| 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/resource_request_body.h" |
| 18 #include "content/common/service_worker/service_worker_messages.h" | 18 #include "content/common/service_worker/service_worker_messages.h" |
| 19 #include "content/common/service_worker/service_worker_types.h" |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 21 | 22 |
| 22 static const int kDocumentMainThreadId = 0; | 23 static const int kDocumentMainThreadId = 0; |
| 23 | 24 |
| 24 ServiceWorkerProviderHost::ServiceWorkerProviderHost( | 25 ServiceWorkerProviderHost::ServiceWorkerProviderHost( |
| 25 int process_id, int provider_id, | 26 int process_id, int provider_id, |
| 26 base::WeakPtr<ServiceWorkerContextCore> context, | 27 base::WeakPtr<ServiceWorkerContextCore> context, |
| 27 ServiceWorkerDispatcherHost* dispatcher_host) | 28 ServiceWorkerDispatcherHost* dispatcher_host) |
| 28 : process_id_(process_id), | 29 : process_id_(process_id), |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 SetControllerVersionAttribute(NULL); | 139 SetControllerVersionAttribute(NULL); |
| 139 | 140 |
| 140 if (dispatcher_host_) { | 141 if (dispatcher_host_) { |
| 141 dispatcher_host_->Send(new ServiceWorkerMsg_DisassociateRegistration( | 142 dispatcher_host_->Send(new ServiceWorkerMsg_DisassociateRegistration( |
| 142 kDocumentMainThreadId, provider_id())); | 143 kDocumentMainThreadId, provider_id())); |
| 143 } | 144 } |
| 144 } | 145 } |
| 145 | 146 |
| 146 scoped_ptr<ServiceWorkerRequestHandler> | 147 scoped_ptr<ServiceWorkerRequestHandler> |
| 147 ServiceWorkerProviderHost::CreateRequestHandler( | 148 ServiceWorkerProviderHost::CreateRequestHandler( |
| 149 FetchRequestMode request_mode, |
| 148 ResourceType resource_type, | 150 ResourceType resource_type, |
| 149 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, | 151 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, |
| 150 scoped_refptr<ResourceRequestBody> body) { | 152 scoped_refptr<ResourceRequestBody> body) { |
| 151 if (IsHostToRunningServiceWorker()) { | 153 if (IsHostToRunningServiceWorker()) { |
| 152 return scoped_ptr<ServiceWorkerRequestHandler>( | 154 return scoped_ptr<ServiceWorkerRequestHandler>( |
| 153 new ServiceWorkerContextRequestHandler( | 155 new ServiceWorkerContextRequestHandler( |
| 154 context_, AsWeakPtr(), blob_storage_context, resource_type)); | 156 context_, AsWeakPtr(), blob_storage_context, resource_type)); |
| 155 } | 157 } |
| 156 if (ServiceWorkerUtils::IsMainResourceType(resource_type) || | 158 if (ServiceWorkerUtils::IsMainResourceType(resource_type) || |
| 157 controlling_version()) { | 159 controlling_version()) { |
| 158 return scoped_ptr<ServiceWorkerRequestHandler>( | 160 return scoped_ptr<ServiceWorkerRequestHandler>( |
| 159 new ServiceWorkerControlleeRequestHandler( | 161 new ServiceWorkerControlleeRequestHandler(context_, |
| 160 context_, AsWeakPtr(), blob_storage_context, resource_type, body)); | 162 AsWeakPtr(), |
| 163 blob_storage_context, |
| 164 request_mode, |
| 165 resource_type, |
| 166 body)); |
| 161 } | 167 } |
| 162 return scoped_ptr<ServiceWorkerRequestHandler>(); | 168 return scoped_ptr<ServiceWorkerRequestHandler>(); |
| 163 } | 169 } |
| 164 | 170 |
| 165 bool ServiceWorkerProviderHost::CanAssociateRegistration( | 171 bool ServiceWorkerProviderHost::CanAssociateRegistration( |
| 166 ServiceWorkerRegistration* registration) { | 172 ServiceWorkerRegistration* registration) { |
| 167 if (!context_) | 173 if (!context_) |
| 168 return false; | 174 return false; |
| 169 if (running_hosted_version_.get()) | 175 if (running_hosted_version_.get()) |
| 170 return false; | 176 return false; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 context_->process_manager()->RemoveProcessReferenceFromPattern( | 234 context_->process_manager()->RemoveProcessReferenceFromPattern( |
| 229 pattern, process_id_); | 235 pattern, process_id_); |
| 230 } | 236 } |
| 231 } | 237 } |
| 232 | 238 |
| 233 bool ServiceWorkerProviderHost::IsContextAlive() { | 239 bool ServiceWorkerProviderHost::IsContextAlive() { |
| 234 return context_ != NULL; | 240 return context_ != NULL; |
| 235 } | 241 } |
| 236 | 242 |
| 237 } // namespace content | 243 } // namespace content |
| OLD | NEW |