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 "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "content/child/child_thread.h" | 9 #include "content/child/child_thread.h" |
10 #include "content/child/service_worker/service_worker_dispatcher.h" | 10 #include "content/child/service_worker/service_worker_dispatcher.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 return; | 40 return; |
41 } | 41 } |
42 | 42 |
43 // TODO(kinuko): Here we could also register the current thread ID | 43 // TODO(kinuko): Here we could also register the current thread ID |
44 // on the provider context so that multiple WebServiceWorkerProviderImpl | 44 // on the provider context so that multiple WebServiceWorkerProviderImpl |
45 // (e.g. on document and on dedicated workers) can properly share | 45 // (e.g. on document and on dedicated workers) can properly share |
46 // the single provider context across threads. (http://crbug.com/366538 | 46 // the single provider context across threads. (http://crbug.com/366538 |
47 // for more context) | 47 // for more context) |
48 GetDispatcher()->AddScriptClient(provider_id_, client); | 48 GetDispatcher()->AddScriptClient(provider_id_, client); |
49 | 49 |
50 if (context_->installing_handle_id() != kInvalidServiceWorkerHandleId) { | |
51 client->setInstalling(GetDispatcher()->GetServiceWorker( | |
52 context_->installing()->info(), false)); | |
53 } | |
54 | |
55 if (context_->waiting_handle_id() != kInvalidServiceWorkerHandleId) { | |
56 client->setWaiting(GetDispatcher()->GetServiceWorker( | |
57 context_->waiting()->info(), false)); | |
58 } | |
59 | |
60 if (context_->active_handle_id() != kInvalidServiceWorkerHandleId) { | |
61 client->setActive(GetDispatcher()->GetServiceWorker( | |
62 context_->active()->info(), false)); | |
63 } | |
64 | |
65 if (context_->controller_handle_id() != kInvalidServiceWorkerHandleId) { | 50 if (context_->controller_handle_id() != kInvalidServiceWorkerHandleId) { |
66 client->setController(GetDispatcher()->GetServiceWorker( | 51 client->setController(GetDispatcher()->GetServiceWorker( |
67 context_->controller()->info(), false)); | 52 context_->controller()->info(), false)); |
68 } | 53 } |
69 } | 54 } |
70 | 55 |
71 void WebServiceWorkerProviderImpl::registerServiceWorker( | 56 void WebServiceWorkerProviderImpl::registerServiceWorker( |
72 const WebURL& pattern, | 57 const WebURL& pattern, |
73 const WebURL& script_url, | 58 const WebURL& script_url, |
74 WebServiceWorkerRegistrationCallbacks* callbacks) { | 59 WebServiceWorkerRegistrationCallbacks* callbacks) { |
(...skipping 16 matching lines...) Expand all Loading... |
91 if (dispatcher) | 76 if (dispatcher) |
92 dispatcher->RemoveScriptClient(provider_id_); | 77 dispatcher->RemoveScriptClient(provider_id_); |
93 } | 78 } |
94 | 79 |
95 ServiceWorkerDispatcher* WebServiceWorkerProviderImpl::GetDispatcher() { | 80 ServiceWorkerDispatcher* WebServiceWorkerProviderImpl::GetDispatcher() { |
96 return ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance( | 81 return ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance( |
97 thread_safe_sender_.get()); | 82 thread_safe_sender_.get()); |
98 } | 83 } |
99 | 84 |
100 } // namespace content | 85 } // namespace content |
OLD | NEW |