Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: content/child/service_worker/web_service_worker_registration_impl.cc

Issue 2443103002: service worker: Implement NavigationPreloadManager.getState (Closed)
Patch Set: rm file added in bad merge Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "content/child/service_worker/service_worker_dispatcher.h" 11 #include "content/child/service_worker/service_worker_dispatcher.h"
12 #include "content/child/service_worker/service_worker_registration_handle_refere nce.h" 12 #include "content/child/service_worker/service_worker_registration_handle_refere nce.h"
13 #include "content/child/service_worker/web_service_worker_impl.h" 13 #include "content/child/service_worker/web_service_worker_impl.h"
14 #include "content/child/service_worker/web_service_worker_provider_impl.h" 14 #include "content/child/service_worker/web_service_worker_provider_impl.h"
15 #include "content/common/service_worker/service_worker_types.h" 15 #include "content/common/service_worker/service_worker_types.h"
16 #include "third_party/WebKit/public/platform/modules/serviceworker/WebNavigation PreloadState.h"
16 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerError.h" 17 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerError.h"
17 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerRegistrationProxy.h" 18 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerRegistrationProxy.h"
18 19
19 namespace content { 20 namespace content {
20 21
21 namespace { 22 namespace {
22 23
23 class HandleImpl : public blink::WebServiceWorkerRegistration::Handle { 24 class HandleImpl : public blink::WebServiceWorkerRegistration::Handle {
24 public: 25 public:
25 explicit HandleImpl( 26 explicit HandleImpl(
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 WebServiceWorkerProviderImpl* provider_impl = 154 WebServiceWorkerProviderImpl* provider_impl =
154 static_cast<WebServiceWorkerProviderImpl*>(provider); 155 static_cast<WebServiceWorkerProviderImpl*>(provider);
155 ServiceWorkerDispatcher* dispatcher = 156 ServiceWorkerDispatcher* dispatcher =
156 ServiceWorkerDispatcher::GetThreadSpecificInstance(); 157 ServiceWorkerDispatcher::GetThreadSpecificInstance();
157 DCHECK(dispatcher); 158 DCHECK(dispatcher);
158 dispatcher->EnableNavigationPreload(provider_impl->provider_id(), 159 dispatcher->EnableNavigationPreload(provider_impl->provider_id(),
159 registration_id(), enable, 160 registration_id(), enable,
160 std::move(callbacks)); 161 std::move(callbacks));
161 } 162 }
162 163
164 void WebServiceWorkerRegistrationImpl::getNavigationPreloadState(
165 blink::WebServiceWorkerProvider* provider,
166 std::unique_ptr<WebGetNavigationPreloadStateCallbacks> callbacks) {
167 WebServiceWorkerProviderImpl* provider_impl =
168 static_cast<WebServiceWorkerProviderImpl*>(provider);
169 ServiceWorkerDispatcher* dispatcher =
170 ServiceWorkerDispatcher::GetThreadSpecificInstance();
171 DCHECK(dispatcher);
172 dispatcher->GetNavigationPreloadState(
173 provider_impl->provider_id(), registration_id(), std::move(callbacks));
174 }
175
163 int64_t WebServiceWorkerRegistrationImpl::registration_id() const { 176 int64_t WebServiceWorkerRegistrationImpl::registration_id() const {
164 return handle_ref_->registration_id(); 177 return handle_ref_->registration_id();
165 } 178 }
166 179
167 // static 180 // static
168 std::unique_ptr<blink::WebServiceWorkerRegistration::Handle> 181 std::unique_ptr<blink::WebServiceWorkerRegistration::Handle>
169 WebServiceWorkerRegistrationImpl::CreateHandle( 182 WebServiceWorkerRegistrationImpl::CreateHandle(
170 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) { 183 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) {
171 if (!registration) 184 if (!registration)
172 return nullptr; 185 return nullptr;
173 return base::MakeUnique<HandleImpl>(registration); 186 return base::MakeUnique<HandleImpl>(registration);
174 } 187 }
175 188
176 blink::WebServiceWorkerRegistration::Handle* 189 blink::WebServiceWorkerRegistration::Handle*
177 WebServiceWorkerRegistrationImpl::CreateLeakyHandle( 190 WebServiceWorkerRegistrationImpl::CreateLeakyHandle(
178 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) { 191 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) {
179 if (!registration) 192 if (!registration)
180 return nullptr; 193 return nullptr;
181 return new HandleImpl(registration); 194 return new HandleImpl(registration);
182 } 195 }
183 196
184 WebServiceWorkerRegistrationImpl::~WebServiceWorkerRegistrationImpl() { 197 WebServiceWorkerRegistrationImpl::~WebServiceWorkerRegistrationImpl() {
185 ServiceWorkerDispatcher* dispatcher = 198 ServiceWorkerDispatcher* dispatcher =
186 ServiceWorkerDispatcher::GetThreadSpecificInstance(); 199 ServiceWorkerDispatcher::GetThreadSpecificInstance();
187 if (dispatcher) 200 if (dispatcher)
188 dispatcher->RemoveServiceWorkerRegistration(handle_ref_->handle_id()); 201 dispatcher->RemoveServiceWorkerRegistration(handle_ref_->handle_id());
189 } 202 }
190 203
191 } // namespace content 204 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698