| 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 "bindings/core/v8/V8ThrowException.h" | |
| 9 #include "core/dom/DOMException.h" | 8 #include "core/dom/DOMException.h" |
| 10 #include "modules/serviceworkers/ServiceWorkerError.h" | 9 #include "modules/serviceworkers/ServiceWorkerError.h" |
| 11 #include "modules/serviceworkers/ServiceWorkerWindowClient.h" | 10 #include "modules/serviceworkers/ServiceWorkerWindowClient.h" |
| 11 #include "platform/bindings/V8ThrowException.h" |
| 12 #include "platform/wtf/PtrUtil.h" | 12 #include "platform/wtf/PtrUtil.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 void NavigateClientCallback::OnSuccess( | 16 void NavigateClientCallback::OnSuccess( |
| 17 std::unique_ptr<WebServiceWorkerClientInfo> client_info) { | 17 std::unique_ptr<WebServiceWorkerClientInfo> client_info) { |
| 18 if (!resolver_->GetExecutionContext() || | 18 if (!resolver_->GetExecutionContext() || |
| 19 resolver_->GetExecutionContext()->IsContextDestroyed()) | 19 resolver_->GetExecutionContext()->IsContextDestroyed()) |
| 20 return; | 20 return; |
| 21 resolver_->Resolve(ServiceWorkerWindowClient::Take( | 21 resolver_->Resolve(ServiceWorkerWindowClient::Take( |
| 22 resolver_.Get(), WTF::WrapUnique(client_info.release()))); | 22 resolver_.Get(), WTF::WrapUnique(client_info.release()))); |
| 23 } | 23 } |
| 24 | 24 |
| 25 void NavigateClientCallback::OnError(const WebServiceWorkerError& error) { | 25 void NavigateClientCallback::OnError(const WebServiceWorkerError& error) { |
| 26 if (!resolver_->GetExecutionContext() || | 26 if (!resolver_->GetExecutionContext() || |
| 27 resolver_->GetExecutionContext()->IsContextDestroyed()) | 27 resolver_->GetExecutionContext()->IsContextDestroyed()) |
| 28 return; | 28 return; |
| 29 | 29 |
| 30 if (error.error_type == WebServiceWorkerError::kErrorTypeNavigation) { | 30 if (error.error_type == WebServiceWorkerError::kErrorTypeNavigation) { |
| 31 ScriptState::Scope scope(resolver_->GetScriptState()); | 31 ScriptState::Scope scope(resolver_->GetScriptState()); |
| 32 resolver_->Reject(V8ThrowException::CreateTypeError( | 32 resolver_->Reject(V8ThrowException::CreateTypeError( |
| 33 resolver_->GetScriptState()->GetIsolate(), error.message)); | 33 resolver_->GetScriptState()->GetIsolate(), error.message)); |
| 34 return; | 34 return; |
| 35 } | 35 } |
| 36 | 36 |
| 37 resolver_->Reject(ServiceWorkerError::Take(resolver_.Get(), error)); | 37 resolver_->Reject(ServiceWorkerError::Take(resolver_.Get(), error)); |
| 38 } | 38 } |
| 39 | 39 |
| 40 } // namespace blink | 40 } // namespace blink |
| OLD | NEW |