| 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/HTMLMediaElementAudioOutputDevice.h" | 5 #include "modules/audio_output_devices/HTMLMediaElementAudioOutputDevice.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
| 9 #include "core/dom/DOMException.h" | 9 #include "core/dom/DOMException.h" |
| 10 #include "core/dom/ExecutionContext.h" | 10 #include "core/dom/ExecutionContext.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 WTF_MAKE_NONCOPYABLE(SetSinkIdResolver); | 22 WTF_MAKE_NONCOPYABLE(SetSinkIdResolver); |
| 23 public: | 23 public: |
| 24 static SetSinkIdResolver* create(ScriptState*, HTMLMediaElement&, const Stri
ng& sinkId); | 24 static SetSinkIdResolver* create(ScriptState*, HTMLMediaElement&, const Stri
ng& sinkId); |
| 25 ~SetSinkIdResolver() override = default; | 25 ~SetSinkIdResolver() override = default; |
| 26 void startAsync(); | 26 void startAsync(); |
| 27 | 27 |
| 28 DECLARE_VIRTUAL_TRACE(); | 28 DECLARE_VIRTUAL_TRACE(); |
| 29 | 29 |
| 30 private: | 30 private: |
| 31 SetSinkIdResolver(ScriptState*, HTMLMediaElement&, const String& sinkId); | 31 SetSinkIdResolver(ScriptState*, HTMLMediaElement&, const String& sinkId); |
| 32 void timerFired(Timer<SetSinkIdResolver>*); | 32 void timerFired(TimerBase*); |
| 33 | 33 |
| 34 Member<HTMLMediaElement> m_element; | 34 Member<HTMLMediaElement> m_element; |
| 35 String m_sinkId; | 35 String m_sinkId; |
| 36 Timer<SetSinkIdResolver> m_timer; | 36 Timer<SetSinkIdResolver> m_timer; |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 SetSinkIdResolver* SetSinkIdResolver::create(ScriptState* scriptState, HTMLMedia
Element& element, const String& sinkId) | 39 SetSinkIdResolver* SetSinkIdResolver::create(ScriptState* scriptState, HTMLMedia
Element& element, const String& sinkId) |
| 40 { | 40 { |
| 41 SetSinkIdResolver* resolver = new SetSinkIdResolver(scriptState, element, si
nkId); | 41 SetSinkIdResolver* resolver = new SetSinkIdResolver(scriptState, element, si
nkId); |
| 42 resolver->suspendIfNeeded(); | 42 resolver->suspendIfNeeded(); |
| 43 resolver->keepAliveWhilePending(); | 43 resolver->keepAliveWhilePending(); |
| 44 return resolver; | 44 return resolver; |
| 45 } | 45 } |
| 46 | 46 |
| 47 SetSinkIdResolver::SetSinkIdResolver(ScriptState* scriptState, HTMLMediaElement&
element, const String& sinkId) | 47 SetSinkIdResolver::SetSinkIdResolver(ScriptState* scriptState, HTMLMediaElement&
element, const String& sinkId) |
| 48 : ScriptPromiseResolver(scriptState) | 48 : ScriptPromiseResolver(scriptState) |
| 49 , m_element(element) | 49 , m_element(element) |
| 50 , m_sinkId(sinkId) | 50 , m_sinkId(sinkId) |
| 51 , m_timer(this, &SetSinkIdResolver::timerFired) | 51 , m_timer(this, &SetSinkIdResolver::timerFired) |
| 52 { | 52 { |
| 53 } | 53 } |
| 54 | 54 |
| 55 void SetSinkIdResolver::startAsync() | 55 void SetSinkIdResolver::startAsync() |
| 56 { | 56 { |
| 57 m_timer.startOneShot(0, BLINK_FROM_HERE); | 57 m_timer.startOneShot(0, BLINK_FROM_HERE); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void SetSinkIdResolver::timerFired(Timer<SetSinkIdResolver>* timer) | 60 void SetSinkIdResolver::timerFired(TimerBase* timer) |
| 61 { | 61 { |
| 62 ExecutionContext* context = getExecutionContext(); | 62 ExecutionContext* context = getExecutionContext(); |
| 63 ASSERT(context && context->isDocument()); | 63 ASSERT(context && context->isDocument()); |
| 64 std::unique_ptr<SetSinkIdCallbacks> callbacks = wrapUnique(new SetSinkIdCall
backs(this, *m_element, m_sinkId)); | 64 std::unique_ptr<SetSinkIdCallbacks> callbacks = wrapUnique(new SetSinkIdCall
backs(this, *m_element, m_sinkId)); |
| 65 WebMediaPlayer* webMediaPlayer = m_element->webMediaPlayer(); | 65 WebMediaPlayer* webMediaPlayer = m_element->webMediaPlayer(); |
| 66 if (webMediaPlayer) { | 66 if (webMediaPlayer) { |
| 67 // Using release() to transfer ownership because |webMediaPlayer| is a p
latform object that takes raw pointers | 67 // Using release() to transfer ownership because |webMediaPlayer| is a p
latform object that takes raw pointers |
| 68 webMediaPlayer->setSinkId(m_sinkId, WebSecurityOrigin(context->getSecuri
tyOrigin()), callbacks.release()); | 68 webMediaPlayer->setSinkId(m_sinkId, WebSecurityOrigin(context->getSecuri
tyOrigin()), callbacks.release()); |
| 69 } else { | 69 } else { |
| 70 if (AudioOutputDeviceClient* client = AudioOutputDeviceClient::from(cont
ext)) { | 70 if (AudioOutputDeviceClient* client = AudioOutputDeviceClient::from(cont
ext)) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 127 } |
| 128 return *supplement; | 128 return *supplement; |
| 129 } | 129 } |
| 130 | 130 |
| 131 DEFINE_TRACE(HTMLMediaElementAudioOutputDevice) | 131 DEFINE_TRACE(HTMLMediaElementAudioOutputDevice) |
| 132 { | 132 { |
| 133 Supplement<HTMLMediaElement>::trace(visitor); | 133 Supplement<HTMLMediaElement>::trace(visitor); |
| 134 } | 134 } |
| 135 | 135 |
| 136 } // namespace blink | 136 } // namespace blink |
| OLD | NEW |