| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 WebServiceWorkerProviderImpl* provider_impl = | 140 WebServiceWorkerProviderImpl* provider_impl = |
| 141 static_cast<WebServiceWorkerProviderImpl*>(provider); | 141 static_cast<WebServiceWorkerProviderImpl*>(provider); |
| 142 ServiceWorkerDispatcher* dispatcher = | 142 ServiceWorkerDispatcher* dispatcher = |
| 143 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 143 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
| 144 DCHECK(dispatcher); | 144 DCHECK(dispatcher); |
| 145 dispatcher->UnregisterServiceWorker(provider_impl->provider_id(), | 145 dispatcher->UnregisterServiceWorker(provider_impl->provider_id(), |
| 146 registration_id(), callbacks); | 146 registration_id(), callbacks); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void WebServiceWorkerRegistrationImpl::enableNavigationPreload( | 149 void WebServiceWorkerRegistrationImpl::enableNavigationPreload( |
| 150 WebEnableNavigationPreloadCallbacks* callbacks) { | 150 bool enable, |
| 151 std::unique_ptr<WebEnableNavigationPreloadCallbacks> owned_callbacks( | 151 blink::WebServiceWorkerProvider* provider, |
| 152 callbacks); | 152 std::unique_ptr<WebEnableNavigationPreloadCallbacks> callbacks) { |
| 153 // TODO(falken): Implement this. | 153 WebServiceWorkerProviderImpl* provider_impl = |
| 154 owned_callbacks->onError(blink::WebServiceWorkerError( | 154 static_cast<WebServiceWorkerProviderImpl*>(provider); |
| 155 blink::WebServiceWorkerError::ErrorTypeAbort, "Not implemented")); | 155 ServiceWorkerDispatcher* dispatcher = |
| 156 } | 156 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
| 157 | 157 DCHECK(dispatcher); |
| 158 void WebServiceWorkerRegistrationImpl::disableNavigationPreload( | 158 dispatcher->EnableNavigationPreload(provider_impl->provider_id(), |
| 159 WebDisableNavigationPreloadCallbacks* callbacks) { | 159 registration_id(), enable, |
| 160 std::unique_ptr<WebDisableNavigationPreloadCallbacks> owned_callbacks( | 160 std::move(callbacks)); |
| 161 callbacks); | |
| 162 // TODO(falken): Implement this. | |
| 163 owned_callbacks->onError(blink::WebServiceWorkerError( | |
| 164 blink::WebServiceWorkerError::ErrorTypeAbort, "Not implemented")); | |
| 165 } | 161 } |
| 166 | 162 |
| 167 int64_t WebServiceWorkerRegistrationImpl::registration_id() const { | 163 int64_t WebServiceWorkerRegistrationImpl::registration_id() const { |
| 168 return handle_ref_->registration_id(); | 164 return handle_ref_->registration_id(); |
| 169 } | 165 } |
| 170 | 166 |
| 171 // static | 167 // static |
| 172 std::unique_ptr<blink::WebServiceWorkerRegistration::Handle> | 168 std::unique_ptr<blink::WebServiceWorkerRegistration::Handle> |
| 173 WebServiceWorkerRegistrationImpl::CreateHandle( | 169 WebServiceWorkerRegistrationImpl::CreateHandle( |
| 174 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) { | 170 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 186 } | 182 } |
| 187 | 183 |
| 188 WebServiceWorkerRegistrationImpl::~WebServiceWorkerRegistrationImpl() { | 184 WebServiceWorkerRegistrationImpl::~WebServiceWorkerRegistrationImpl() { |
| 189 ServiceWorkerDispatcher* dispatcher = | 185 ServiceWorkerDispatcher* dispatcher = |
| 190 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 186 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
| 191 if (dispatcher) | 187 if (dispatcher) |
| 192 dispatcher->RemoveServiceWorkerRegistration(handle_ref_->handle_id()); | 188 dispatcher->RemoveServiceWorkerRegistration(handle_ref_->handle_id()); |
| 193 } | 189 } |
| 194 | 190 |
| 195 } // namespace content | 191 } // namespace content |
| OLD | NEW |