Bug 1404917 - 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 675599 2f29937c190c7f5e8937b7fe29ae2b02e96079af
parent 675598 bd62a4afa17f381d7dbe4625d9698639e15d6b79
child 734650 81d90ac2c3d92c64fb18f976263896e5bfd688ef
push id83180
push userbmo:poirot.alex@gmail.com
push dateThu, 05 Oct 2017 15:54:09 +0000
bugs1404917
milestone58.0a1
Bug 1404917 - 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;