Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 #include "modules/audio_output_devices/SetSinkIdCallbacks.h" | |
| 7 | |
| 8 #include "bindings/core/v8/ScriptPromiseResolver.h" | |
| 9 #include "modules/audio_output_devices/HTMLMediaElementAudioOutputDevice.h" | |
| 10 #include "platform/Logging.h" | |
| 11 #include "public/platform/WebSetSinkIdError.h" | |
| 12 | |
| 13 namespace blink { | |
| 14 | |
| 15 SetSinkIdCallbacks::SetSinkIdCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResol ver> resolver, HTMLMediaElement& element, const String& sinkId) | |
| 16 : m_resolver(resolver) | |
| 17 , m_element(element) | |
| 18 , m_sinkId(sinkId) | |
| 19 { | |
| 20 ASSERT(m_resolver); | |
| 21 WTF_LOG(Media, __FUNCTION__); | |
| 22 } | |
| 23 | |
| 24 SetSinkIdCallbacks::~SetSinkIdCallbacks() | |
| 25 { | |
| 26 WTF_LOG(Media, __FUNCTION__); | |
| 27 } | |
| 28 | |
| 29 void SetSinkIdCallbacks::onSuccess() | |
| 30 { | |
| 31 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ eDOMObjectsAreStopped()) | |
| 32 return; | |
| 33 | |
| 34 HTMLMediaElementAudioOutputDevice& aodElement = HTMLMediaElementAudioOutputD evice::from(*m_element); | |
| 35 aodElement.setSinkId(m_sinkId); | |
| 36 m_resolver->resolve(); | |
| 37 } | |
| 38 | |
| 39 void SetSinkIdCallbacks::onError(WebSetSinkIdError* rawError) | |
| 40 { | |
| 41 ASSERT(rawError); | |
| 42 OwnPtr<WebSetSinkIdError> error = adoptPtr(rawError); | |
| 43 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ eDOMObjectsAreStopped()) { | |
|
Mike West
2015/06/18 06:30:49
Nit: No {} for one-line clauses.
| |
| 44 return; | |
| 45 } | |
| 46 | |
| 47 switch (error->errorType) { | |
| 48 case WebSetSinkIdError::ErrorTypeNotFound: | |
| 49 m_resolver->reject(DOMException::create(NotFoundError, error->message)); | |
| 50 break; | |
| 51 case WebSetSinkIdError::ErrorTypeSecurity: | |
| 52 m_resolver->reject(DOMException::create(SecurityError, error->message)); | |
| 53 break; | |
| 54 case WebSetSinkIdError::ErrorTypeNotSupported: | |
| 55 m_resolver->reject(DOMException::create(NotSupportedError, error->messag e)); | |
| 56 break; | |
| 57 case WebSetSinkIdError::ErrorTypeAbort: | |
| 58 m_resolver->reject(DOMException::create(AbortError, error->message)); | |
| 59 break; | |
| 60 default: | |
| 61 ASSERT_NOT_REACHED(); | |
| 62 } | |
| 63 } | |
| 64 | |
| 65 } // namespace blink | |
| OLD | NEW |