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 "public/platform/modules/presentation/WebPresentationError.h" | 11 #include "public/platform/modules/presentation/WebPresentationError.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 PresentationAvailabilityCallbacks::PresentationAvailabilityCallbacks( | 15 PresentationAvailabilityCallbacks::PresentationAvailabilityCallbacks( |
16 ScriptPromiseResolver* resolver, | 16 PresentationAvailabilityProperty* resolver, |
17 const KURL& url) | 17 const KURL& url) |
18 : m_resolver(resolver), m_url(url) { | 18 : m_resolver(resolver), m_url(url) { |
19 ASSERT(m_resolver); | 19 ASSERT(m_resolver); |
20 } | 20 } |
21 | 21 |
22 PresentationAvailabilityCallbacks::~PresentationAvailabilityCallbacks() {} | 22 PresentationAvailabilityCallbacks::~PresentationAvailabilityCallbacks() {} |
23 | 23 |
24 void PresentationAvailabilityCallbacks::onSuccess(bool value) { | 24 void PresentationAvailabilityCallbacks::onSuccess(bool value) { |
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 m_resolver->resolve( | 28 m_resolver->resolve( |
29 PresentationAvailability::take(m_resolver.get(), m_url, value)); | 29 PresentationAvailability::take(m_resolver.get(), m_url, value)); |
30 } | 30 } |
31 | 31 |
32 void PresentationAvailabilityCallbacks::onError( | 32 void PresentationAvailabilityCallbacks::onError( |
33 const WebPresentationError& error) { | 33 const WebPresentationError& error) { |
34 if (!m_resolver->getExecutionContext() || | 34 if (!m_resolver->getExecutionContext() || |
35 m_resolver->getExecutionContext()->isContextDestroyed()) | 35 m_resolver->getExecutionContext()->isContextDestroyed()) |
36 return; | 36 return; |
37 m_resolver->reject(PresentationError::take(m_resolver.get(), error)); | 37 m_resolver->reject(PresentationError::take(error)); |
38 } | 38 } |
39 | 39 |
40 } // namespace blink | 40 } // namespace blink |
OLD | NEW |