--- a/devtools/client/netmonitor/src/connector/firefox-data-provider.js
+++ b/devtools/client/netmonitor/src/connector/firefox-data-provider.js
@@ -68,22 +68,22 @@ class FirefoxDataProvider {
true,
);
}
emit(EVENTS.REQUEST_ADDED, id);
}
/**
- * Update a network request if it already exists in application state.
+ * Update a network request and push to a request queue.
*
* @param {string} id request id
* @param {object} data data payload will be updated to application state
*/
- async updateRequest(id, data) {
+ async updateRequestInQueue(id, data) {
let {
mimeType,
responseContent,
responseCookies,
responseHeaders,
requestCookies,
requestHeaders,
requestPostData,
@@ -311,16 +311,17 @@ class FirefoxDataProvider {
request: {
method,
url,
},
startedDateTime,
} = networkInfo;
// Create tracking record for this request.
+ // Untracked events are optional events
this.rdpRequestMap.set(actor, {
requestHeaders: false,
requestCookies: false,
eventTimings: false,
responseContent: false,
});
this.addRequest(actor, {
@@ -366,24 +367,25 @@ class FirefoxDataProvider {
case "requestPostData":
this.requestData(actor, updateType).then(response => {
this.onRequestPostData(response)
.then(() => this.onDataReceived(actor, updateType));
emit(EVENTS.UPDATING_REQUEST_POST_DATA, actor);
});
break;
case "securityInfo":
- this.updateRequest(actor, {
- securityState: networkInfo.securityInfo,
- }).then(() => {
- this.requestData(actor, updateType).then(response => {
- this.onSecurityInfo(response)
- .then(() => this.onDataReceived(actor, updateType));
- emit(EVENTS.UPDATING_SECURITY_INFO, actor);
- });
+ this.requestData(actor, updateType).then(response => {
+ this.onSecurityInfo(response)
+ .then(() => {
+ this.pushRequestToQueue(actor, {
+ securityState: networkInfo.securityInfo,
+ });
+ this.onDataReceived(actor, updateType);
+ });
+ emit(EVENTS.UPDATING_SECURITY_INFO, actor);
});
break;
case "responseHeaders":
this.requestData(actor, updateType).then(response => {
this.onResponseHeaders(response)
.then(() => this.onDataReceived(actor, updateType));
emit(EVENTS.UPDATING_RESPONSE_HEADERS, actor);
});
@@ -391,17 +393,17 @@ class FirefoxDataProvider {
case "responseCookies":
this.requestData(actor, updateType).then(response => {
this.onResponseCookies(response)
.then(() => this.onDataReceived(actor, updateType));
emit(EVENTS.UPDATING_RESPONSE_COOKIES, actor);
});
break;
case "responseStart":
- this.updateRequest(actor, {
+ this.updateRequestInQueue(actor, {
httpVersion: networkInfo.response.httpVersion,
remoteAddress: networkInfo.response.remoteAddress,
remotePort: networkInfo.response.remotePort,
status: networkInfo.response.status,
statusText: networkInfo.response.statusText,
headersSize: networkInfo.response.headersSize
}).then(() => {
emit(EVENTS.STARTED_RECEIVING_RESPONSE, actor);
@@ -413,24 +415,26 @@ class FirefoxDataProvider {
contentSize: networkInfo.response.bodySize,
transferredSize: networkInfo.response.transferredSize,
mimeType: networkInfo.response.content.mimeType
}, response).then(() => this.onDataReceived(actor, updateType));
emit(EVENTS.UPDATING_RESPONSE_CONTENT, actor);
});
break;
case "eventTimings":
- this.updateRequest(actor, { totalTime: networkInfo.totalTime })
- .then(() => {
- this.requestData(actor, updateType).then(response => {
- this.onEventTimings(response)
- .then(() => this.onDataReceived(actor, updateType));
- emit(EVENTS.UPDATING_EVENT_TIMINGS, actor);
+ this.requestData(actor, updateType).then(response => {
+ this.onEventTimings(response)
+ .then(() => {
+ this.pushRequestToQueue(actor, {
+ totalTime: networkInfo.totalTime,
+ });
+ this.onDataReceived(actor, updateType);
});
- });
+ emit(EVENTS.UPDATING_EVENT_TIMINGS, actor);
+ });
break;
}
emit(EVENTS.NETWORK_EVENT_UPDATED, actor);
}
/**
* Wrapper method for requesting HTTP details data from the backend.
@@ -509,108 +513,108 @@ class FirefoxDataProvider {
}
/**
* Handles additional information received for a "requestHeaders" packet.
*
* @param {object} response the message received from the server.
*/
onRequestHeaders(response) {
- return this.updateRequest(response.from, {
+ return this.updateRequestInQueue(response.from, {
requestHeaders: response
}).then(() => {
emit(EVENTS.RECEIVED_REQUEST_HEADERS, response.from);
});
}
/**
* Handles additional information received for a "requestCookies" packet.
*
* @param {object} response the message received from the server.
*/
onRequestCookies(response) {
- return this.updateRequest(response.from, {
+ return this.updateRequestInQueue(response.from, {
requestCookies: response
}).then(() => {
emit(EVENTS.RECEIVED_REQUEST_COOKIES, response.from);
});
}
/**
* Handles additional information received for a "requestPostData" packet.
*
* @param {object} response the message received from the server.
*/
onRequestPostData(response) {
- return this.updateRequest(response.from, {
+ return this.updateRequestInQueue(response.from, {
requestPostData: response
}).then(() => {
emit(EVENTS.RECEIVED_REQUEST_POST_DATA, response.from);
});
}
/**
* Handles additional information received for a "securityInfo" packet.
*
* @param {object} response the message received from the server.
*/
onSecurityInfo(response) {
- return this.updateRequest(response.from, {
+ return this.updateRequestInQueue(response.from, {
securityInfo: response.securityInfo
}).then(() => {
emit(EVENTS.RECEIVED_SECURITY_INFO, response.from);
});
}
/**
* Handles additional information received for a "responseHeaders" packet.
*
* @param {object} response the message received from the server.
*/
onResponseHeaders(response) {
- return this.updateRequest(response.from, {
+ return this.updateRequestInQueue(response.from, {
responseHeaders: response
}).then(() => {
emit(EVENTS.RECEIVED_RESPONSE_HEADERS, response.from);
});
}
/**
* Handles additional information received for a "responseCookies" packet.
*
* @param {object} response the message received from the server.
*/
onResponseCookies(response) {
- return this.updateRequest(response.from, {
+ return this.updateRequestInQueue(response.from, {
responseCookies: response
}).then(() => {
emit(EVENTS.RECEIVED_RESPONSE_COOKIES, response.from);
});
}
/**
* Handles additional information received for a "responseContent" packet.
*
* @param {object} data the message received from the server event.
* @param {object} response the message received from the server.
*/
onResponseContent(data, response) {
let payload = Object.assign({ responseContent: response }, data);
- return this.updateRequest(response.from, payload).then(() => {
+ return this.updateRequestInQueue(response.from, payload).then(() => {
emit(EVENTS.RECEIVED_RESPONSE_CONTENT, response.from);
});
}
/**
* Handles additional information received for a "eventTimings" packet.
*
* @param {object} response the message received from the server.
*/
onEventTimings(response) {
- return this.updateRequest(response.from, {
+ return this.updateRequestInQueue(response.from, {
eventTimings: response
}).then(() => {
emit(EVENTS.RECEIVED_EVENT_TIMINGS, response.from);
});
}
}
/**