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

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

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

Powered by Google App Engine
This is Rietveld 408576698