| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ServiceWorkerWindowClientCallback.h" | 5 #include "modules/serviceworkers/ServiceWorkerWindowClientCallback.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 #include "modules/serviceworkers/ServiceWorkerWindowClient.h" | 10 #include "modules/serviceworkers/ServiceWorkerWindowClient.h" |
| 11 #include "wtf/PtrUtil.h" | 11 #include "wtf/PtrUtil.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 void NavigateClientCallback::onSuccess( | 15 void NavigateClientCallback::onSuccess( |
| 16 std::unique_ptr<WebServiceWorkerClientInfo> clientInfo) { | 16 std::unique_ptr<WebServiceWorkerClientInfo> clientInfo) { |
| 17 if (!m_resolver->getExecutionContext() || | 17 if (!m_resolver->getExecutionContext() || |
| 18 m_resolver->getExecutionContext()->isContextDestroyed()) | 18 m_resolver->getExecutionContext()->isContextDestroyed()) |
| 19 return; | 19 return; |
| 20 m_resolver->resolve(ServiceWorkerWindowClient::take( | 20 m_resolver->resolve(ServiceWorkerWindowClient::take( |
| 21 m_resolver.get(), wrapUnique(clientInfo.release()))); | 21 m_resolver.get(), WTF::wrapUnique(clientInfo.release()))); |
| 22 } | 22 } |
| 23 | 23 |
| 24 void NavigateClientCallback::onError(const WebServiceWorkerError& error) { | 24 void NavigateClientCallback::onError(const WebServiceWorkerError& error) { |
| 25 if (!m_resolver->getExecutionContext() || | 25 if (!m_resolver->getExecutionContext() || |
| 26 m_resolver->getExecutionContext()->isContextDestroyed()) | 26 m_resolver->getExecutionContext()->isContextDestroyed()) |
| 27 return; | 27 return; |
| 28 | 28 |
| 29 if (error.errorType == WebServiceWorkerError::ErrorTypeNavigation) { | 29 if (error.errorType == WebServiceWorkerError::ErrorTypeNavigation) { |
| 30 ScriptState::Scope scope(m_resolver->getScriptState()); | 30 ScriptState::Scope scope(m_resolver->getScriptState()); |
| 31 m_resolver->reject(V8ThrowException::createTypeError( | 31 m_resolver->reject(V8ThrowException::createTypeError( |
| 32 m_resolver->getScriptState()->isolate(), error.message)); | 32 m_resolver->getScriptState()->isolate(), error.message)); |
| 33 return; | 33 return; |
| 34 } | 34 } |
| 35 | 35 |
| 36 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error)); | 36 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error)); |
| 37 } | 37 } |
| 38 | 38 |
| 39 } // namespace blink | 39 } // namespace blink |
| OLD | NEW |