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

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: fix expected 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 e9d8a83a8216914370e554a463933fb421ee3a09..a2280e5f52a70fcf121116cc441767f3cdbc4e65 100644
--- a/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp
+++ b/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp
@@ -359,8 +359,9 @@ RTCConfiguration* RTCPeerConnection::parseConfiguration(const Dictionary& config
return rtcConfiguration;
}
-RTCOfferOptions* RTCPeerConnection::parseOfferOptions(const Dictionary& options, ExceptionState& exceptionState)
+RTCOfferOptions* RTCPeerConnection::parseOfferOptions(const Dictionary& options, RTCErrorCallback* errorCallback, bool& hadError)
{
+ hadError = false;
if (options.isUndefinedOrNull())
return 0;
@@ -378,12 +379,14 @@ RTCOfferOptions* RTCPeerConnection::parseOfferOptions(const Dictionary& options,
bool iceRestart = false;
if (DictionaryHelper::get(options, "offerToReceiveVideo", offerToReceiveVideo) && offerToReceiveVideo < 0) {
- exceptionState.throwTypeError("Invalid offerToReceiveVideo");
+ asyncCallErrorCallback(errorCallback, "Invalid offerToReceiveVideo");
philipj_slow 2016/02/22 10:03:41 Before this would throw a TypeError, and if I'm re
Guido Urdaneta 2016/02/22 11:37:50 Yes. The spec uses RTCPeerConnectionErrorCallback,
+ hadError = true;
return 0;
}
if (DictionaryHelper::get(options, "offerToReceiveAudio", offerToReceiveAudio) && offerToReceiveAudio < 0) {
- exceptionState.throwTypeError("Invalid offerToReceiveAudio");
+ asyncCallErrorCallback(errorCallback, "Invalid offerToReceiveAudio");
+ hadError = true;
return 0;
}
@@ -465,20 +468,17 @@ RTCPeerConnection::~RTCPeerConnection()
ASSERT(m_closed || m_stopped);
}
-void RTCPeerConnection::createOffer(ExecutionContext* context, RTCSessionDescriptionCallback* successCallback, RTCErrorCallback* errorCallback, const Dictionary& rtcOfferOptions, ExceptionState& exceptionState)
+void RTCPeerConnection::createOffer(ExecutionContext* context, RTCSessionDescriptionCallback* successCallback, RTCErrorCallback* 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);
+ ASSERT(errorCallback);
philipj_slow 2016/02/22 10:03:41 The nullability of errorCallback didn't change wit
Guido Urdaneta 2016/02/22 11:37:50 Correct. There was a previous CL making the error
philipj_slow 2016/02/23 09:13:54 Sounds fine to do here, just checking.
+ UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferLegacyFailureCallback);
+ if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback))
+ return;
- RTCOfferOptions* offerOptions = parseOfferOptions(rtcOfferOptions, exceptionState);
- if (exceptionState.hadException())
+ bool hadOfferOptionsError = false;
+ RTCOfferOptions* offerOptions = parseOfferOptions(rtcOfferOptions, errorCallback, hadOfferOptionsError);
+ if (hadOfferOptionsError)
return;
RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::create(executionContext(), this, successCallback, errorCallback);
@@ -486,7 +486,7 @@ void RTCPeerConnection::createOffer(ExecutionContext* context, RTCSessionDescrip
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);
@@ -494,40 +494,38 @@ void RTCPeerConnection::createOffer(ExecutionContext* context, RTCSessionDescrip
MediaErrorState mediaErrorState;
WebMediaConstraints constraints = MediaConstraintsImpl::create(context, rtcOfferOptions, mediaErrorState);
if (mediaErrorState.hadException()) {
- mediaErrorState.raiseException(exceptionState);
+ String errorMsg = mediaErrorState.getErrorMessage();
+ asyncCallErrorCallback(errorCallback, 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, RTCErrorCallback* errorCallback, const Dictionary& mediaConstraints, ExceptionState& exceptionState)
+void RTCPeerConnection::createAnswer(ExecutionContext* context, RTCSessionDescriptionCallback* successCallback, RTCErrorCallback* 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);
+ String errorMsg = mediaErrorState.getErrorMessage();
+ asyncCallErrorCallback(errorCallback, errorMsg);
return;
}

Powered by Google App Engine
This is Rietveld 408576698