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

Unified Diff: third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp

Issue 1713953002: Report errors in RTCPeerConnection legacy functions via the the failure callback instead of excepti… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ignore ConstraintErrors produced by the constraints parser Created 4 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
Index: third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp
diff --git a/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp b/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp
index 1fc84a1ffb378e7736b24eb025d1abcb1764f0c8..7b508f573802d1b873743096f1dca346aa1ae62f 100644
--- a/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp
+++ b/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp
@@ -359,7 +359,7 @@ RTCConfiguration* RTCPeerConnection::parseConfiguration(const Dictionary& config
return rtcConfiguration;
}
-RTCOfferOptions* RTCPeerConnection::parseOfferOptions(const Dictionary& options, ExceptionState& exceptionState)
+RTCOfferOptions* RTCPeerConnection::parseOfferOptions(const Dictionary& options)
{
if (options.isUndefinedOrNull())
return 0;
@@ -377,16 +377,10 @@ RTCOfferOptions* RTCPeerConnection::parseOfferOptions(const Dictionary& options,
bool voiceActivityDetection = true;
bool iceRestart = false;
- if (DictionaryHelper::get(options, "offerToReceiveVideo", offerToReceiveVideo) && offerToReceiveVideo < 0) {
- exceptionState.throwTypeError("Invalid offerToReceiveVideo");
- return 0;
- }
-
- if (DictionaryHelper::get(options, "offerToReceiveAudio", offerToReceiveAudio) && offerToReceiveAudio < 0) {
- exceptionState.throwTypeError("Invalid offerToReceiveAudio");
- return 0;
- }
-
+ if (DictionaryHelper::get(options, "offerToReceiveVideo", offerToReceiveVideo) && offerToReceiveVideo < 0)
+ offerToReceiveVideo = 0;
+ if (DictionaryHelper::get(options, "offerToReceiveAudio", offerToReceiveAudio) && offerToReceiveAudio < 0)
+ offerToReceiveAudio = 0;
DictionaryHelper::get(options, "voiceActivityDetection", voiceActivityDetection);
DictionaryHelper::get(options, "iceRestart", iceRestart);
@@ -465,69 +459,60 @@ RTCPeerConnection::~RTCPeerConnection()
ASSERT(m_closed || m_stopped);
}
-void RTCPeerConnection::createOffer(ExecutionContext* context, RTCSessionDescriptionCallback* successCallback, RTCPeerConnectionErrorCallback* errorCallback, const Dictionary& rtcOfferOptions, ExceptionState& exceptionState)
+void RTCPeerConnection::createOffer(ExecutionContext* context, RTCSessionDescriptionCallback* successCallback, RTCPeerConnectionErrorCallback* errorCallback, const Dictionary& rtcOfferOptions)
{
- if (errorCallback)
- UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferLegacyFailureCallback);
- else
- Deprecation::countDeprecation(context, UseCounter::RTCPeerConnectionCreateOfferLegacyNoFailureCallback);
-
- if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
- return;
-
ASSERT(successCallback);
-
- RTCOfferOptions* offerOptions = parseOfferOptions(rtcOfferOptions, exceptionState);
- if (exceptionState.hadException())
+ ASSERT(errorCallback);
+ UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferLegacyFailureCallback);
+ if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback))
return;
+ RTCOfferOptions* offerOptions = parseOfferOptions(rtcOfferOptions);
RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::create(executionContext(), this, successCallback, errorCallback);
if (offerOptions) {
if (offerOptions->offerToReceiveAudio() != -1 || offerOptions->offerToReceiveVideo() != -1)
UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferLegacyOfferOptions);
- else if (errorCallback)
+ else
UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferLegacyCompliant);
m_peerHandler->createOffer(request, offerOptions);
} else {
MediaErrorState mediaErrorState;
WebMediaConstraints constraints = MediaConstraintsImpl::create(context, rtcOfferOptions, mediaErrorState);
- if (mediaErrorState.hadException()) {
- mediaErrorState.raiseException(exceptionState);
+ if (mediaErrorState.canGenerateException()) {
philipj_slow 2016/03/01 04:53:05 It's a bit subtle why this works. Isn't it a bug i
hta - Chromium 2016/03/07 15:15:47 The reason for canGenerateException is that the DO
philipj_slow 2016/03/09 13:15:31 OK, so this is related to NavigatorUserMediaError
Guido Urdaneta 2016/03/09 15:04:35 Done.
+ String errorMsg = mediaErrorState.getErrorMessage();
+ asyncCallErrorCallback(errorCallback, DOMException::create(OperationError, errorMsg));
return;
}
if (!constraints.isEmpty())
UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferLegacyConstraints);
- else if (errorCallback)
+ else
UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferLegacyCompliant);
m_peerHandler->createOffer(request, constraints);
}
}
-void RTCPeerConnection::createAnswer(ExecutionContext* context, RTCSessionDescriptionCallback* successCallback, RTCPeerConnectionErrorCallback* errorCallback, const Dictionary& mediaConstraints, ExceptionState& exceptionState)
+void RTCPeerConnection::createAnswer(ExecutionContext* context, RTCSessionDescriptionCallback* successCallback, RTCPeerConnectionErrorCallback* errorCallback, const Dictionary& mediaConstraints)
{
- if (errorCallback)
- UseCounter::count(context, UseCounter::RTCPeerConnectionCreateAnswerLegacyFailureCallback);
- else
- Deprecation::countDeprecation(context, UseCounter::RTCPeerConnectionCreateAnswerLegacyNoFailureCallback);
-
+ ASSERT(successCallback);
+ ASSERT(errorCallback);
+ UseCounter::count(context, UseCounter::RTCPeerConnectionCreateAnswerLegacyFailureCallback);
if (mediaConstraints.isObject())
UseCounter::count(context, UseCounter::RTCPeerConnectionCreateAnswerLegacyConstraints);
- else if (errorCallback)
+ else
UseCounter::count(context, UseCounter::RTCPeerConnectionCreateAnswerLegacyCompliant);
- if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
+ if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback))
return;
- ASSERT(successCallback);
-
MediaErrorState mediaErrorState;
WebMediaConstraints constraints = MediaConstraintsImpl::create(context, mediaConstraints, mediaErrorState);
- if (mediaErrorState.hadException()) {
- mediaErrorState.raiseException(exceptionState);
+ if (mediaErrorState.canGenerateException()) {
+ String errorMsg = mediaErrorState.getErrorMessage();
+ asyncCallErrorCallback(errorCallback, DOMException::create(OperationError, errorMsg));
return;
}

Powered by Google App Engine
This is Rietveld 408576698