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 "config.h" | 5 #include "config.h" |
6 #include "modules/presentation/PresentationAvailabilityCallback.h" | 6 #include "modules/presentation/PresentationAvailabilityCallback.h" |
7 | 7 |
8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
9 #include "core/dom/DOMException.h" | 9 #include "core/dom/DOMException.h" |
10 #include "modules/presentation/PresentationAvailability.h" | 10 #include "modules/presentation/PresentationAvailability.h" |
11 #include "modules/presentation/PresentationError.h" | 11 #include "modules/presentation/PresentationError.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 PresentationAvailabilityCallback::PresentationAvailabilityCallback(PassRefPtrWil
lBeRawPtr<ScriptPromiseResolver> resolver) | 15 PresentationAvailabilityCallback::PresentationAvailabilityCallback(ScriptPromise
Resolver* resolver) |
16 : m_resolver(resolver) | 16 : m_resolver(resolver) |
17 { | 17 { |
18 ASSERT(m_resolver); | 18 ASSERT(m_resolver); |
19 } | 19 } |
20 | 20 |
21 void PresentationAvailabilityCallback::onSuccess(bool* result) | 21 void PresentationAvailabilityCallback::onSuccess(bool* result) |
22 { | 22 { |
23 OwnPtr<bool> availability = adoptPtr(result); | 23 OwnPtr<bool> availability = adoptPtr(result); |
24 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ
eDOMObjectsAreStopped()) | 24 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ
eDOMObjectsAreStopped()) |
25 return; | 25 return; |
26 m_resolver->resolve(PresentationAvailability::take(m_resolver.get(), *availa
bility)); | 26 m_resolver->resolve(PresentationAvailability::take(m_resolver.get(), *availa
bility)); |
27 } | 27 } |
28 | 28 |
29 void PresentationAvailabilityCallback::onError(WebPresentationError* result) | 29 void PresentationAvailabilityCallback::onError(WebPresentationError* result) |
30 { | 30 { |
31 OwnPtr<WebPresentationError> error = adoptPtr(result); | 31 OwnPtr<WebPresentationError> error = adoptPtr(result); |
32 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ
eDOMObjectsAreStopped()) | 32 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ
eDOMObjectsAreStopped()) |
33 return; | 33 return; |
34 m_resolver->reject(PresentationError::take(*error)); | 34 m_resolver->reject(PresentationError::take(*error)); |
35 } | 35 } |
36 | 36 |
37 } // namespace blink | 37 } // namespace blink |
OLD | NEW |