| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 std::unique_ptr<WebGetNavigationPreloadStateCallbacks> callbacks) { | 166 std::unique_ptr<WebGetNavigationPreloadStateCallbacks> callbacks) { |
| 167 WebServiceWorkerProviderImpl* provider_impl = | 167 WebServiceWorkerProviderImpl* provider_impl = |
| 168 static_cast<WebServiceWorkerProviderImpl*>(provider); | 168 static_cast<WebServiceWorkerProviderImpl*>(provider); |
| 169 ServiceWorkerDispatcher* dispatcher = | 169 ServiceWorkerDispatcher* dispatcher = |
| 170 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 170 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
| 171 DCHECK(dispatcher); | 171 DCHECK(dispatcher); |
| 172 dispatcher->GetNavigationPreloadState( | 172 dispatcher->GetNavigationPreloadState( |
| 173 provider_impl->provider_id(), registration_id(), std::move(callbacks)); | 173 provider_impl->provider_id(), registration_id(), std::move(callbacks)); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void WebServiceWorkerRegistrationImpl::setNavigationPreloadHeader( |
| 177 const blink::WebString& value, |
| 178 blink::WebServiceWorkerProvider* provider, |
| 179 std::unique_ptr<WebSetNavigationPreloadHeaderCallbacks> callbacks) { |
| 180 WebServiceWorkerProviderImpl* provider_impl = |
| 181 static_cast<WebServiceWorkerProviderImpl*>(provider); |
| 182 ServiceWorkerDispatcher* dispatcher = |
| 183 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
| 184 DCHECK(dispatcher); |
| 185 dispatcher->SetNavigationPreloadHeader(provider_impl->provider_id(), |
| 186 registration_id(), value.utf8(), |
| 187 std::move(callbacks)); |
| 188 } |
| 189 |
| 176 int64_t WebServiceWorkerRegistrationImpl::registration_id() const { | 190 int64_t WebServiceWorkerRegistrationImpl::registration_id() const { |
| 177 return handle_ref_->registration_id(); | 191 return handle_ref_->registration_id(); |
| 178 } | 192 } |
| 179 | 193 |
| 180 // static | 194 // static |
| 181 std::unique_ptr<blink::WebServiceWorkerRegistration::Handle> | 195 std::unique_ptr<blink::WebServiceWorkerRegistration::Handle> |
| 182 WebServiceWorkerRegistrationImpl::CreateHandle( | 196 WebServiceWorkerRegistrationImpl::CreateHandle( |
| 183 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) { | 197 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) { |
| 184 if (!registration) | 198 if (!registration) |
| 185 return nullptr; | 199 return nullptr; |
| 186 return base::MakeUnique<HandleImpl>(registration); | 200 return base::MakeUnique<HandleImpl>(registration); |
| 187 } | 201 } |
| 188 | 202 |
| 189 blink::WebServiceWorkerRegistration::Handle* | 203 blink::WebServiceWorkerRegistration::Handle* |
| 190 WebServiceWorkerRegistrationImpl::CreateLeakyHandle( | 204 WebServiceWorkerRegistrationImpl::CreateLeakyHandle( |
| 191 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) { | 205 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) { |
| 192 if (!registration) | 206 if (!registration) |
| 193 return nullptr; | 207 return nullptr; |
| 194 return new HandleImpl(registration); | 208 return new HandleImpl(registration); |
| 195 } | 209 } |
| 196 | 210 |
| 197 WebServiceWorkerRegistrationImpl::~WebServiceWorkerRegistrationImpl() { | 211 WebServiceWorkerRegistrationImpl::~WebServiceWorkerRegistrationImpl() { |
| 198 ServiceWorkerDispatcher* dispatcher = | 212 ServiceWorkerDispatcher* dispatcher = |
| 199 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 213 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
| 200 if (dispatcher) | 214 if (dispatcher) |
| 201 dispatcher->RemoveServiceWorkerRegistration(handle_ref_->handle_id()); | 215 dispatcher->RemoveServiceWorkerRegistration(handle_ref_->handle_id()); |
| 202 } | 216 } |
| 203 | 217 |
| 204 } // namespace content | 218 } // namespace content |
| OLD | NEW |