Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: content/browser/service_worker/service_worker_provider_host.cc

Issue 2843043002: network service: Create URLLoader for service worker navigation case
Patch Set: . Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/service_worker/service_worker_provider_host.h" 5 #include "content/browser/service_worker/service_worker_provider_host.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/feature_list.h" 9 #include "base/feature_list.h"
10 #include "base/guid.h" 10 #include "base/guid.h"
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 std::unique_ptr<ServiceWorkerRequestHandler> 408 std::unique_ptr<ServiceWorkerRequestHandler>
409 ServiceWorkerProviderHost::CreateRequestHandler( 409 ServiceWorkerProviderHost::CreateRequestHandler(
410 FetchRequestMode request_mode, 410 FetchRequestMode request_mode,
411 FetchCredentialsMode credentials_mode, 411 FetchCredentialsMode credentials_mode,
412 FetchRedirectMode redirect_mode, 412 FetchRedirectMode redirect_mode,
413 ResourceType resource_type, 413 ResourceType resource_type,
414 RequestContextType request_context_type, 414 RequestContextType request_context_type,
415 RequestContextFrameType frame_type, 415 RequestContextFrameType frame_type,
416 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, 416 base::WeakPtr<storage::BlobStorageContext> blob_storage_context,
417 scoped_refptr<ResourceRequestBodyImpl> body, 417 scoped_refptr<ResourceRequestBodyImpl> body,
418 bool skip_service_worker) { 418 bool skip_service_worker,
419 NetworkFallbackCallback network_fallback_callback) {
419 // |skip_service_worker| is meant to apply to requests that could be handled 420 // |skip_service_worker| is meant to apply to requests that could be handled
420 // by a service worker, as opposed to requests for the service worker script 421 // by a service worker, as opposed to requests for the service worker script
421 // itself. So ignore it here for the service worker script and its imported 422 // itself. So ignore it here for the service worker script and its imported
422 // scripts. 423 // scripts.
423 // TODO(falken): Really it should be treated as an error to set 424 // TODO(falken): Really it should be treated as an error to set
424 // |skip_service_worker| for requests to start the service worker, but it's 425 // |skip_service_worker| for requests to start the service worker, but it's
425 // difficult to fix that renderer-side, since we don't know whether a request 426 // difficult to fix that renderer-side, since we don't know whether a request
426 // is for a service worker without access to IsHostToRunningServiceWorker() as 427 // is for a service worker without access to IsHostToRunningServiceWorker() as
427 // that state is stored browser-side. 428 // that state is stored browser-side.
428 if (IsHostToRunningServiceWorker() && 429 if (IsHostToRunningServiceWorker() &&
429 (resource_type == RESOURCE_TYPE_SERVICE_WORKER || 430 (resource_type == RESOURCE_TYPE_SERVICE_WORKER ||
430 resource_type == RESOURCE_TYPE_SCRIPT)) { 431 resource_type == RESOURCE_TYPE_SCRIPT)) {
431 skip_service_worker = false; 432 skip_service_worker = false;
432 } 433 }
433 if (skip_service_worker) { 434 if (skip_service_worker) {
434 if (!ServiceWorkerUtils::IsMainResourceType(resource_type)) 435 if (!ServiceWorkerUtils::IsMainResourceType(resource_type))
435 return std::unique_ptr<ServiceWorkerRequestHandler>(); 436 return std::unique_ptr<ServiceWorkerRequestHandler>();
436 return base::MakeUnique<ServiceWorkerURLTrackingRequestHandler>( 437 return base::MakeUnique<ServiceWorkerURLTrackingRequestHandler>(
437 context_, AsWeakPtr(), blob_storage_context, resource_type); 438 context_, AsWeakPtr(), blob_storage_context, resource_type);
438 } 439 }
439 if (IsHostToRunningServiceWorker()) { 440 if (IsHostToRunningServiceWorker()) {
440 return base::MakeUnique<ServiceWorkerContextRequestHandler>( 441 return base::MakeUnique<ServiceWorkerContextRequestHandler>(
441 context_, AsWeakPtr(), blob_storage_context, resource_type); 442 context_, AsWeakPtr(), blob_storage_context, resource_type);
442 } 443 }
443 if (ServiceWorkerUtils::IsMainResourceType(resource_type) || 444 if (ServiceWorkerUtils::IsMainResourceType(resource_type) ||
444 controlling_version()) { 445 controlling_version()) {
445 return base::MakeUnique<ServiceWorkerControlleeRequestHandler>( 446 return base::MakeUnique<ServiceWorkerControlleeRequestHandler>(
446 context_, AsWeakPtr(), blob_storage_context, request_mode, 447 context_, AsWeakPtr(), blob_storage_context, request_mode,
447 credentials_mode, redirect_mode, resource_type, request_context_type, 448 credentials_mode, redirect_mode, resource_type, request_context_type,
448 frame_type, body); 449 frame_type, body, network_fallback_callback);
449 } 450 }
450 return std::unique_ptr<ServiceWorkerRequestHandler>(); 451 return std::unique_ptr<ServiceWorkerRequestHandler>();
451 } 452 }
452 453
453 ServiceWorkerObjectInfo 454 ServiceWorkerObjectInfo
454 ServiceWorkerProviderHost::GetOrCreateServiceWorkerHandle( 455 ServiceWorkerProviderHost::GetOrCreateServiceWorkerHandle(
455 ServiceWorkerVersion* version) { 456 ServiceWorkerVersion* version) {
456 DCHECK(dispatcher_host_); 457 DCHECK(dispatcher_host_);
457 if (!context_ || !version) 458 if (!context_ || !version)
458 return ServiceWorkerObjectInfo(); 459 return ServiceWorkerObjectInfo();
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 render_thread_id_, provider_id(), 787 render_thread_id_, provider_id(),
787 GetOrCreateServiceWorkerHandle( 788 GetOrCreateServiceWorkerHandle(
788 associated_registration_->active_version()), 789 associated_registration_->active_version()),
789 false /* shouldNotifyControllerChange */, 790 false /* shouldNotifyControllerChange */,
790 associated_registration_->active_version()->used_features())); 791 associated_registration_->active_version()->used_features()));
791 } 792 }
792 } 793 }
793 } 794 }
794 795
795 } // namespace content 796 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698