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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 return; | 42 return; |
43 } | 43 } |
44 | 44 |
45 // TODO(kinuko): Here we could also register the current thread ID | 45 // TODO(kinuko): Here we could also register the current thread ID |
46 // on the provider context so that multiple WebServiceWorkerProviderImpl | 46 // on the provider context so that multiple WebServiceWorkerProviderImpl |
47 // (e.g. on document and on dedicated workers) can properly share | 47 // (e.g. on document and on dedicated workers) can properly share |
48 // the single provider context across threads. (http://crbug.com/366538 | 48 // the single provider context across threads. (http://crbug.com/366538 |
49 // for more context) | 49 // for more context) |
50 GetDispatcher()->AddProviderClient(provider_id_, client); | 50 GetDispatcher()->AddProviderClient(provider_id_, client); |
51 | 51 |
52 if (!context_->registration()) { | 52 if (!context_->IsAssociatedWithRegistration()) |
Kunihiko Sakamoto
2015/01/28 06:38:55
I wonder if this and GetRegistrationInfoAndVersion
nhiroki
2015/01/28 07:42:27
Good point. Done.
| |
53 // This provider is not associated with any registration. | |
54 return; | 53 return; |
55 } | |
56 | 54 |
57 // Set .ready if the associated registration has the active service worker. | 55 // Set .ready if the associated registration has the active service worker. |
58 if (context_->active_handle_id() != kInvalidServiceWorkerHandleId) { | 56 if (context_->active_handle_id() != kInvalidServiceWorkerHandleId) { |
57 ServiceWorkerRegistrationObjectInfo info; | |
58 ServiceWorkerVersionAttributes attrs; | |
59 context_->GetRegistrationInfoAndVersionAttributes(&info, &attrs); | |
60 | |
59 WebServiceWorkerRegistrationImpl* registration = | 61 WebServiceWorkerRegistrationImpl* registration = |
60 GetDispatcher()->FindServiceWorkerRegistration( | 62 GetDispatcher()->FindServiceWorkerRegistration(info, false); |
61 context_->registration()->info(), false); | |
62 if (!registration) { | 63 if (!registration) { |
63 registration = GetDispatcher()->CreateServiceWorkerRegistration( | 64 registration = |
64 context_->registration()->info(), false); | 65 GetDispatcher()->CreateServiceWorkerRegistration(info, false); |
65 ServiceWorkerVersionAttributes attrs = context_->GetVersionAttributes(); | |
66 registration->SetInstalling( | 66 registration->SetInstalling( |
67 GetDispatcher()->GetServiceWorker(attrs.installing, false)); | 67 GetDispatcher()->GetServiceWorker(attrs.installing, false)); |
68 registration->SetWaiting( | 68 registration->SetWaiting( |
69 GetDispatcher()->GetServiceWorker(attrs.waiting, false)); | 69 GetDispatcher()->GetServiceWorker(attrs.waiting, false)); |
70 registration->SetActive( | 70 registration->SetActive( |
71 GetDispatcher()->GetServiceWorker(attrs.active, false)); | 71 GetDispatcher()->GetServiceWorker(attrs.active, false)); |
72 } | 72 } |
73 client->setReadyRegistration(registration); | 73 client->setReadyRegistration(registration); |
74 } | 74 } |
75 | 75 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 if (dispatcher) | 109 if (dispatcher) |
110 dispatcher->RemoveProviderClient(provider_id_); | 110 dispatcher->RemoveProviderClient(provider_id_); |
111 } | 111 } |
112 | 112 |
113 ServiceWorkerDispatcher* WebServiceWorkerProviderImpl::GetDispatcher() { | 113 ServiceWorkerDispatcher* WebServiceWorkerProviderImpl::GetDispatcher() { |
114 return ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance( | 114 return ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance( |
115 thread_safe_sender_.get()); | 115 thread_safe_sender_.get()); |
116 } | 116 } |
117 | 117 |
118 } // namespace content | 118 } // namespace content |
OLD | NEW |