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

Unified Diff: Source/modules/mediastream/UserMediaRequest.cpp

Issue 173893009: MediaStream API: Update getUserMedia to match the spec (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed review comment Created 6 years, 10 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/NavigatorMediaStream.idl ('k') | no next file » | 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 750298b508f5e93ddc3867dcbf38f34b21b63c88..cbec9e3805b817054b9079a88ad9eaba8171f5b4 100644
--- a/Source/modules/mediastream/UserMediaRequest.cpp
+++ b/Source/modules/mediastream/UserMediaRequest.cpp
@@ -34,8 +34,10 @@
#include "modules/mediastream/UserMediaRequest.h"
#include "bindings/v8/Dictionary.h"
+#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/ExceptionState.h"
#include "core/dom/Document.h"
+#include "core/dom/ExceptionCode.h"
#include "core/dom/SpaceSplitString.h"
#include "modules/mediastream/MediaConstraintsImpl.h"
#include "modules/mediastream/MediaStream.h"
@@ -73,8 +75,10 @@ PassRefPtr<UserMediaRequest> UserMediaRequest::create(ExecutionContext* context,
if (exceptionState.hadException())
return nullptr;
- if (audio.isNull() && video.isNull())
+ if (audio.isNull() && video.isNull()) {
+ exceptionState.throwDOMException(SyntaxError, "At least one of audio and video must be requested");
return nullptr;
+ }
return adoptRef(new UserMediaRequest(context, controller, audio, video, successCallback, errorCallback));
}
@@ -153,10 +157,8 @@ void UserMediaRequest::fail(const String& description)
if (!executionContext())
return;
- if (m_errorCallback) {
- RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(NavigatorUserMediaError::NamePermissionDenied, description, String());
- m_errorCallback->handleEvent(error.get());
- }
+ RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(NavigatorUserMediaError::NamePermissionDenied, description, String());
+ m_errorCallback->handleEvent(error.get());
}
void UserMediaRequest::failConstraint(const String& constraintName, const String& description)
@@ -165,10 +167,8 @@ void UserMediaRequest::failConstraint(const String& constraintName, const String
if (!executionContext())
return;
- if (m_errorCallback) {
- RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(NavigatorUserMediaError::NameConstraintNotSatisfied, description, constraintName);
- m_errorCallback->handleEvent(error.get());
- }
+ RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(NavigatorUserMediaError::NameConstraintNotSatisfied, description, constraintName);
+ m_errorCallback->handleEvent(error.get());
}
void UserMediaRequest::contextDestroyed()
« no previous file with comments | « Source/modules/mediastream/NavigatorMediaStream.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698