Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: third_party/WebKit/Source/modules/audio_output_devices/HTMLMediaElementAudioOutputDevice.cpp

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "modules/audio_output_devices/AudioOutputDeviceClient.h" 11 #include "modules/audio_output_devices/AudioOutputDeviceClient.h"
12 #include "modules/audio_output_devices/SetSinkIdCallbacks.h" 12 #include "modules/audio_output_devices/SetSinkIdCallbacks.h"
13 #include "public/platform/WebSecurityOrigin.h" 13 #include "public/platform/WebSecurityOrigin.h"
14 #include "wtf/PtrUtil.h"
15 #include <memory>
16 14
17 namespace blink { 15 namespace blink {
18 16
19 namespace { 17 namespace {
20 18
21 class SetSinkIdResolver : public ScriptPromiseResolver { 19 class SetSinkIdResolver : public ScriptPromiseResolver {
22 WTF_MAKE_NONCOPYABLE(SetSinkIdResolver); 20 WTF_MAKE_NONCOPYABLE(SetSinkIdResolver);
23 public: 21 public:
24 static SetSinkIdResolver* create(ScriptState*, HTMLMediaElement&, const Stri ng& sinkId); 22 static SetSinkIdResolver* create(ScriptState*, HTMLMediaElement&, const Stri ng& sinkId);
25 ~SetSinkIdResolver() override = default; 23 ~SetSinkIdResolver() override = default;
(...skipping 28 matching lines...) Expand all
54 52
55 void SetSinkIdResolver::startAsync() 53 void SetSinkIdResolver::startAsync()
56 { 54 {
57 m_timer.startOneShot(0, BLINK_FROM_HERE); 55 m_timer.startOneShot(0, BLINK_FROM_HERE);
58 } 56 }
59 57
60 void SetSinkIdResolver::timerFired(Timer<SetSinkIdResolver>* timer) 58 void SetSinkIdResolver::timerFired(Timer<SetSinkIdResolver>* timer)
61 { 59 {
62 ExecutionContext* context = getExecutionContext(); 60 ExecutionContext* context = getExecutionContext();
63 ASSERT(context && context->isDocument()); 61 ASSERT(context && context->isDocument());
64 std::unique_ptr<SetSinkIdCallbacks> callbacks = wrapUnique(new SetSinkIdCall backs(this, *m_element, m_sinkId)); 62 OwnPtr<SetSinkIdCallbacks> callbacks = adoptPtr(new SetSinkIdCallbacks(this, *m_element, m_sinkId));
65 WebMediaPlayer* webMediaPlayer = m_element->webMediaPlayer(); 63 WebMediaPlayer* webMediaPlayer = m_element->webMediaPlayer();
66 if (webMediaPlayer) { 64 if (webMediaPlayer) {
67 // Using release() to transfer ownership because |webMediaPlayer| is a p latform object that takes raw pointers 65 // Using leakPtr() 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()); 66 webMediaPlayer->setSinkId(m_sinkId, WebSecurityOrigin(context->getSecuri tyOrigin()), callbacks.leakPtr());
69 } else { 67 } else {
70 if (AudioOutputDeviceClient* client = AudioOutputDeviceClient::from(cont ext)) { 68 if (AudioOutputDeviceClient* client = AudioOutputDeviceClient::from(cont ext)) {
71 client->checkIfAudioSinkExistsAndIsAuthorized(context, m_sinkId, std ::move(callbacks)); 69 client->checkIfAudioSinkExistsAndIsAuthorized(context, m_sinkId, std ::move(callbacks));
72 } else { 70 } else {
73 // The context has been detached. Impossible to get a security origi n to check. 71 // The context has been detached. Impossible to get a security origi n to check.
74 ASSERT(context->activeDOMObjectsAreStopped()); 72 ASSERT(context->activeDOMObjectsAreStopped());
75 reject(DOMException::create(SecurityError, "Impossible to authorize device for detached context")); 73 reject(DOMException::create(SecurityError, "Impossible to authorize device for detached context"));
76 } 74 }
77 } 75 }
78 } 76 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 125 }
128 return *supplement; 126 return *supplement;
129 } 127 }
130 128
131 DEFINE_TRACE(HTMLMediaElementAudioOutputDevice) 129 DEFINE_TRACE(HTMLMediaElementAudioOutputDevice)
132 { 130 {
133 Supplement<HTMLMediaElement>::trace(visitor); 131 Supplement<HTMLMediaElement>::trace(visitor);
134 } 132 }
135 133
136 } // namespace blink 134 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698