| OLD | NEW |
| 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/ServiceWorkerError.h" | 9 #include "modules/serviceworkers/ServiceWorkerError.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 EnableNavigationPreloadCallbacks::EnableNavigationPreloadCallbacks( | 13 EnableNavigationPreloadCallbacks::EnableNavigationPreloadCallbacks( |
| 14 ScriptPromiseResolver* resolver) | 14 ScriptPromiseResolver* resolver) |
| 15 : m_resolver(resolver) { | 15 : m_resolver(resolver) { |
| 16 DCHECK(m_resolver); | 16 DCHECK(m_resolver); |
| 17 } | 17 } |
| 18 | 18 |
| 19 EnableNavigationPreloadCallbacks::~EnableNavigationPreloadCallbacks() {} | 19 EnableNavigationPreloadCallbacks::~EnableNavigationPreloadCallbacks() {} |
| 20 | 20 |
| 21 void EnableNavigationPreloadCallbacks::onSuccess() { | 21 void EnableNavigationPreloadCallbacks::onSuccess() { |
| 22 if (!m_resolver->getExecutionContext() || | 22 if (!m_resolver->getExecutionContext()) |
| 23 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) | |
| 24 return; | 23 return; |
| 25 m_resolver->resolve(); | 24 m_resolver->resolve(); |
| 26 } | 25 } |
| 27 | 26 |
| 28 void EnableNavigationPreloadCallbacks::onError( | 27 void EnableNavigationPreloadCallbacks::onError( |
| 29 const WebServiceWorkerError& error) { | 28 const WebServiceWorkerError& error) { |
| 30 if (!m_resolver->getExecutionContext() || | 29 if (!m_resolver->getExecutionContext()) |
| 31 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) | |
| 32 return; | 30 return; |
| 33 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error)); | 31 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error)); |
| 34 } | 32 } |
| 35 | 33 |
| 36 DisableNavigationPreloadCallbacks::DisableNavigationPreloadCallbacks( | 34 DisableNavigationPreloadCallbacks::DisableNavigationPreloadCallbacks( |
| 37 ScriptPromiseResolver* resolver) | 35 ScriptPromiseResolver* resolver) |
| 38 : m_resolver(resolver) { | 36 : m_resolver(resolver) { |
| 39 DCHECK(m_resolver); | 37 DCHECK(m_resolver); |
| 40 } | 38 } |
| 41 | 39 |
| 42 DisableNavigationPreloadCallbacks::~DisableNavigationPreloadCallbacks() {} | 40 DisableNavigationPreloadCallbacks::~DisableNavigationPreloadCallbacks() {} |
| 43 | 41 |
| 44 void DisableNavigationPreloadCallbacks::onSuccess() { | 42 void DisableNavigationPreloadCallbacks::onSuccess() { |
| 45 if (!m_resolver->getExecutionContext() || | 43 if (!m_resolver->getExecutionContext()) |
| 46 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) | |
| 47 return; | 44 return; |
| 48 m_resolver->resolve(); | 45 m_resolver->resolve(); |
| 49 } | 46 } |
| 50 | 47 |
| 51 void DisableNavigationPreloadCallbacks::onError( | 48 void DisableNavigationPreloadCallbacks::onError( |
| 52 const WebServiceWorkerError& error) { | 49 const WebServiceWorkerError& error) { |
| 53 if (!m_resolver->getExecutionContext() || | 50 if (!m_resolver->getExecutionContext()) |
| 54 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) | |
| 55 return; | 51 return; |
| 56 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error)); | 52 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error)); |
| 57 } | 53 } |
| 58 | 54 |
| 59 } // namespace blink | 55 } // namespace blink |
| OLD | NEW |