Bug 1406314 - Prevent multiple response content copies in parent and in content processes. draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Thu, 05 Oct 2017 17:12:00 +0200
changeset 675937 1a6c814229585568bd2dd064544944fbc2ca9c39
parent 675604 c7a59ff43a02fe442214471c2ff5e1cc4895c5f6
child 734770 a35f496abd36dbe5caadf06f4a3889838a5f59e1
push id83308
push userbmo:poirot.alex@gmail.com
push dateFri, 06 Oct 2017 08:19:47 +0000
bugs1406314
milestone58.0a1
Bug 1406314 - Prevent multiple response content copies in parent and in content processes. MozReview-Commit-ID: FwTEmQ13IgJ
devtools/client/netmonitor/src/connector/firefox-data-provider.js
devtools/shared/webconsole/network-monitor.js
--- a/devtools/client/netmonitor/src/connector/firefox-data-provider.js
+++ b/devtools/client/netmonitor/src/connector/firefox-data-provider.js
@@ -1,15 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 /* eslint-disable block-scoped-var */
 
 "use strict";
 
+const Services = require("Services");
 const { EVENTS } = require("../constants");
 const { CurlUtils } = require("devtools/client/shared/curl");
 const { fetchHeaders, formDataURI } = require("../utils/request-utils");
 
 /**
  * This object is responsible for fetching additional HTTP
  * data from the backend.
  */
@@ -322,17 +323,22 @@ class FirefoxDataProvider {
     // in case this method is called multiple times in a raw.
     if (this.pendingResponseContentRequests.has(id)) {
       return this.pendingResponseContentRequests.get(id);
     }
     let promise = this.webConsoleClient.getResponseContent(id)
       .then(async response => {
         let { mimeType } = response.content;
         let { encoding, text } = response.content;
-        let textString = await this.getLongString(text);
+        let textString;
+        if (typeof(text) == "number") {
+          textString = Services.responses[text];
+        } else {
+          textString = await this.getLongString(text);
+        }
 
         let data = {
           content: {
             encoding,
             mimeType,
             text: textString,
           },
         };
--- a/devtools/shared/webconsole/network-monitor.js
+++ b/devtools/shared/webconsole/network-monitor.js
@@ -612,16 +612,25 @@ NetworkResponseListener.prototype = {
     }
 
     if (response.mimeType && this.request.contentCharset) {
       response.mimeType += "; charset=" + this.request.contentCharset;
     }
 
     this.receivedData = "";
 
+    if (!Services.responses) {
+      Services.responses = [];
+    }
+
+    Services.responses.push(response.text);
+    dump("push("+(Services.responses.length-1)+" - "+response.text.substr(0, 10)+"\n");
+    response.text = Services.responses.length - 1;
+
+
     this.httpActivity.owner.addResponseContent(
       response,
       this.httpActivity.discardResponseBody
     );
 
     this._wrappedNotificationCallbacks = null;
     this.httpActivity = null;
     this.sink = null;