Bug 1323095 - Add deprecation warnings to callback-based pc.getStats + fix w3c link. r=drno
authorJan-Ivar Bruaroey <jib@mozilla.com>
Mon, 12 Dec 2016 19:17:38 -0500
changeset 325778 747abcc62ca484e38862e14252b7bdf4dad98763
parent 325777 c189d68fb575d345bc45b845bee1b98a068ae0ec
child 325779 0032dbb192845302676a49e6decc4fea0948e24a
push id84796
push userphilringnalda@gmail.com
push dateWed, 14 Dec 2016 03:30:34 +0000
treeherdermozilla-inbound@896c2e219086 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdrno
bugs1323095
milestone53.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 1323095 - Add deprecation warnings to callback-based pc.getStats + fix w3c link. r=drno MozReview-Commit-ID: TlVLuZDadN
dom/media/PeerConnection.js
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -437,17 +437,21 @@ RTCPeerConnection.prototype = {
     this.__DOM_IMPL__._innerObject = this;
     this._observer = new this._win.PeerConnectionObserver(this.__DOM_IMPL__);
 
     var location = "" + this._win.location;
 
     // Warn just once per PeerConnection about deprecated getStats usage.
     this._warnDeprecatedStatsAccessNullable = { warn: () =>
       this.logWarning("non-maplike pc.getStats access is deprecated! " +
-                      "See http://w3c.github.io/webrtc-pc/#example for usage.") };
+                      "See http://w3c.github.io/webrtc-pc/#getstats-example for usage.") };
+
+    this._warnDeprecatedStatsCallbacksNullable = { warn: () =>
+      this.logWarning("Callback-based pc.getStats is deprecated! Use promise-version! " +
+                      "See http://w3c.github.io/webrtc-pc/#getstats-example for usage.") };
 
     // Add a reference to the PeerConnection to global list (before init).
     _globalPCList.addPC(this);
 
     this._impl.initialize(this._observer, this._win, rtcConfig,
                           Services.tm.currentThread);
 
     this._certificateReady = this._initCertificate(rtcConfig.certificates);
@@ -1208,16 +1212,21 @@ RTCPeerConnection.prototype = {
 
   changeIceConnectionState: function(state) {
     this._iceConnectionState = state;
     _globalPCList.notifyLifecycleObservers(this, "iceconnectionstatechange");
     this.dispatchEvent(new this._win.Event("iceconnectionstatechange"));
   },
 
   getStats: function(selector, onSucc, onErr) {
+    if (typeof onSucc == "function" &&
+        this._warnDeprecatedStatsCallbacksNullable.warn) {
+      this._warnDeprecatedStatsCallbacksNullable.warn();
+      this._warnDeprecatedStatsCallbacksNullable.warn = null;
+    }
     return this._auto(onSucc, onErr, () => this._getStats(selector));
   },
 
   _getStats: async function(selector) {
     // getStats is allowed even in closed state.
     return await this._chain(() => new Promise((resolve, reject) => {
       this._onGetStatsSuccess = resolve;
       this._onGetStatsFailure = reject;
@@ -1485,17 +1494,18 @@ PeerConnectionObserver.prototype = {
         break;
     }
   },
 
   onGetStatsSuccess: function(dict) {
     let pc = this._dompc;
     let chromeobj = new RTCStatsReport(pc._win, dict);
     let webidlobj = pc._win.RTCStatsReport._create(pc._win, chromeobj);
-    chromeobj.makeStatsPublic(pc._warnDeprecatedStatsAccessNullable);
+    chromeobj.makeStatsPublic(pc._warnDeprecatedStatsCallbacksNullable &&
+                              pc._warnDeprecatedStatsAccessNullable);
     pc._onGetStatsSuccess(webidlobj);
   },
 
   onGetStatsError: function(code, message) {
     this._dompc._onGetStatsFailure(this.newError(message, code));
   },
 
   onAddStream: function(stream) {