Bug 1365635 - Fix payload queue and damp regression r?honza
MozReview-Commit-ID: 4mW6pH2CeQN
--- a/devtools/client/netmonitor/src/connector/firefox-connector.js
+++ b/devtools/client/netmonitor/src/connector/firefox-connector.js
@@ -8,16 +8,20 @@ const Services = require("Services");
const { CurlUtils } = require("devtools/client/shared/curl");
const { TimelineFront } = require("devtools/shared/fronts/timeline");
const { ACTIVITY_TYPE, EVENTS } = require("../constants");
const { getDisplayedRequestById } = require("../selectors/index");
const { fetchHeaders, formDataURI } = require("../utils/request-utils");
class FirefoxConnector {
constructor() {
+ // Internal properties
+ this.payloadQueue = [];
+
+ // Public methods
this.connect = this.connect.bind(this);
this.disconnect = this.disconnect.bind(this);
this.willNavigate = this.willNavigate.bind(this);
this.displayCachedEvents = this.displayCachedEvents.bind(this);
this.onDocLoadingMarker = this.onDocLoadingMarker.bind(this);
this.addRequest = this.addRequest.bind(this);
this.updateRequest = this.updateRequest.bind(this);
this.fetchImage = this.fetchImage.bind(this);
@@ -50,17 +54,17 @@ class FirefoxConnector {
this.onResponseContent = this.onResponseContent.bind(this);
this.onEventTimings = this.onEventTimings.bind(this);
}
async connect(connection, actions, getState) {
this.actions = actions;
this.getState = getState;
this.tabTarget = connection.tabConnection.tabTarget;
- this.tabClient = this.tabTarget.isTabActor ? this.tabTarget.activeTab : null;
+
this.webConsoleClient = this.tabTarget.activeConsole;
this.tabTarget.on("will-navigate", this.willNavigate);
this.tabTarget.on("close", this.disconnect);
this.webConsoleClient.on("networkEvent", this.onNetworkEvent);
this.webConsoleClient.on("networkEventUpdate", this.onNetworkEventUpdate);
// Don't start up waiting for timeline markers if the server isn't
@@ -70,28 +74,32 @@ class FirefoxConnector {
this.timelineFront.on("doc-loading", this.onDocLoadingMarker);
await this.timelineFront.start({ withDocLoadingEvents: true });
}
this.displayCachedEvents();
}
async disconnect() {
- // When debugging local or a remote instance, the connection is closed by
- // the RemoteTarget. The webconsole actor is stopped on disconnect.
- this.tabClient = null;
- this.webConsoleClient = null;
+ this.actions.batchReset();
// The timeline front wasn't initialized and started if the server wasn't
// recent enough to emit the markers we were interested in.
if (this.tabTarget.getTrait("documentLoadingMarkers") && this.timelineFront) {
this.timelineFront.off("doc-loading", this.onDocLoadingMarker);
await this.timelineFront.destroy();
- this.timelineFront = null;
}
+
+ this.tabTarget.off("will-navigate");
+ this.tabTarget.off("close");
+ this.tabTarget = null;
+ this.webConsoleClient.off("networkEvent");
+ this.webConsoleClient.off("networkEventUpdate");
+ this.webConsoleClient = null;
+ this.timelineFront = null;
}
willNavigate() {
if (!Services.prefs.getBoolPref("devtools.webconsole.persistlog")) {
this.actions.batchReset();
this.actions.clearRequests();
} else {
// If the log is persistent, just clear all accumulated timing markers.
@@ -192,17 +200,22 @@ class FirefoxConnector {
this.fetchPostData(requestPostData),
this.fetchRequestCookies(requestCookies),
this.fetchResponseCookies(responseCookies),
]);
let payload = Object.assign({}, data,
imageObj, requestHeadersObj, responseHeadersObj,
postDataObj, requestCookiesObj, responseCookiesObj);
- await this.actions.updateRequest(id, payload, true);
+
+ this.pushPayloadToQueue(id, payload);
+
+ if (this.isQueuePayloadReady(id)) {
+ await this.actions.updateRequest(id, this.getPayloadFromQueue(id).payload, true);
+ }
}
async fetchImage(mimeType, responseContent) {
let payload = {};
if (mimeType && responseContent && responseContent.content) {
let { encoding, text } = responseContent.content;
let response = await this.getLongString(text);