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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 m_timer.startOneShot(0, BLINK_FROM_HERE); | 61 m_timer.startOneShot(0, BLINK_FROM_HERE); |
62 } | 62 } |
63 | 63 |
64 void SetSinkIdResolver::timerFired(TimerBase* timer) { | 64 void SetSinkIdResolver::timerFired(TimerBase* timer) { |
65 ExecutionContext* context = getExecutionContext(); | 65 ExecutionContext* context = getExecutionContext(); |
66 ASSERT(context && context->isDocument()); | 66 ASSERT(context && context->isDocument()); |
67 std::unique_ptr<SetSinkIdCallbacks> callbacks = | 67 std::unique_ptr<SetSinkIdCallbacks> callbacks = |
68 wrapUnique(new SetSinkIdCallbacks(this, *m_element, m_sinkId)); | 68 wrapUnique(new SetSinkIdCallbacks(this, *m_element, m_sinkId)); |
69 WebMediaPlayer* webMediaPlayer = m_element->webMediaPlayer(); | 69 WebMediaPlayer* webMediaPlayer = m_element->webMediaPlayer(); |
70 if (webMediaPlayer) { | 70 if (webMediaPlayer) { |
71 // Using release() to transfer ownership because |webMediaPlayer| is a platf
orm object that takes raw pointers | 71 // Using release() to transfer ownership because |webMediaPlayer| is a |
| 72 // platform object that takes raw pointers. |
72 webMediaPlayer->setSinkId(m_sinkId, | 73 webMediaPlayer->setSinkId(m_sinkId, |
73 WebSecurityOrigin(context->getSecurityOrigin()), | 74 WebSecurityOrigin(context->getSecurityOrigin()), |
74 callbacks.release()); | 75 callbacks.release()); |
75 } else { | 76 } else { |
76 if (AudioOutputDeviceClient* client = | 77 if (AudioOutputDeviceClient* client = |
77 AudioOutputDeviceClient::from(context)) { | 78 AudioOutputDeviceClient::from(context)) { |
78 client->checkIfAudioSinkExistsAndIsAuthorized(context, m_sinkId, | 79 client->checkIfAudioSinkExistsAndIsAuthorized(context, m_sinkId, |
79 std::move(callbacks)); | 80 std::move(callbacks)); |
80 } else { | 81 } else { |
81 // The context has been detached. Impossible to get a security origin to c
heck. | 82 // The context has been detached. Impossible to get a security origin to |
| 83 // check. |
82 ASSERT(context->activeDOMObjectsAreStopped()); | 84 ASSERT(context->activeDOMObjectsAreStopped()); |
83 reject(DOMException::create( | 85 reject(DOMException::create( |
84 SecurityError, | 86 SecurityError, |
85 "Impossible to authorize device for detached context")); | 87 "Impossible to authorize device for detached context")); |
86 } | 88 } |
87 } | 89 } |
88 } | 90 } |
89 | 91 |
90 DEFINE_TRACE(SetSinkIdResolver) { | 92 DEFINE_TRACE(SetSinkIdResolver) { |
91 visitor->trace(m_element); | 93 visitor->trace(m_element); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 provideTo(element, supplementName(), supplement); | 138 provideTo(element, supplementName(), supplement); |
137 } | 139 } |
138 return *supplement; | 140 return *supplement; |
139 } | 141 } |
140 | 142 |
141 DEFINE_TRACE(HTMLMediaElementAudioOutputDevice) { | 143 DEFINE_TRACE(HTMLMediaElementAudioOutputDevice) { |
142 Supplement<HTMLMediaElement>::trace(visitor); | 144 Supplement<HTMLMediaElement>::trace(visitor); |
143 } | 145 } |
144 | 146 |
145 } // namespace blink | 147 } // namespace blink |
OLD | NEW |