| 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/audio_output_devices/HTMLMediaElementAudioOutputDevice.h" | 6 #include "modules/audio_output_devices/HTMLMediaElementAudioOutputDevice.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
| 10 #include "core/dom/ExecutionContext.h" | 10 #include "core/dom/ExecutionContext.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 { | 28 { |
| 29 m_sinkId = sinkId; | 29 m_sinkId = sinkId; |
| 30 } | 30 } |
| 31 | 31 |
| 32 ScriptPromise HTMLMediaElementAudioOutputDevice::setSinkId(ScriptState* scriptSt
ate, HTMLMediaElement& element, const String& sinkId) | 32 ScriptPromise HTMLMediaElementAudioOutputDevice::setSinkId(ScriptState* scriptSt
ate, HTMLMediaElement& element, const String& sinkId) |
| 33 { | 33 { |
| 34 WebMediaPlayer* webMediaPlayer = element.webMediaPlayer(); | 34 WebMediaPlayer* webMediaPlayer = element.webMediaPlayer(); |
| 35 if (!webMediaPlayer) | 35 if (!webMediaPlayer) |
| 36 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(AbortError, "No media player available")); | 36 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(AbortError, "No media player available")); |
| 37 | 37 |
| 38 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 38 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 39 webMediaPlayer->setSinkId(sinkId, new SetSinkIdCallbacks(resolver, element,
sinkId)); | 39 webMediaPlayer->setSinkId(sinkId, new SetSinkIdCallbacks(resolver, element,
sinkId)); |
| 40 return resolver->promise(); | 40 return resolver->promise(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 const char* HTMLMediaElementAudioOutputDevice::supplementName() | 43 const char* HTMLMediaElementAudioOutputDevice::supplementName() |
| 44 { | 44 { |
| 45 return "HTMLMediaElementAudioOutputDevice"; | 45 return "HTMLMediaElementAudioOutputDevice"; |
| 46 } | 46 } |
| 47 | 47 |
| 48 HTMLMediaElementAudioOutputDevice& HTMLMediaElementAudioOutputDevice::from(HTMLM
ediaElement& element) | 48 HTMLMediaElementAudioOutputDevice& HTMLMediaElementAudioOutputDevice::from(HTMLM
ediaElement& element) |
| 49 { | 49 { |
| 50 HTMLMediaElementAudioOutputDevice* supplement = static_cast<HTMLMediaElement
AudioOutputDevice*>(WillBeHeapSupplement<HTMLMediaElement>::from(element, supple
mentName())); | 50 HTMLMediaElementAudioOutputDevice* supplement = static_cast<HTMLMediaElement
AudioOutputDevice*>(WillBeHeapSupplement<HTMLMediaElement>::from(element, supple
mentName())); |
| 51 if (!supplement) { | 51 if (!supplement) { |
| 52 supplement = new HTMLMediaElementAudioOutputDevice(); | 52 supplement = new HTMLMediaElementAudioOutputDevice(); |
| 53 provideTo(element, supplementName(), adoptPtrWillBeNoop(supplement)); | 53 provideTo(element, supplementName(), adoptPtrWillBeNoop(supplement)); |
| 54 } | 54 } |
| 55 return *supplement; | 55 return *supplement; |
| 56 } | 56 } |
| 57 | 57 |
| 58 DEFINE_TRACE(HTMLMediaElementAudioOutputDevice) | 58 DEFINE_TRACE(HTMLMediaElementAudioOutputDevice) |
| 59 { | 59 { |
| 60 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor); | 60 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor); |
| 61 } | 61 } |
| 62 | 62 |
| 63 } // namespace blink | 63 } // namespace blink |
| OLD | NEW |