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

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

Issue 1302793002: Refactor "options" argument to getUserMedia to be a dictionary (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 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 "config.h" 5 #include "config.h"
6 #include "modules/mediastream/MediaDevices.h" 6 #include "modules/mediastream/MediaDevices.h"
7 7
8 #include "bindings/core/v8/ScriptPromise.h" 8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "bindings/core/v8/ScriptState.h" 10 #include "bindings/core/v8/ScriptState.h"
11 #include "core/dom/DOMException.h" 11 #include "core/dom/DOMException.h"
12 #include "core/dom/Document.h" 12 #include "core/dom/Document.h"
13 #include "core/dom/ExceptionCode.h" 13 #include "core/dom/ExceptionCode.h"
14 #include "modules/mediastream/MediaStream.h" 14 #include "modules/mediastream/MediaStream.h"
15 #include "modules/mediastream/MediaStreamConstraints.h"
15 #include "modules/mediastream/NavigatorMediaStream.h" 16 #include "modules/mediastream/NavigatorMediaStream.h"
16 #include "modules/mediastream/NavigatorUserMediaErrorCallback.h" 17 #include "modules/mediastream/NavigatorUserMediaErrorCallback.h"
17 #include "modules/mediastream/NavigatorUserMediaSuccessCallback.h" 18 #include "modules/mediastream/NavigatorUserMediaSuccessCallback.h"
18 #include "modules/mediastream/UserMediaController.h" 19 #include "modules/mediastream/UserMediaController.h"
19 20
20 namespace blink { 21 namespace blink {
21 22
22 ScriptPromise MediaDevices::enumerateDevices(ScriptState* scriptState) 23 ScriptPromise MediaDevices::enumerateDevices(ScriptState* scriptState)
23 { 24 {
24 Document* document = toDocument(scriptState->executionContext()); 25 Document* document = toDocument(scriptState->executionContext());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 visitor->trace(m_resolver); 80 visitor->trace(m_resolver);
80 NavigatorUserMediaErrorCallback::trace(visitor); 81 NavigatorUserMediaErrorCallback::trace(visitor);
81 } 82 }
82 83
83 private: 84 private:
84 Member<ScriptPromiseResolver> m_resolver; 85 Member<ScriptPromiseResolver> m_resolver;
85 }; 86 };
86 87
87 } // namespace 88 } // namespace
88 89
89 ScriptPromise MediaDevices::getUserMedia(ScriptState* scriptState, const Diction ary& options, ExceptionState& exceptionState) 90 ScriptPromise MediaDevices::getUserMedia(ScriptState* scriptState, const MediaSt reamConstraints& options, ExceptionState& exceptionState)
90 { 91 {
91 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 92 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
92 93
93 NavigatorUserMediaSuccessCallback* successCallback = new PromiseSuccessCallb ack(resolver); 94 NavigatorUserMediaSuccessCallback* successCallback = new PromiseSuccessCallb ack(resolver);
94 NavigatorUserMediaErrorCallback* errorCallback = new PromiseErrorCallback(re solver); 95 NavigatorUserMediaErrorCallback* errorCallback = new PromiseErrorCallback(re solver);
95 96
96 Document* document = toDocument(scriptState->executionContext()); 97 Document* document = toDocument(scriptState->executionContext());
97 UserMediaController* userMedia = UserMediaController::from(document->frame() ); 98 UserMediaController* userMedia = UserMediaController::from(document->frame() );
98 if (!userMedia) 99 if (!userMedia)
99 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError, "No media device controller available; is this a detac hed window?")); 100 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError, "No media device controller available; is this a detac hed window?"));
100 101
101 UserMediaRequest* request = UserMediaRequest::create(document, userMedia, op tions, successCallback, errorCallback, exceptionState); 102 UserMediaRequest* request = UserMediaRequest::create(document, userMedia, op tions, successCallback, errorCallback, exceptionState);
102 if (!request) { 103 if (!request) {
103 ASSERT(exceptionState.hadException()); 104 ASSERT(exceptionState.hadException());
104 return exceptionState.reject(scriptState); 105 return exceptionState.reject(scriptState);
105 } 106 }
106 107
107 request->start(); 108 request->start();
108 return resolver->promise(); 109 return resolver->promise();
109 } 110 }
110 111
111 } // namespace blink 112 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698