Bug 1115976 - Restore download progress when using netmonitor. r=vporof
authorJ. Ryan Stinnett <jryans@gmail.com>
Fri, 02 Jan 2015 12:06:12 -0600
changeset 247677 d5a6e28f71322f7f40a90021787f16f3a70ff4d2
parent 247676 9198ef9c7df6797d1c393227d0c219ccacb36260
child 247678 7f82e95ceb0571889d9db76513c4a19aab63e2ba
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvporof
bugs1115976
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 1115976 - Restore download progress when using netmonitor. r=vporof
toolkit/devtools/webconsole/network-monitor.js
--- a/toolkit/devtools/webconsole/network-monitor.js
+++ b/toolkit/devtools/webconsole/network-monitor.js
@@ -81,16 +81,30 @@ NetworkResponseListener.prototype = {
     }
     if (this._wrappedNotificationCallbacks) {
       return this._wrappedNotificationCallbacks.getInterface(iid);
     }
     throw Cr.NS_ERROR_NO_INTERFACE;
   },
 
   /**
+   * Forward notifications for interfaces this object implements, in case other
+   * objects also implemented them.
+   */
+  _forwardNotification(iid, method, args) {
+    if (!this._wrappedNotificationCallbacks) {
+      return;
+    }
+    try {
+      let impl = this._wrappedNotificationCallbacks.getInterface(iid);
+      impl[method].apply(impl, args);
+    } catch(e if e.result == Cr.NS_ERROR_NO_INTERFACE) {}
+  },
+
+  /**
    * This NetworkResponseListener tracks the NetworkMonitor.openResponses object
    * to find the associated uncached headers.
    * @private
    */
   _foundOpenResponse: false,
 
   /**
    * If the channel already had notificationCallbacks, hold them here internally
@@ -211,19 +225,24 @@ NetworkResponseListener.prototype = {
   // nsIProgressEventSink implementation
 
   /**
    * Handle progress event as data is transferred.  This is used to record the
    * size on the wire, which may be compressed / encoded.
    */
   onProgress: function(request, context, progress, progressMax) {
     this.transferredSize = progress;
+    // Need to forward as well to keep things like Download Manager's progress
+    // bar working properly.
+    this._forwardNotification(Ci.nsIProgressEventSink, 'onProgress', arguments);
   },
 
-  onStatus: function () {},
+  onStatus: function () {
+    this._forwardNotification(Ci.nsIProgressEventSink, 'onStatus', arguments);
+  },
 
   /**
    * Find the open response object associated to the current request. The
    * NetworkMonitor._httpResponseExaminer() method saves the response headers in
    * NetworkMonitor.openResponses. This method takes the data from the open
    * response object and puts it into the HTTP activity object, then sends it to
    * the remote Web Console instance.
    *