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

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

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 2016 The Chromium Authors. All rights reserved. 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 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 "modules/serviceworkers/NavigationPreloadCallbacks.h" 5 #include "modules/serviceworkers/NavigationPreloadCallbacks.h"
6 6
7 #include "bindings/core/v8/ScriptPromiseResolver.h" 7 #include "bindings/core/v8/ScriptPromiseResolver.h"
8 #include "core/dom/DOMException.h" 8 #include "core/dom/DOMException.h"
9 #include "modules/serviceworkers/NavigationPreloadState.h"
9 #include "modules/serviceworkers/ServiceWorkerError.h" 10 #include "modules/serviceworkers/ServiceWorkerError.h"
11 #include "public/platform/modules/serviceworker/WebNavigationPreloadState.h"
10 12
11 namespace blink { 13 namespace blink {
12 14
13 EnableNavigationPreloadCallbacks::EnableNavigationPreloadCallbacks( 15 EnableNavigationPreloadCallbacks::EnableNavigationPreloadCallbacks(
14 ScriptPromiseResolver* resolver) 16 ScriptPromiseResolver* resolver)
15 : m_resolver(resolver) { 17 : m_resolver(resolver) {
16 DCHECK(m_resolver); 18 DCHECK(m_resolver);
17 } 19 }
18 20
19 EnableNavigationPreloadCallbacks::~EnableNavigationPreloadCallbacks() {} 21 EnableNavigationPreloadCallbacks::~EnableNavigationPreloadCallbacks() {}
20 22
21 void EnableNavigationPreloadCallbacks::onSuccess() { 23 void EnableNavigationPreloadCallbacks::onSuccess() {
22 if (!m_resolver->getExecutionContext() || 24 if (!m_resolver->getExecutionContext() ||
23 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) 25 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped())
24 return; 26 return;
25 m_resolver->resolve(); 27 m_resolver->resolve();
26 } 28 }
27 29
28 void EnableNavigationPreloadCallbacks::onError( 30 void EnableNavigationPreloadCallbacks::onError(
29 const WebServiceWorkerError& error) { 31 const WebServiceWorkerError& error) {
30 if (!m_resolver->getExecutionContext() || 32 if (!m_resolver->getExecutionContext() ||
31 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) 33 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped())
32 return; 34 return;
33 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error)); 35 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error));
34 } 36 }
35 37
38 GetNavigationPreloadStateCallbacks::GetNavigationPreloadStateCallbacks(
39 ScriptPromiseResolver* resolver)
40 : m_resolver(resolver) {
41 DCHECK(m_resolver);
42 }
43
44 GetNavigationPreloadStateCallbacks::~GetNavigationPreloadStateCallbacks() {}
45
46 void GetNavigationPreloadStateCallbacks::onSuccess(
47 const WebNavigationPreloadState& state) {
48 if (!m_resolver->getExecutionContext() ||
49 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped())
50 return;
51 NavigationPreloadState dict;
52 dict.setEnabled(state.enabled);
53 if (!state.headerValue.isNull())
54 dict.setHeaderValue(state.headerValue);
55 m_resolver->resolve(dict);
56 }
57
58 void GetNavigationPreloadStateCallbacks::onError(
59 const WebServiceWorkerError& error) {
60 if (!m_resolver->getExecutionContext() ||
61 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped())
62 return;
63 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error));
64 }
65
36 } // namespace blink 66 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698