Bug 1261585 - Necko does content conversions for TracableChannel so devtool does not need to do it separately. r=ochameau
☠☠ backed out by 9521a6247d94 ☠ ☠
authorDragana Damjanovic <dd.mozilla@gmail.com>
Tue, 20 Dec 2016 06:45:00 -0500
changeset 343916 92de31554a9f5c5da8bc36fa06b85e215a45220f
parent 343915 13d5c32e4a61b1fec4669b80aefb801a9e5cb968
child 343917 16d6554c9c5b073c0a32db7ca72a30fee173794b
push id31391
push userphilringnalda@gmail.com
push dateTue, 21 Feb 2017 04:29:09 +0000
treeherdermozilla-central@d84beb192e57 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1261585
milestone54.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 1261585 - Necko does content conversions for TracableChannel so devtool does not need to do it separately. r=ochameau
devtools/shared/webconsole/network-monitor.js
--- a/devtools/shared/webconsole/network-monitor.js
+++ b/devtools/shared/webconsole/network-monitor.js
@@ -422,58 +422,19 @@ NetworkResponseListener.prototype = {
   /**
    * See documentation at
    * https://developer.mozilla.org/En/NsIRequestObserver
    *
    * @param nsIRequest request
    * @param nsISupports context
    */
   onStartRequest: function (request) {
-    // Converter will call this again, we should just ignore that.
-    if (this.request) {
-      return;
-    }
-
     this.request = request;
     this._getSecurityInfo();
     this._findOpenResponse();
-    // We need to track the offset for the onDataAvailable calls where
-    // we pass the data from our pipe to the converter.
-    this.offset = 0;
-
-    // In the multi-process mode, the conversion happens on the child
-    // side while we can only monitor the channel on the parent
-    // side. If the content is gzipped, we have to unzip it
-    // ourself. For that we use the stream converter services.  Do not
-    // do that for Service workers as they are run in the child
-    // process.
-    let channel = this.request;
-    if (!this.httpActivity.fromServiceWorker &&
-        channel instanceof Ci.nsIEncodedChannel &&
-        channel.contentEncodings &&
-        !channel.applyConversion) {
-      let encodingHeader = channel.getResponseHeader("Content-Encoding");
-      let scs = Cc["@mozilla.org/streamConverters;1"]
-        .getService(Ci.nsIStreamConverterService);
-      let encodings = encodingHeader.split(/\s*\t*,\s*\t*/);
-      let nextListener = this;
-      let acceptedEncodings = ["gzip", "deflate", "br", "x-gzip", "x-deflate"];
-      for (let i in encodings) {
-        // There can be multiple conversions applied
-        let enc = encodings[i].toLowerCase();
-        if (acceptedEncodings.indexOf(enc) > -1) {
-          this.converter = scs.asyncConvertData(enc, "uncompressed",
-                                                nextListener, null);
-          nextListener = this.converter;
-        }
-      }
-      if (this.converter) {
-        this.converter.onStartRequest(this.request, null);
-      }
-    }
     // Asynchronously wait for the data coming from the request.
     this.setAsyncListener(this.sink.inputStream, this);
   },
 
   /**
    * Parse security state of this request and report it to the client.
    */
   _getSecurityInfo: DevToolsUtils.makeInfallible(function () {
@@ -629,17 +590,16 @@ NetworkResponseListener.prototype = {
       response,
       this.httpActivity.discardResponseBody
     );
 
     this._wrappedNotificationCallbacks = null;
     this.httpActivity = null;
     this.sink = null;
     this.inputStream = null;
-    this.converter = null;
     this.request = null;
     this.owner = null;
   },
 
   /**
    * The nsIInputStreamCallback for when the request input stream is ready -
    * either it has more data or it is closed.
    *
@@ -657,25 +617,21 @@ NetworkResponseListener.prototype = {
       // This may throw if the stream is closed normally or due to an error.
       available = stream.available();
     } catch (ex) {
       // Ignore.
     }
 
     if (available != -1) {
       if (available != 0) {
-        if (this.converter) {
-          this.converter.onDataAvailable(this.request, null, stream,
-                                         this.offset, available);
-        } else {
-          this.onDataAvailable(this.request, null, stream, this.offset,
-                               available);
-        }
+        // Note that passing 0 as the offset here is wrong, but the
+        // onDataAvailable() method does not use the offset, so it does not
+        // matter.
+        this.onDataAvailable(this.request, null, stream, 0, available);
       }
-      this.offset += available;
       this.setAsyncListener(stream, this);
     } else {
       this.onStreamClose();
       this.offset = 0;
     }
   },
 };