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

Side by Side Diff: third_party/WebKit/Source/modules/mediastream/MediaDevices.cpp

Issue 2815313002: Reland of Move ScriptState::GetExecutionContext (Part 5) (Closed)
Patch Set: Created 3 years, 8 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/mediastream/MediaDevices.h" 5 #include "modules/mediastream/MediaDevices.h"
6 6
7 #include "bindings/core/v8/ScriptPromise.h" 7 #include "bindings/core/v8/ScriptPromise.h"
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/DOMException.h" 10 #include "core/dom/DOMException.h"
11 #include "core/dom/Document.h" 11 #include "core/dom/Document.h"
12 #include "core/dom/ExceptionCode.h" 12 #include "core/dom/ExceptionCode.h"
13 #include "core/dom/ExecutionContext.h"
13 #include "core/events/Event.h" 14 #include "core/events/Event.h"
14 #include "modules/mediastream/MediaErrorState.h" 15 #include "modules/mediastream/MediaErrorState.h"
15 #include "modules/mediastream/MediaStream.h" 16 #include "modules/mediastream/MediaStream.h"
16 #include "modules/mediastream/MediaStreamConstraints.h" 17 #include "modules/mediastream/MediaStreamConstraints.h"
17 #include "modules/mediastream/NavigatorMediaStream.h" 18 #include "modules/mediastream/NavigatorMediaStream.h"
18 #include "modules/mediastream/NavigatorUserMediaErrorCallback.h" 19 #include "modules/mediastream/NavigatorUserMediaErrorCallback.h"
19 #include "modules/mediastream/NavigatorUserMediaSuccessCallback.h" 20 #include "modules/mediastream/NavigatorUserMediaSuccessCallback.h"
20 #include "modules/mediastream/UserMediaController.h" 21 #include "modules/mediastream/UserMediaController.h"
21 22
22 namespace blink { 23 namespace blink {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 : SuspendableObject(context), 72 : SuspendableObject(context),
72 observing_(false), 73 observing_(false),
73 stopped_(false), 74 stopped_(false),
74 dispatch_scheduled_event_runner_(AsyncMethodRunner<MediaDevices>::Create( 75 dispatch_scheduled_event_runner_(AsyncMethodRunner<MediaDevices>::Create(
75 this, 76 this,
76 &MediaDevices::DispatchScheduledEvent)) {} 77 &MediaDevices::DispatchScheduledEvent)) {}
77 78
78 MediaDevices::~MediaDevices() {} 79 MediaDevices::~MediaDevices() {}
79 80
80 ScriptPromise MediaDevices::enumerateDevices(ScriptState* script_state) { 81 ScriptPromise MediaDevices::enumerateDevices(ScriptState* script_state) {
81 Document* document = ToDocument(script_state->GetExecutionContext()); 82 Document* document = ToDocument(ExecutionContext::From(script_state));
82 UserMediaController* user_media = 83 UserMediaController* user_media =
83 UserMediaController::From(document->GetFrame()); 84 UserMediaController::From(document->GetFrame());
84 if (!user_media) 85 if (!user_media)
85 return ScriptPromise::RejectWithDOMException( 86 return ScriptPromise::RejectWithDOMException(
86 script_state, 87 script_state,
87 DOMException::Create(kNotSupportedError, 88 DOMException::Create(kNotSupportedError,
88 "No media device controller available; is this a " 89 "No media device controller available; is this a "
89 "detached window?")); 90 "detached window?"));
90 91
91 MediaDevicesRequest* request = 92 MediaDevicesRequest* request =
92 MediaDevicesRequest::Create(script_state, user_media); 93 MediaDevicesRequest::Create(script_state, user_media);
93 return request->Start(); 94 return request->Start();
94 } 95 }
95 96
96 ScriptPromise MediaDevices::getUserMedia(ScriptState* script_state, 97 ScriptPromise MediaDevices::getUserMedia(ScriptState* script_state,
97 const MediaStreamConstraints& options, 98 const MediaStreamConstraints& options,
98 ExceptionState& exception_state) { 99 ExceptionState& exception_state) {
99 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); 100 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state);
100 101
101 NavigatorUserMediaSuccessCallback* success_callback = 102 NavigatorUserMediaSuccessCallback* success_callback =
102 new PromiseSuccessCallback(resolver); 103 new PromiseSuccessCallback(resolver);
103 NavigatorUserMediaErrorCallback* error_callback = 104 NavigatorUserMediaErrorCallback* error_callback =
104 new PromiseErrorCallback(resolver); 105 new PromiseErrorCallback(resolver);
105 106
106 Document* document = ToDocument(script_state->GetExecutionContext()); 107 Document* document = ToDocument(ExecutionContext::From(script_state));
107 UserMediaController* user_media = 108 UserMediaController* user_media =
108 UserMediaController::From(document->GetFrame()); 109 UserMediaController::From(document->GetFrame());
109 if (!user_media) 110 if (!user_media)
110 return ScriptPromise::RejectWithDOMException( 111 return ScriptPromise::RejectWithDOMException(
111 script_state, 112 script_state,
112 DOMException::Create(kNotSupportedError, 113 DOMException::Create(kNotSupportedError,
113 "No media device controller available; is this a " 114 "No media device controller available; is this a "
114 "detached window?")); 115 "detached window?"));
115 116
116 MediaErrorState error_state; 117 MediaErrorState error_state;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 249 }
249 250
250 DEFINE_TRACE(MediaDevices) { 251 DEFINE_TRACE(MediaDevices) {
251 visitor->Trace(dispatch_scheduled_event_runner_); 252 visitor->Trace(dispatch_scheduled_event_runner_);
252 visitor->Trace(scheduled_events_); 253 visitor->Trace(scheduled_events_);
253 EventTargetWithInlineData::Trace(visitor); 254 EventTargetWithInlineData::Trace(visitor);
254 SuspendableObject::Trace(visitor); 255 SuspendableObject::Trace(visitor);
255 } 256 }
256 257
257 } // namespace blink 258 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698