| 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/child/service_worker/web_service_worker_provider_impl.h" | 5 #include "content/child/service_worker/web_service_worker_provider_impl.h" |
| 6 | 6 |
| 7 #include "content/child/service_worker/service_worker_dispatcher.h" | 7 #include "content/child/service_worker/service_worker_dispatcher.h" |
| 8 #include "content/child/service_worker/service_worker_handle_reference.h" | 8 #include "content/child/service_worker/service_worker_handle_reference.h" |
| 9 #include "content/child/service_worker/service_worker_provider_context.h" | 9 #include "content/child/service_worker/service_worker_provider_context.h" |
| 10 #include "content/child/service_worker/web_service_worker_impl.h" | 10 #include "content/child/service_worker/web_service_worker_impl.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // TODO(kinuko): Here we could also register the current thread ID | 40 // TODO(kinuko): Here we could also register the current thread ID |
| 41 // on the provider context so that multiple WebServiceWorkerProviderImpl | 41 // on the provider context so that multiple WebServiceWorkerProviderImpl |
| 42 // (e.g. on document and on dedicated workers) can properly share | 42 // (e.g. on document and on dedicated workers) can properly share |
| 43 // the single provider context across threads. (http://crbug.com/366538 | 43 // the single provider context across threads. (http://crbug.com/366538 |
| 44 // for more context) | 44 // for more context) |
| 45 GetDispatcher()->AddProviderClient(context_->provider_id(), client); | 45 GetDispatcher()->AddProviderClient(context_->provider_id(), client); |
| 46 | 46 |
| 47 if (!context_->controller()) | 47 if (!context_->controller()) |
| 48 return; | 48 return; |
| 49 scoped_refptr<WebServiceWorkerImpl> controller = | 49 scoped_refptr<WebServiceWorkerImpl> controller = |
| 50 GetDispatcher()->GetOrCreateServiceWorker(context_->controller()->info()); | 50 GetDispatcher()->GetOrCreateServiceWorker( |
| 51 ServiceWorkerHandleReference::Create(context_->controller()->info(), |
| 52 thread_safe_sender_.get())); |
| 51 client->setController(WebServiceWorkerImpl::CreateHandle(controller), | 53 client->setController(WebServiceWorkerImpl::CreateHandle(controller), |
| 52 false /* shouldNotifyControllerChange */); | 54 false /* shouldNotifyControllerChange */); |
| 53 } | 55 } |
| 54 | 56 |
| 55 void WebServiceWorkerProviderImpl::registerServiceWorker( | 57 void WebServiceWorkerProviderImpl::registerServiceWorker( |
| 56 const WebURL& pattern, | 58 const WebURL& pattern, |
| 57 const WebURL& script_url, | 59 const WebURL& script_url, |
| 58 WebServiceWorkerRegistrationCallbacks* callbacks) { | 60 WebServiceWorkerRegistrationCallbacks* callbacks) { |
| 59 GetDispatcher()->RegisterServiceWorker( | 61 GetDispatcher()->RegisterServiceWorker( |
| 60 context_->provider_id(), pattern, script_url, callbacks); | 62 context_->provider_id(), pattern, script_url, callbacks); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 103 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
| 102 if (dispatcher) | 104 if (dispatcher) |
| 103 dispatcher->RemoveProviderClient(context_->provider_id()); | 105 dispatcher->RemoveProviderClient(context_->provider_id()); |
| 104 } | 106 } |
| 105 | 107 |
| 106 ServiceWorkerDispatcher* WebServiceWorkerProviderImpl::GetDispatcher() { | 108 ServiceWorkerDispatcher* WebServiceWorkerProviderImpl::GetDispatcher() { |
| 107 return ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 109 return ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
| 108 } | 110 } |
| 109 | 111 |
| 110 } // namespace content | 112 } // namespace content |
| OLD | NEW |