| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 WebServiceWorkerUnregistrationCallbacks* callbacks) { | 138 WebServiceWorkerUnregistrationCallbacks* callbacks) { |
| 139 WebServiceWorkerProviderImpl* provider_impl = | 139 WebServiceWorkerProviderImpl* provider_impl = |
| 140 static_cast<WebServiceWorkerProviderImpl*>(provider); | 140 static_cast<WebServiceWorkerProviderImpl*>(provider); |
| 141 ServiceWorkerDispatcher* dispatcher = | 141 ServiceWorkerDispatcher* dispatcher = |
| 142 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 142 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
| 143 DCHECK(dispatcher); | 143 DCHECK(dispatcher); |
| 144 dispatcher->UnregisterServiceWorker(provider_impl->provider_id(), | 144 dispatcher->UnregisterServiceWorker(provider_impl->provider_id(), |
| 145 registration_id(), callbacks); | 145 registration_id(), callbacks); |
| 146 } | 146 } |
| 147 | 147 |
| 148 int64_t WebServiceWorkerRegistrationImpl::registrationId() { |
| 149 return registration_id(); |
| 150 } |
| 151 |
| 148 int64_t WebServiceWorkerRegistrationImpl::registration_id() const { | 152 int64_t WebServiceWorkerRegistrationImpl::registration_id() const { |
| 149 return handle_ref_->registration_id(); | 153 return handle_ref_->registration_id(); |
| 150 } | 154 } |
| 151 | 155 |
| 152 // static | 156 // static |
| 153 std::unique_ptr<blink::WebServiceWorkerRegistration::Handle> | 157 std::unique_ptr<blink::WebServiceWorkerRegistration::Handle> |
| 154 WebServiceWorkerRegistrationImpl::CreateHandle( | 158 WebServiceWorkerRegistrationImpl::CreateHandle( |
| 155 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) { | 159 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) { |
| 156 if (!registration) | 160 if (!registration) |
| 157 return nullptr; | 161 return nullptr; |
| 158 return base::WrapUnique(new HandleImpl(registration)); | 162 return base::WrapUnique(new HandleImpl(registration)); |
| 159 } | 163 } |
| 160 | 164 |
| 161 blink::WebServiceWorkerRegistration::Handle* | 165 blink::WebServiceWorkerRegistration::Handle* |
| 162 WebServiceWorkerRegistrationImpl::CreateLeakyHandle( | 166 WebServiceWorkerRegistrationImpl::CreateLeakyHandle( |
| 163 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) { | 167 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) { |
| 164 if (!registration) | 168 if (!registration) |
| 165 return nullptr; | 169 return nullptr; |
| 166 return new HandleImpl(registration); | 170 return new HandleImpl(registration); |
| 167 } | 171 } |
| 168 | 172 |
| 169 WebServiceWorkerRegistrationImpl::~WebServiceWorkerRegistrationImpl() { | 173 WebServiceWorkerRegistrationImpl::~WebServiceWorkerRegistrationImpl() { |
| 170 ServiceWorkerDispatcher* dispatcher = | 174 ServiceWorkerDispatcher* dispatcher = |
| 171 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 175 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
| 172 if (dispatcher) | 176 if (dispatcher) |
| 173 dispatcher->RemoveServiceWorkerRegistration(handle_ref_->handle_id()); | 177 dispatcher->RemoveServiceWorkerRegistration(handle_ref_->handle_id()); |
| 174 } | 178 } |
| 175 | 179 |
| 176 } // namespace content | 180 } // namespace content |
| OLD | NEW |