| OLD | NEW |
| 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 "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "content/browser/message_port_message_filter.h" | 8 #include "content/browser/message_port_message_filter.h" |
| 9 #include "content/browser/service_worker/service_worker_context_core.h" | 9 #include "content/browser/service_worker/service_worker_context_core.h" |
| 10 #include "content/browser/service_worker/service_worker_context_request_handler.
h" | 10 #include "content/browser/service_worker/service_worker_context_request_handler.
h" |
| 11 #include "content/browser/service_worker/service_worker_controllee_request_handl
er.h" | 11 #include "content/browser/service_worker/service_worker_controllee_request_handl
er.h" |
| 12 #include "content/browser/service_worker/service_worker_dispatcher_host.h" | 12 #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
| 13 #include "content/browser/service_worker/service_worker_handle.h" | 13 #include "content/browser/service_worker/service_worker_handle.h" |
| 14 #include "content/browser/service_worker/service_worker_registration_handle.h" | 14 #include "content/browser/service_worker/service_worker_registration_handle.h" |
| 15 #include "content/browser/service_worker/service_worker_utils.h" | 15 #include "content/browser/service_worker/service_worker_utils.h" |
| 16 #include "content/browser/service_worker/service_worker_version.h" | 16 #include "content/browser/service_worker/service_worker_version.h" |
| 17 #include "content/common/resource_request_body.h" |
| 17 #include "content/common/service_worker/service_worker_messages.h" | 18 #include "content/common/service_worker/service_worker_messages.h" |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 | 21 |
| 21 static const int kDocumentMainThreadId = 0; | 22 static const int kDocumentMainThreadId = 0; |
| 22 | 23 |
| 23 ServiceWorkerProviderHost::ServiceWorkerProviderHost( | 24 ServiceWorkerProviderHost::ServiceWorkerProviderHost( |
| 24 int process_id, int provider_id, | 25 int process_id, int provider_id, |
| 25 base::WeakPtr<ServiceWorkerContextCore> context, | 26 base::WeakPtr<ServiceWorkerContextCore> context, |
| 26 ServiceWorkerDispatcherHost* dispatcher_host) | 27 ServiceWorkerDispatcherHost* dispatcher_host) |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 if (!associated_registration_) | 180 if (!associated_registration_) |
| 180 return; | 181 return; |
| 181 associated_registration_->RemoveListener(this); | 182 associated_registration_->RemoveListener(this); |
| 182 associated_registration_ = NULL; | 183 associated_registration_ = NULL; |
| 183 ClearVersionAttributes(); | 184 ClearVersionAttributes(); |
| 184 } | 185 } |
| 185 | 186 |
| 186 scoped_ptr<ServiceWorkerRequestHandler> | 187 scoped_ptr<ServiceWorkerRequestHandler> |
| 187 ServiceWorkerProviderHost::CreateRequestHandler( | 188 ServiceWorkerProviderHost::CreateRequestHandler( |
| 188 ResourceType resource_type, | 189 ResourceType resource_type, |
| 189 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context) { | 190 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context, |
| 191 scoped_refptr<ResourceRequestBody> body) { |
| 190 if (IsHostToRunningServiceWorker()) { | 192 if (IsHostToRunningServiceWorker()) { |
| 191 return scoped_ptr<ServiceWorkerRequestHandler>( | 193 return scoped_ptr<ServiceWorkerRequestHandler>( |
| 192 new ServiceWorkerContextRequestHandler( | 194 new ServiceWorkerContextRequestHandler( |
| 193 context_, AsWeakPtr(), blob_storage_context, resource_type)); | 195 context_, AsWeakPtr(), blob_storage_context, resource_type)); |
| 194 } | 196 } |
| 195 if (ServiceWorkerUtils::IsMainResourceType(resource_type) || | 197 if (ServiceWorkerUtils::IsMainResourceType(resource_type) || |
| 196 active_version()) { | 198 active_version()) { |
| 197 return scoped_ptr<ServiceWorkerRequestHandler>( | 199 return scoped_ptr<ServiceWorkerRequestHandler>( |
| 198 new ServiceWorkerControlleeRequestHandler( | 200 new ServiceWorkerControlleeRequestHandler( |
| 199 context_, AsWeakPtr(), blob_storage_context, resource_type)); | 201 context_, AsWeakPtr(), blob_storage_context, resource_type, body)); |
| 200 } | 202 } |
| 201 return scoped_ptr<ServiceWorkerRequestHandler>(); | 203 return scoped_ptr<ServiceWorkerRequestHandler>(); |
| 202 } | 204 } |
| 203 | 205 |
| 204 bool ServiceWorkerProviderHost::CanAssociateRegistration( | 206 bool ServiceWorkerProviderHost::CanAssociateRegistration( |
| 205 ServiceWorkerRegistration* registration) { | 207 ServiceWorkerRegistration* registration) { |
| 206 if (!context_) | 208 if (!context_) |
| 207 return false; | 209 return false; |
| 208 if (running_hosted_version_) | 210 if (running_hosted_version_) |
| 209 return false; | 211 return false; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 dispatcher_host_->RegisterServiceWorkerHandle(handle.Pass()); | 247 dispatcher_host_->RegisterServiceWorkerHandle(handle.Pass()); |
| 246 } | 248 } |
| 247 return info; | 249 return info; |
| 248 } | 250 } |
| 249 | 251 |
| 250 bool ServiceWorkerProviderHost::IsContextAlive() { | 252 bool ServiceWorkerProviderHost::IsContextAlive() { |
| 251 return context_ != NULL; | 253 return context_ != NULL; |
| 252 } | 254 } |
| 253 | 255 |
| 254 } // namespace content | 256 } // namespace content |
| OLD | NEW |