| 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/presentation/PresentationAvailabilityCallbacks.h" | 5 #include "modules/presentation/PresentationAvailabilityCallbacks.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/presentation/PresentationAvailability.h" | 9 #include "modules/presentation/PresentationAvailability.h" |
| 10 #include "modules/presentation/PresentationError.h" | 10 #include "modules/presentation/PresentationError.h" |
| 11 #include "modules/presentation/PresentationRequest.h" | 11 #include "modules/presentation/PresentationRequest.h" |
| 12 #include "public/platform/modules/presentation/WebPresentationError.h" | 12 #include "public/platform/modules/presentation/WebPresentationError.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 PresentationAvailabilityCallbacks::PresentationAvailabilityCallbacks( | 16 PresentationAvailabilityCallbacks::PresentationAvailabilityCallbacks( |
| 17 PresentationAvailabilityProperty* resolver, | 17 PresentationAvailabilityProperty* resolver, |
| 18 const Vector<KURL>& urls) | 18 const Vector<KURL>& urls) |
| 19 : resolver_(resolver), urls_(urls) { | 19 : resolver_(resolver), urls_(urls) { |
| 20 ASSERT(resolver_); | 20 DCHECK(resolver_); |
| 21 } | 21 } |
| 22 | 22 |
| 23 PresentationAvailabilityCallbacks::~PresentationAvailabilityCallbacks() {} | 23 PresentationAvailabilityCallbacks::~PresentationAvailabilityCallbacks() {} |
| 24 | 24 |
| 25 void PresentationAvailabilityCallbacks::OnSuccess(bool value) { | 25 void PresentationAvailabilityCallbacks::OnSuccess(bool value) { |
| 26 if (!resolver_->GetExecutionContext() || | 26 if (!resolver_->GetExecutionContext() || |
| 27 resolver_->GetExecutionContext()->IsContextDestroyed()) | 27 resolver_->GetExecutionContext()->IsContextDestroyed()) |
| 28 return; | 28 return; |
| 29 resolver_->Resolve( | 29 resolver_->Resolve( |
| 30 PresentationAvailability::Take(resolver_.Get(), urls_, value)); | 30 PresentationAvailability::Take(resolver_.Get(), urls_, value)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void PresentationAvailabilityCallbacks::OnError( | 33 void PresentationAvailabilityCallbacks::OnError( |
| 34 const WebPresentationError& error) { | 34 const WebPresentationError& error) { |
| 35 if (!resolver_->GetExecutionContext() || | 35 if (!resolver_->GetExecutionContext() || |
| 36 resolver_->GetExecutionContext()->IsContextDestroyed()) | 36 resolver_->GetExecutionContext()->IsContextDestroyed()) |
| 37 return; | 37 return; |
| 38 resolver_->Reject(PresentationError::Take(error)); | 38 resolver_->Reject(PresentationError::Take(error)); |
| 39 } | 39 } |
| 40 | 40 |
| 41 } // namespace blink | 41 } // namespace blink |
| OLD | NEW |