OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_registration_impl.h" | 5 #include "content/child/service_worker/web_service_worker_registration_impl.h" |
6 | 6 |
| 7 #include "base/macros.h" |
7 #include "content/child/service_worker/service_worker_dispatcher.h" | 8 #include "content/child/service_worker/service_worker_dispatcher.h" |
8 #include "content/child/service_worker/service_worker_registration_handle_refere
nce.h" | 9 #include "content/child/service_worker/service_worker_registration_handle_refere
nce.h" |
9 #include "content/child/service_worker/web_service_worker_impl.h" | 10 #include "content/child/service_worker/web_service_worker_impl.h" |
10 #include "content/child/service_worker/web_service_worker_provider_impl.h" | 11 #include "content/child/service_worker/web_service_worker_provider_impl.h" |
11 #include "content/common/service_worker/service_worker_types.h" | 12 #include "content/common/service_worker/service_worker_types.h" |
12 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerRegistrationProxy.h" | 13 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerRegistrationProxy.h" |
13 | 14 |
14 namespace content { | 15 namespace content { |
15 | 16 |
16 namespace { | 17 namespace { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 WebServiceWorkerUnregistrationCallbacks* callbacks) { | 132 WebServiceWorkerUnregistrationCallbacks* callbacks) { |
132 WebServiceWorkerProviderImpl* provider_impl = | 133 WebServiceWorkerProviderImpl* provider_impl = |
133 static_cast<WebServiceWorkerProviderImpl*>(provider); | 134 static_cast<WebServiceWorkerProviderImpl*>(provider); |
134 ServiceWorkerDispatcher* dispatcher = | 135 ServiceWorkerDispatcher* dispatcher = |
135 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 136 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
136 DCHECK(dispatcher); | 137 DCHECK(dispatcher); |
137 dispatcher->UnregisterServiceWorker(provider_impl->provider_id(), | 138 dispatcher->UnregisterServiceWorker(provider_impl->provider_id(), |
138 registration_id(), callbacks); | 139 registration_id(), callbacks); |
139 } | 140 } |
140 | 141 |
141 int64 WebServiceWorkerRegistrationImpl::registration_id() const { | 142 int64_t WebServiceWorkerRegistrationImpl::registration_id() const { |
142 return handle_ref_->registration_id(); | 143 return handle_ref_->registration_id(); |
143 } | 144 } |
144 | 145 |
145 // static | 146 // static |
146 blink::WebPassOwnPtr<blink::WebServiceWorkerRegistration::Handle> | 147 blink::WebPassOwnPtr<blink::WebServiceWorkerRegistration::Handle> |
147 WebServiceWorkerRegistrationImpl::CreateHandle( | 148 WebServiceWorkerRegistrationImpl::CreateHandle( |
148 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) { | 149 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) { |
149 if (!registration) | 150 if (!registration) |
150 return nullptr; | 151 return nullptr; |
151 return blink::adoptWebPtr(new HandleImpl(registration)); | 152 return blink::adoptWebPtr(new HandleImpl(registration)); |
152 } | 153 } |
153 | 154 |
154 blink::WebServiceWorkerRegistration::Handle* | 155 blink::WebServiceWorkerRegistration::Handle* |
155 WebServiceWorkerRegistrationImpl::CreateLeakyHandle( | 156 WebServiceWorkerRegistrationImpl::CreateLeakyHandle( |
156 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) { | 157 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) { |
157 if (!registration) | 158 if (!registration) |
158 return nullptr; | 159 return nullptr; |
159 return new HandleImpl(registration); | 160 return new HandleImpl(registration); |
160 } | 161 } |
161 | 162 |
162 WebServiceWorkerRegistrationImpl::~WebServiceWorkerRegistrationImpl() { | 163 WebServiceWorkerRegistrationImpl::~WebServiceWorkerRegistrationImpl() { |
163 ServiceWorkerDispatcher* dispatcher = | 164 ServiceWorkerDispatcher* dispatcher = |
164 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 165 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
165 if (dispatcher) | 166 if (dispatcher) |
166 dispatcher->RemoveServiceWorkerRegistration(handle_ref_->handle_id()); | 167 dispatcher->RemoveServiceWorkerRegistration(handle_ref_->handle_id()); |
167 } | 168 } |
168 | 169 |
169 } // namespace content | 170 } // namespace content |
OLD | NEW |