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

Unified Diff: Source/modules/mediastream/UserMediaRequest.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/mediastream/UserMediaRequest.h ('k') | Source/modules/modules.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/mediastream/UserMediaRequest.cpp
diff --git a/Source/modules/mediastream/UserMediaRequest.cpp b/Source/modules/mediastream/UserMediaRequest.cpp
index 4262a2cbd7adc1d9c9882b688c419f17047d03ba..e4bb565d0764fd884a12797ab503b9084e045776 100644
--- a/Source/modules/mediastream/UserMediaRequest.cpp
+++ b/Source/modules/mediastream/UserMediaRequest.cpp
@@ -41,37 +41,36 @@
#include "core/dom/SpaceSplitString.h"
#include "modules/mediastream/MediaConstraintsImpl.h"
#include "modules/mediastream/MediaStream.h"
+#include "modules/mediastream/MediaStreamConstraints.h"
#include "modules/mediastream/UserMediaController.h"
#include "platform/mediastream/MediaStreamCenter.h"
#include "platform/mediastream/MediaStreamDescriptor.h"
namespace blink {
-static WebMediaConstraints parseOptions(const Dictionary& options, const String& mediaType, ExceptionState& exceptionState)
+static WebMediaConstraints parseOptions(const BooleanOrDictionary& options, ExceptionState& exceptionState)
{
WebMediaConstraints constraints;
Dictionary constraintsDictionary;
- bool ok = options.get(mediaType, constraintsDictionary);
- if (ok && !constraintsDictionary.isUndefinedOrNull())
- constraints = MediaConstraintsImpl::create(constraintsDictionary, exceptionState);
- else {
- bool mediaRequested = false;
- DictionaryHelper::get(options, mediaType, mediaRequested);
- if (mediaRequested)
+ if (options.isDictionary()) {
+ constraints = MediaConstraintsImpl::create(options.getAsDictionary(), exceptionState);
+ } else {
+ if (options.getAsBoolean()) {
tommi (sloooow) - chröme 2015/08/20 08:05:28 } else if (options.getAsBoolean()) {
constraints = MediaConstraintsImpl::create();
+ }
}
tommi (sloooow) - chröme 2015/08/20 08:05:28 } else { ASSERT(false); } (assuming options wil
hta - Chromium 2015/08/20 08:20:32 options.getAsBoolean actually calls ASSERT(isBoole
return constraints;
}
-UserMediaRequest* UserMediaRequest::create(ExecutionContext* context, UserMediaController* controller, const Dictionary& options, NavigatorUserMediaSuccessCallback* successCallback, NavigatorUserMediaErrorCallback* errorCallback, ExceptionState& exceptionState)
+UserMediaRequest* UserMediaRequest::create(ExecutionContext* context, UserMediaController* controller, const MediaStreamConstraints& options, NavigatorUserMediaSuccessCallback* successCallback, NavigatorUserMediaErrorCallback* errorCallback, ExceptionState& exceptionState)
{
- WebMediaConstraints audio = parseOptions(options, "audio", exceptionState);
+ WebMediaConstraints audio = parseOptions(options.audio(), exceptionState);
if (exceptionState.hadException())
return nullptr;
- WebMediaConstraints video = parseOptions(options, "video", exceptionState);
+ WebMediaConstraints video = parseOptions(options.video(), exceptionState);
if (exceptionState.hadException())
return nullptr;
« no previous file with comments | « Source/modules/mediastream/UserMediaRequest.h ('k') | Source/modules/modules.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698