| 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/trace_event/trace_event.h" | 7 #include "base/trace_event/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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 ServiceWorkerControlleeRequestHandler::ServiceWorkerControlleeRequestHandler( | 24 ServiceWorkerControlleeRequestHandler::ServiceWorkerControlleeRequestHandler( |
| 25 base::WeakPtr<ServiceWorkerContextCore> context, | 25 base::WeakPtr<ServiceWorkerContextCore> context, |
| 26 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 26 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
| 27 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, | 27 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, |
| 28 FetchRequestMode request_mode, | 28 FetchRequestMode request_mode, |
| 29 FetchCredentialsMode credentials_mode, | 29 FetchCredentialsMode credentials_mode, |
| 30 ResourceType resource_type, | 30 ResourceType resource_type, |
| 31 RequestContextType request_context_type, | 31 RequestContextType request_context_type, |
| 32 RequestContextFrameType frame_type, | 32 RequestContextFrameType frame_type, |
| 33 const ServiceWorkerClientInfo& client_info, |
| 33 scoped_refptr<ResourceRequestBody> body) | 34 scoped_refptr<ResourceRequestBody> body) |
| 34 : ServiceWorkerRequestHandler(context, | 35 : ServiceWorkerRequestHandler(context, |
| 35 provider_host, | 36 provider_host, |
| 36 blob_storage_context, | 37 blob_storage_context, |
| 37 resource_type), | 38 resource_type), |
| 38 is_main_resource_load_( | 39 is_main_resource_load_( |
| 39 ServiceWorkerUtils::IsMainResourceType(resource_type)), | 40 ServiceWorkerUtils::IsMainResourceType(resource_type)), |
| 40 request_mode_(request_mode), | 41 request_mode_(request_mode), |
| 41 credentials_mode_(credentials_mode), | 42 credentials_mode_(credentials_mode), |
| 42 request_context_type_(request_context_type), | 43 request_context_type_(request_context_type), |
| 43 frame_type_(frame_type), | 44 frame_type_(frame_type), |
| 45 client_info_(client_info), |
| 44 body_(body), | 46 body_(body), |
| 45 weak_factory_(this) { | 47 weak_factory_(this) { |
| 46 } | 48 } |
| 47 | 49 |
| 48 ServiceWorkerControlleeRequestHandler:: | 50 ServiceWorkerControlleeRequestHandler:: |
| 49 ~ServiceWorkerControlleeRequestHandler() { | 51 ~ServiceWorkerControlleeRequestHandler() { |
| 50 // Navigation triggers an update to occur shortly after the page and | 52 // Navigation triggers an update to occur shortly after the page and |
| 51 // its initial subresources load. | 53 // its initial subresources load. |
| 52 if (provider_host_ && provider_host_->active_version()) { | 54 if (provider_host_ && provider_host_->active_version()) { |
| 53 if (is_main_resource_load_) | 55 if (is_main_resource_load_) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 83 job_ = NULL; | 85 job_ = NULL; |
| 84 return NULL; | 86 return NULL; |
| 85 } | 87 } |
| 86 | 88 |
| 87 // It's for original request (A) or redirect case (B-a or B-b). | 89 // It's for original request (A) or redirect case (B-a or B-b). |
| 88 DCHECK(!job_.get() || job_->ShouldForwardToServiceWorker()); | 90 DCHECK(!job_.get() || job_->ShouldForwardToServiceWorker()); |
| 89 | 91 |
| 90 job_ = new ServiceWorkerURLRequestJob( | 92 job_ = new ServiceWorkerURLRequestJob( |
| 91 request, network_delegate, provider_host_, blob_storage_context_, | 93 request, network_delegate, provider_host_, blob_storage_context_, |
| 92 resource_context, request_mode_, credentials_mode_, | 94 resource_context, request_mode_, credentials_mode_, |
| 93 is_main_resource_load_, request_context_type_, frame_type_, body_); | 95 is_main_resource_load_, request_context_type_, frame_type_, client_info_, |
| 96 body_); |
| 94 resource_context_ = resource_context; | 97 resource_context_ = resource_context; |
| 95 | 98 |
| 96 if (is_main_resource_load_) | 99 if (is_main_resource_load_) |
| 97 PrepareForMainResource(request); | 100 PrepareForMainResource(request); |
| 98 else | 101 else |
| 99 PrepareForSubResource(); | 102 PrepareForSubResource(); |
| 100 | 103 |
| 101 if (job_->ShouldFallbackToNetwork()) { | 104 if (job_->ShouldFallbackToNetwork()) { |
| 102 // If we know we can fallback to network at this point (in case | 105 // If we know we can fallback to network at this point (in case |
| 103 // the storage lookup returned immediately), just return NULL here to | 106 // the storage lookup returned immediately), just return NULL here to |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 } | 268 } |
| 266 | 269 |
| 267 void ServiceWorkerControlleeRequestHandler::PrepareForSubResource() { | 270 void ServiceWorkerControlleeRequestHandler::PrepareForSubResource() { |
| 268 DCHECK(job_.get()); | 271 DCHECK(job_.get()); |
| 269 DCHECK(context_); | 272 DCHECK(context_); |
| 270 DCHECK(provider_host_->active_version()); | 273 DCHECK(provider_host_->active_version()); |
| 271 job_->ForwardToServiceWorker(); | 274 job_->ForwardToServiceWorker(); |
| 272 } | 275 } |
| 273 | 276 |
| 274 } // namespace content | 277 } // namespace content |
| OLD | NEW |