OLD | NEW |
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 FetchCredentialsMode credentials_mode, |
28 ResourceType resource_type, | 28 ResourceType resource_type, |
| 29 RequestContextType request_context_type, |
| 30 RequestContextFrameType frame_type, |
29 scoped_refptr<ResourceRequestBody> body) | 31 scoped_refptr<ResourceRequestBody> body) |
30 : ServiceWorkerRequestHandler(context, | 32 : ServiceWorkerRequestHandler(context, |
31 provider_host, | 33 provider_host, |
32 blob_storage_context, | 34 blob_storage_context, |
33 resource_type), | 35 resource_type), |
34 is_main_resource_load_( | 36 is_main_resource_load_( |
35 ServiceWorkerUtils::IsMainResourceType(resource_type)), | 37 ServiceWorkerUtils::IsMainResourceType(resource_type)), |
36 request_mode_(request_mode), | 38 request_mode_(request_mode), |
37 credentials_mode_(credentials_mode), | 39 credentials_mode_(credentials_mode), |
| 40 request_context_type_(request_context_type), |
| 41 frame_type_(frame_type), |
38 body_(body), | 42 body_(body), |
39 weak_factory_(this) { | 43 weak_factory_(this) { |
40 } | 44 } |
41 | 45 |
42 ServiceWorkerControlleeRequestHandler:: | 46 ServiceWorkerControlleeRequestHandler:: |
43 ~ServiceWorkerControlleeRequestHandler() { | 47 ~ServiceWorkerControlleeRequestHandler() { |
44 // Navigation triggers an update to occur shortly after the page and | 48 // Navigation triggers an update to occur shortly after the page and |
45 // its initial subresources load. | 49 // its initial subresources load. |
46 if (provider_host_ && provider_host_->active_version()) { | 50 if (provider_host_ && provider_host_->active_version()) { |
47 if (is_main_resource_load_) | 51 if (is_main_resource_load_) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 83 |
80 // It's for original request (A) or redirect case (B-a or B-b). | 84 // It's for original request (A) or redirect case (B-a or B-b). |
81 DCHECK(!job_.get() || job_->ShouldForwardToServiceWorker()); | 85 DCHECK(!job_.get() || job_->ShouldForwardToServiceWorker()); |
82 | 86 |
83 job_ = new ServiceWorkerURLRequestJob(request, | 87 job_ = new ServiceWorkerURLRequestJob(request, |
84 network_delegate, | 88 network_delegate, |
85 provider_host_, | 89 provider_host_, |
86 blob_storage_context_, | 90 blob_storage_context_, |
87 request_mode_, | 91 request_mode_, |
88 credentials_mode_, | 92 credentials_mode_, |
| 93 request_context_type_, |
| 94 frame_type_, |
89 body_); | 95 body_); |
90 if (is_main_resource_load_) | 96 if (is_main_resource_load_) |
91 PrepareForMainResource(request->url()); | 97 PrepareForMainResource(request->url()); |
92 else | 98 else |
93 PrepareForSubResource(); | 99 PrepareForSubResource(); |
94 | 100 |
95 if (job_->ShouldFallbackToNetwork()) { | 101 if (job_->ShouldFallbackToNetwork()) { |
96 // If we know we can fallback to network at this point (in case | 102 // If we know we can fallback to network at this point (in case |
97 // the storage lookup returned immediately), just return NULL here to | 103 // the storage lookup returned immediately), just return NULL here to |
98 // fallback to network. | 104 // fallback to network. |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 } | 247 } |
242 | 248 |
243 void ServiceWorkerControlleeRequestHandler::PrepareForSubResource() { | 249 void ServiceWorkerControlleeRequestHandler::PrepareForSubResource() { |
244 DCHECK(job_.get()); | 250 DCHECK(job_.get()); |
245 DCHECK(context_); | 251 DCHECK(context_); |
246 DCHECK(provider_host_->active_version()); | 252 DCHECK(provider_host_->active_version()); |
247 job_->ForwardToServiceWorker(); | 253 job_->ForwardToServiceWorker(); |
248 } | 254 } |
249 | 255 |
250 } // namespace content | 256 } // namespace content |
OLD | NEW |