| 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/audio_output_devices/SetSinkIdCallbacks.h" | 5 #include "modules/audio_output_devices/SetSinkIdCallbacks.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/audio_output_devices/HTMLMediaElementAudioOutputDevice.h" | 9 #include "modules/audio_output_devices/HTMLMediaElementAudioOutputDevice.h" |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 HTMLMediaElement& element, | 36 HTMLMediaElement& element, |
| 37 const String& sinkId) | 37 const String& sinkId) |
| 38 : m_resolver(resolver), m_element(element), m_sinkId(sinkId) { | 38 : m_resolver(resolver), m_element(element), m_sinkId(sinkId) { |
| 39 ASSERT(m_resolver); | 39 ASSERT(m_resolver); |
| 40 } | 40 } |
| 41 | 41 |
| 42 SetSinkIdCallbacks::~SetSinkIdCallbacks() {} | 42 SetSinkIdCallbacks::~SetSinkIdCallbacks() {} |
| 43 | 43 |
| 44 void SetSinkIdCallbacks::onSuccess() { | 44 void SetSinkIdCallbacks::onSuccess() { |
| 45 if (!m_resolver->getExecutionContext() || | 45 if (!m_resolver->getExecutionContext() || |
| 46 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) | 46 m_resolver->getExecutionContext()->isContextDestroyed()) |
| 47 return; | 47 return; |
| 48 | 48 |
| 49 HTMLMediaElementAudioOutputDevice& aodElement = | 49 HTMLMediaElementAudioOutputDevice& aodElement = |
| 50 HTMLMediaElementAudioOutputDevice::from(*m_element); | 50 HTMLMediaElementAudioOutputDevice::from(*m_element); |
| 51 aodElement.setSinkId(m_sinkId); | 51 aodElement.setSinkId(m_sinkId); |
| 52 m_resolver->resolve(); | 52 m_resolver->resolve(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void SetSinkIdCallbacks::onError(WebSetSinkIdError error) { | 55 void SetSinkIdCallbacks::onError(WebSetSinkIdError error) { |
| 56 if (!m_resolver->getExecutionContext() || | 56 if (!m_resolver->getExecutionContext() || |
| 57 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) | 57 m_resolver->getExecutionContext()->isContextDestroyed()) |
| 58 return; | 58 return; |
| 59 | 59 |
| 60 m_resolver->reject(ToException(error)); | 60 m_resolver->reject(ToException(error)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 } // namespace blink | 63 } // namespace blink |
| OLD | NEW |