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

Side by Side Diff: third_party/WebKit/Source/modules/serviceworkers/NavigationPreloadCallbacks.cpp

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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "modules/serviceworkers/NavigationPreloadCallbacks.h"
6
7 #include "bindings/core/v8/ScriptPromiseResolver.h"
8 #include "core/dom/DOMException.h"
9 #include "modules/serviceworkers/ServiceWorkerError.h"
10
11 namespace blink {
12
13 EnableNavigationPreloadCallbacks::EnableNavigationPreloadCallbacks(
14 ScriptPromiseResolver* resolver)
15 : m_resolver(resolver) {
16 DCHECK(m_resolver);
17 }
18
19 EnableNavigationPreloadCallbacks::~EnableNavigationPreloadCallbacks() {}
20
21 void EnableNavigationPreloadCallbacks::onSuccess() {
22 if (!m_resolver->getExecutionContext() ||
23 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped())
24 return;
25 m_resolver->resolve();
26 }
27
28 void EnableNavigationPreloadCallbacks::onError(
29 const WebServiceWorkerError& error) {
30 if (!m_resolver->getExecutionContext() ||
31 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped())
32 return;
33 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error));
34 }
35
36 DisableNavigationPreloadCallbacks::DisableNavigationPreloadCallbacks(
37 ScriptPromiseResolver* resolver)
38 : m_resolver(resolver) {
39 DCHECK(m_resolver);
40 }
41
42 DisableNavigationPreloadCallbacks::~DisableNavigationPreloadCallbacks() {}
43
44 void DisableNavigationPreloadCallbacks::onSuccess() {
45 if (!m_resolver->getExecutionContext() ||
46 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped())
47 return;
48 m_resolver->resolve();
49 }
50
51 void DisableNavigationPreloadCallbacks::onError(
52 const WebServiceWorkerError& error) {
53 if (!m_resolver->getExecutionContext() ||
54 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped())
55 return;
56 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error));
57 }
58
59 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698