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 2413063003: service worker: Add promise boilerplate for NavigationPreload enable/disable (Closed)
Patch Set: more boilerplate Created 4 years, 2 months 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/WebServiceWor kerError.h"
16 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerRegistrationProxy.h" 17 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerRegistrationProxy.h"
17 18
18 namespace content { 19 namespace content {
19 20
20 namespace { 21 namespace {
21 22
22 class HandleImpl : public blink::WebServiceWorkerRegistration::Handle { 23 class HandleImpl : public blink::WebServiceWorkerRegistration::Handle {
23 public: 24 public:
24 explicit HandleImpl( 25 explicit HandleImpl(
25 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) 26 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration)
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 WebServiceWorkerUnregistrationCallbacks* callbacks) { 139 WebServiceWorkerUnregistrationCallbacks* callbacks) {
139 WebServiceWorkerProviderImpl* provider_impl = 140 WebServiceWorkerProviderImpl* provider_impl =
140 static_cast<WebServiceWorkerProviderImpl*>(provider); 141 static_cast<WebServiceWorkerProviderImpl*>(provider);
141 ServiceWorkerDispatcher* dispatcher = 142 ServiceWorkerDispatcher* dispatcher =
142 ServiceWorkerDispatcher::GetThreadSpecificInstance(); 143 ServiceWorkerDispatcher::GetThreadSpecificInstance();
143 DCHECK(dispatcher); 144 DCHECK(dispatcher);
144 dispatcher->UnregisterServiceWorker(provider_impl->provider_id(), 145 dispatcher->UnregisterServiceWorker(provider_impl->provider_id(),
145 registration_id(), callbacks); 146 registration_id(), callbacks);
146 } 147 }
147 148
149 void WebServiceWorkerRegistrationImpl::enableNavigationPreload(
150 WebEnableNavigationPreloadCallbacks* callbacks) {
151 std::unique_ptr<WebEnableNavigationPreloadCallbacks> owned_callbacks(
152 callbacks);
153 // TODO(falken): Implement this.
154 owned_callbacks->onError(blink::WebServiceWorkerError(
155 blink::WebServiceWorkerError::ErrorTypeAbort, "Not implemented"));
156 }
157
158 void WebServiceWorkerRegistrationImpl::disableNavigationPreload(
159 WebDisableNavigationPreloadCallbacks* callbacks) {
160 std::unique_ptr<WebDisableNavigationPreloadCallbacks> owned_callbacks(
161 callbacks);
162 // TODO(falken): Implement this.
163 owned_callbacks->onError(blink::WebServiceWorkerError(
164 blink::WebServiceWorkerError::ErrorTypeAbort, "Not implemented"));
165 }
166
148 int64_t WebServiceWorkerRegistrationImpl::registration_id() const { 167 int64_t WebServiceWorkerRegistrationImpl::registration_id() const {
149 return handle_ref_->registration_id(); 168 return handle_ref_->registration_id();
150 } 169 }
151 170
152 // static 171 // static
153 std::unique_ptr<blink::WebServiceWorkerRegistration::Handle> 172 std::unique_ptr<blink::WebServiceWorkerRegistration::Handle>
154 WebServiceWorkerRegistrationImpl::CreateHandle( 173 WebServiceWorkerRegistrationImpl::CreateHandle(
155 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) { 174 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) {
156 if (!registration) 175 if (!registration)
157 return nullptr; 176 return nullptr;
158 return base::MakeUnique<HandleImpl>(registration); 177 return base::MakeUnique<HandleImpl>(registration);
159 } 178 }
160 179
161 blink::WebServiceWorkerRegistration::Handle* 180 blink::WebServiceWorkerRegistration::Handle*
162 WebServiceWorkerRegistrationImpl::CreateLeakyHandle( 181 WebServiceWorkerRegistrationImpl::CreateLeakyHandle(
163 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) { 182 const scoped_refptr<WebServiceWorkerRegistrationImpl>& registration) {
164 if (!registration) 183 if (!registration)
165 return nullptr; 184 return nullptr;
166 return new HandleImpl(registration); 185 return new HandleImpl(registration);
167 } 186 }
168 187
169 WebServiceWorkerRegistrationImpl::~WebServiceWorkerRegistrationImpl() { 188 WebServiceWorkerRegistrationImpl::~WebServiceWorkerRegistrationImpl() {
170 ServiceWorkerDispatcher* dispatcher = 189 ServiceWorkerDispatcher* dispatcher =
171 ServiceWorkerDispatcher::GetThreadSpecificInstance(); 190 ServiceWorkerDispatcher::GetThreadSpecificInstance();
172 if (dispatcher) 191 if (dispatcher)
173 dispatcher->RemoveServiceWorkerRegistration(handle_ref_->handle_id()); 192 dispatcher->RemoveServiceWorkerRegistration(handle_ref_->handle_id());
174 } 193 }
175 194
176 } // namespace content 195 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698