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

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

Issue 615493003: [ServiceWorker] Plumbing the request credentials mode to the ServiceWorker. [2/2 chromium] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_controllee_request_handl er.h" 5 #include "content/browser/service_worker/service_worker_controllee_request_handl er.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "content/browser/service_worker/service_worker_context_core.h" 8 #include "content/browser/service_worker/service_worker_context_core.h"
9 #include "content/browser/service_worker/service_worker_metrics.h" 9 #include "content/browser/service_worker/service_worker_metrics.h"
10 #include "content/browser/service_worker/service_worker_provider_host.h" 10 #include "content/browser/service_worker/service_worker_provider_host.h"
11 #include "content/browser/service_worker/service_worker_registration.h" 11 #include "content/browser/service_worker/service_worker_registration.h"
12 #include "content/browser/service_worker/service_worker_url_request_job.h" 12 #include "content/browser/service_worker/service_worker_url_request_job.h"
13 #include "content/browser/service_worker/service_worker_utils.h" 13 #include "content/browser/service_worker/service_worker_utils.h"
14 #include "content/common/resource_request_body.h" 14 #include "content/common/resource_request_body.h"
15 #include "content/common/service_worker/service_worker_types.h" 15 #include "content/common/service_worker/service_worker_types.h"
16 #include "net/base/load_flags.h" 16 #include "net/base/load_flags.h"
17 #include "net/base/net_util.h" 17 #include "net/base/net_util.h"
18 #include "net/url_request/url_request.h" 18 #include "net/url_request/url_request.h"
19 19
20 namespace content { 20 namespace content {
21 21
22 ServiceWorkerControlleeRequestHandler::ServiceWorkerControlleeRequestHandler( 22 ServiceWorkerControlleeRequestHandler::ServiceWorkerControlleeRequestHandler(
23 base::WeakPtr<ServiceWorkerContextCore> context, 23 base::WeakPtr<ServiceWorkerContextCore> context,
24 base::WeakPtr<ServiceWorkerProviderHost> provider_host, 24 base::WeakPtr<ServiceWorkerProviderHost> provider_host,
25 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, 25 base::WeakPtr<storage::BlobStorageContext> blob_storage_context,
26 FetchRequestMode request_mode, 26 FetchRequestMode request_mode,
27 FetchCredentialsMode credentials_mode,
27 ResourceType resource_type, 28 ResourceType resource_type,
28 scoped_refptr<ResourceRequestBody> body) 29 scoped_refptr<ResourceRequestBody> body)
29 : ServiceWorkerRequestHandler(context, 30 : ServiceWorkerRequestHandler(context,
30 provider_host, 31 provider_host,
31 blob_storage_context, 32 blob_storage_context,
32 resource_type), 33 resource_type),
33 is_main_resource_load_( 34 is_main_resource_load_(
34 ServiceWorkerUtils::IsMainResourceType(resource_type)), 35 ServiceWorkerUtils::IsMainResourceType(resource_type)),
35 request_mode_(request_mode), 36 request_mode_(request_mode),
37 credentials_mode_(credentials_mode),
36 body_(body), 38 body_(body),
37 weak_factory_(this) { 39 weak_factory_(this) {
38 } 40 }
39 41
40 ServiceWorkerControlleeRequestHandler:: 42 ServiceWorkerControlleeRequestHandler::
41 ~ServiceWorkerControlleeRequestHandler() { 43 ~ServiceWorkerControlleeRequestHandler() {
42 // Navigation triggers an update to occur shortly after the page and 44 // Navigation triggers an update to occur shortly after the page and
43 // its initial subresources load. 45 // its initial subresources load.
44 if (provider_host_ && provider_host_->active_version()) { 46 if (provider_host_ && provider_host_->active_version()) {
45 if (is_main_resource_load_) 47 if (is_main_resource_load_)
(...skipping 30 matching lines...) Expand all
76 } 78 }
77 79
78 // It's for original request (A) or redirect case (B-a or B-b). 80 // It's for original request (A) or redirect case (B-a or B-b).
79 DCHECK(!job_.get() || job_->ShouldForwardToServiceWorker()); 81 DCHECK(!job_.get() || job_->ShouldForwardToServiceWorker());
80 82
81 job_ = new ServiceWorkerURLRequestJob(request, 83 job_ = new ServiceWorkerURLRequestJob(request,
82 network_delegate, 84 network_delegate,
83 provider_host_, 85 provider_host_,
84 blob_storage_context_, 86 blob_storage_context_,
85 request_mode_, 87 request_mode_,
88 credentials_mode_,
86 body_); 89 body_);
87 if (is_main_resource_load_) 90 if (is_main_resource_load_)
88 PrepareForMainResource(request->url()); 91 PrepareForMainResource(request->url());
89 else 92 else
90 PrepareForSubResource(); 93 PrepareForSubResource();
91 94
92 if (job_->ShouldFallbackToNetwork()) { 95 if (job_->ShouldFallbackToNetwork()) {
93 // If we know we can fallback to network at this point (in case 96 // If we know we can fallback to network at this point (in case
94 // the storage lookup returned immediately), just return NULL here to 97 // the storage lookup returned immediately), just return NULL here to
95 // fallback to network. 98 // fallback to network.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 241 }
239 242
240 void ServiceWorkerControlleeRequestHandler::PrepareForSubResource() { 243 void ServiceWorkerControlleeRequestHandler::PrepareForSubResource() {
241 DCHECK(job_.get()); 244 DCHECK(job_.get());
242 DCHECK(context_); 245 DCHECK(context_);
243 DCHECK(provider_host_->active_version()); 246 DCHECK(provider_host_->active_version());
244 job_->ForwardToServiceWorker(); 247 job_->ForwardToServiceWorker();
245 } 248 }
246 249
247 } // namespace content 250 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698