Bug 1091898 - remove old non-spec exceptionhandling around callbacks. r=jesup, r=drno
authorJan-Ivar Bruaroey <jib@mozilla.com>
Wed, 26 Nov 2014 22:35:54 -0500
changeset 219123 5bc1b5e7991415629e63f8e15f34f8b59a24202a
parent 219122 e5bf096003d52758f72ee79dff6f63faec4fb232
child 219124 f9cf5afe311a8cd8d81a7f31b4cf2b9b132875d7
push id27956
push userkwierso@gmail.com
push dateFri, 12 Dec 2014 00:47:19 +0000
treeherdermozilla-central@32a2c5bd2f68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, drno
bugs1091898
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1091898 - remove old non-spec exceptionhandling around callbacks. r=jesup, r=drno
dom/media/PeerConnection.js
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -386,31 +386,16 @@ RTCPeerConnection.prototype = {
   get _impl() {
     if (!this._pc) {
       throw new this._win.DOMError("InvalidStateError",
           "RTCPeerConnection is gone (did you enter Offline mode?)");
     }
     return this._pc;
   },
 
-  callCB: function(callback, arg) {
-    if (callback) {
-      this._win.setTimeout(() => {
-        try {
-          callback(arg);
-        } catch(e) {
-          // A content script (user-provided) callback threw an error. We don't
-          // want this to take down peerconnection, but we still want the user
-          // to see it, so we catch it, report it, and move on.
-          this.logErrorAndCallOnError(e.message, e.fileName, e.lineNumber);
-        }
-      }, 0);
-    }
-  },
-
   _initIdp: function() {
     let prefName = "media.peerconnection.identity.timeout";
     let idpTimeout = Services.prefs.getIntPref(prefName);
     let warningFunc = this.logWarning.bind(this);
     this._localIdp = new PeerConnectionIdp(this._win, idpTimeout, warningFunc,
                                            this.dispatchEvent.bind(this));
     this._remoteIdp = new PeerConnectionIdp(this._win, idpTimeout, warningFunc,
                                             this.dispatchEvent.bind(this));
@@ -761,17 +746,17 @@ RTCPeerConnection.prototype = {
     // complicates much more than would be ideal, but it ensures that the IdP
     // doesn't hold things up too much when it's not on the critical path
     let allDone = () => {
       if (!setRemoteComplete || !idpComplete || isDone) {
         return;
       }
       // May be null if the user didn't supply success/failure callbacks.
       // Violation of spec, but we allow it for now
-      this.callCB(onSuccess);
+      onSuccess();
       isDone = true;
       this._executeNext();
     };
 
     let setRemoteDone = () => {
       setRemoteComplete = true;
       allDone();
     };
@@ -785,17 +770,17 @@ RTCPeerConnection.prototype = {
     } else {
       idpDone = message => {
         let idpGood = this._processIdpResult(message);
         if (!idpGood) {
           // iff we are waiting for a very specific peerIdentity
           // call the error callback directly and then close
           idpError = "Peer Identity mismatch, expected: " +
             this._impl.peerIdentity;
-          this.callCB(onError, idpError);
+          onError(idpError);
           this.close();
         } else {
           idpComplete = true;
           allDone();
         }
       };
     }
 
@@ -1159,81 +1144,75 @@ PeerConnectionObserver.prototype = {
   onCreateOfferSuccess: function(sdp) {
     let pc = this._dompc;
     let fp = pc._impl.fingerprint;
     let origin = Cu.getWebIDLCallerPrincipal().origin;
     pc._localIdp.appendIdentityToSDP(sdp, fp, origin, function(sdp, assertion) {
       if (assertion) {
         pc._gotIdentityAssertion(assertion);
       }
-      pc.callCB(pc._onCreateOfferSuccess,
-                new pc._win.mozRTCSessionDescription({ type: "offer",
-                                                       sdp: sdp }));
+      pc._onCreateOfferSuccess(new pc._win.mozRTCSessionDescription({ type: "offer",
+                                                                      sdp: sdp }));
       pc._executeNext();
     }.bind(this));
   },
 
   onCreateOfferError: function(code, message) {
-    this._dompc.callCB(this._dompc._onCreateOfferFailure, this.newError(code, message));
+    this._dompc._onCreateOfferFailure(this.newError(code, message));
     this._dompc._executeNext();
   },
 
   onCreateAnswerSuccess: function(sdp) {
     let pc = this._dompc;
     let fp = pc._impl.fingerprint;
     let origin = Cu.getWebIDLCallerPrincipal().origin;
     pc._localIdp.appendIdentityToSDP(sdp, fp, origin, function(sdp, assertion) {
       if (assertion) {
         pc._gotIdentityAssertion(assertion);
       }
-      pc.callCB(pc._onCreateAnswerSuccess,
-                new pc._win.mozRTCSessionDescription({ type: "answer",
-                                                       sdp: sdp }));
+      pc._onCreateAnswerSuccess(new pc._win.mozRTCSessionDescription({ type: "answer",
+                                                                       sdp: sdp }));
       pc._executeNext();
     }.bind(this));
   },
 
   onCreateAnswerError: function(code, message) {
-    this._dompc.callCB(this._dompc._onCreateAnswerFailure,
-                       this.newError(code, message));
+    this._dompc._onCreateAnswerFailure(this.newError(code, message));
     this._dompc._executeNext();
   },
 
   onSetLocalDescriptionSuccess: function() {
-    this._dompc.callCB(this._dompc._onSetLocalDescriptionSuccess);
+    this._dompc._onSetLocalDescriptionSuccess();
     this._dompc._executeNext();
   },
 
   onSetRemoteDescriptionSuccess: function() {
     // This function calls _executeNext() for us
     this._dompc._onSetRemoteDescriptionSuccess();
   },
 
   onSetLocalDescriptionError: function(code, message) {
     this._localType = null;
-    this._dompc.callCB(this._dompc._onSetLocalDescriptionFailure,
-                       this.newError(code, message));
+    this._dompc._onSetLocalDescriptionFailure(this.newError(code, message));
     this._dompc._executeNext();
   },
 
   onSetRemoteDescriptionError: function(code, message) {
     this._remoteType = null;
-    this._dompc.callCB(this._dompc._onSetRemoteDescriptionFailure,
-                       this.newError(code, message));
+    this._dompc._onSetRemoteDescriptionFailure(this.newError(code, message));
     this._dompc._executeNext();
   },
 
   onAddIceCandidateSuccess: function() {
-    this._dompc.callCB(this._dompc._onAddIceCandidateSuccess);
+    this._dompc._onAddIceCandidateSuccess();
     this._dompc._executeNext();
   },
 
   onAddIceCandidateError: function(code, message) {
-    this._dompc.callCB(this._dompc._onAddIceCandidateError,
-                       this.newError(code, message));
+    this._dompc._onAddIceCandidateError(this.newError(code, message));
     this._dompc._executeNext();
   },
 
   onIceCandidate: function(level, mid, candidate) {
     if (candidate == "") {
       this.foundIceCandidate(null);
     } else {
       this.foundIceCandidate(new this._dompc._win.mozRTCIceCandidate(
@@ -1348,61 +1327,60 @@ PeerConnectionObserver.prototype = {
     }
   },
 
   onGetStatsSuccess: function(dict) {
     let chromeobj = new RTCStatsReport(this._dompc._win, dict);
     let webidlobj = this._dompc._win.RTCStatsReport._create(this._dompc._win,
                                                             chromeobj);
     chromeobj.makeStatsPublic();
-    this._dompc.callCB(this._dompc._onGetStatsSuccess, webidlobj);
+    this._dompc._onGetStatsSuccess(webidlobj);
     this._dompc._executeNext();
   },
 
   onGetStatsError: function(code, message) {
-    this._dompc.callCB(this._dompc._onGetStatsFailure,
-                       this.newError(code, message));
+    this._dompc._onGetStatsFailure(this.newError(code, message));
     this._dompc._executeNext();
   },
 
   onAddStream: function(stream) {
     let ev = new this._dompc._win.MediaStreamEvent("addstream",
                                                    { stream: stream });
-    this._dompc.dispatchEvent(ev);
+    this.dispatchEvent(ev);
   },
 
   onRemoveStream: function(stream, type) {
     this.dispatchEvent(new this._dompc._win.MediaStreamEvent("removestream",
                                                              { stream: stream }));
   },
 
   onAddTrack: function(track) {
     let ev = new this._dompc._win.MediaStreamTrackEvent("addtrack",
                                                         { track: track });
-    this._dompc.dispatchEvent(ev);
+    this.dispatchEvent(ev);
   },
 
   onRemoveTrack: function(track, type) {
     this.dispatchEvent(new this._dompc._win.MediaStreamTrackEvent("removetrack",
                                                                   { track: track }));
   },
 
   onReplaceTrackSuccess: function() {
     var pc = this._dompc;
     pc._onReplaceTrackSender.track = pc._onReplaceTrackWithTrack;
     pc._onReplaceTrackWithTrack = null;
     pc._onReplaceTrackSender = null;
-    pc.callCB(pc._onReplaceTrackSuccess);
+    pc._onReplaceTrackSuccess();
   },
 
   onReplaceTrackError: function(code, message) {
     var pc = this._dompc;
     pc._onReplaceTrackWithTrack = null;
     pc._onReplaceTrackSender = null;
-    pc.callCB(pc._onReplaceTrackError, this.newError(code, message));
+    pc._onReplaceTrackError(this.newError(code, message));
   },
 
   foundIceCandidate: function(cand) {
     this.dispatchEvent(new this._dompc._win.RTCPeerConnectionIceEvent("icecandidate",
                                                                       { candidate: cand } ));
   },
 
   notifyDataChannel: function(channel) {