Bug 1434855 - Refactor HAR builder options; r=ochameau

MozReview-Commit-ID: FRcxp4XPFdf

--HG--
extra : rebase_source : 4b88ddf3b5c14b0d9f1cb8f71018cd556ebbe353
This commit is contained in:
Jan Odvarko 2018-03-08 10:07:45 +01:00
parent 70a3b5a0c6
commit da22fde827
3 changed files with 23 additions and 31 deletions

View File

@ -105,21 +105,11 @@ window.Netmonitor = {
*/
getHar() {
let { HarExporter } = require("devtools/client/netmonitor/src/har/har-exporter");
let {
getLongString,
getTabTarget,
getTimingMarker,
requestData,
} = connector;
let { form: { title, url } } = getTabTarget();
let state = store.getState();
let options = {
getString: getLongString,
connector,
items: getSortedRequests(state),
requestData,
getTimingMarker,
title: title || url,
};
return HarExporter.getHar(options);
@ -136,13 +126,8 @@ window.Netmonitor = {
}
let { HarExporter } = require("devtools/client/netmonitor/src/har/har-exporter");
let { getLongString, getTabTarget, requestData } = connector;
let { form: { title, url } } = getTabTarget();
let options = {
getString: getLongString,
requestData,
title: title || url,
connector,
includeResponseBodies: false,
items: [getDisplayedRequestById(store.getState(), requestId)],
};

View File

@ -186,10 +186,28 @@ const HarExporter = {
* since it can involve additional RDP communication (e.g. resolving
* long strings).
*/
buildHarData: function (options) {
buildHarData: async function (options) {
let { connector } = options;
let {
getTabTarget,
} = connector;
let {
form: { title, url }
} = getTabTarget();
options = {
...options,
title: title || url,
getString: connector.getLongString,
getTimingMarker: connector.getTimingMarker,
requestData: connector.requestData,
};
// Build HAR object from collected data.
let builder = new HarBuilder(options);
return builder.build();
let result = await builder.build();
return result;
},
/**

View File

@ -409,20 +409,9 @@ class RequestListContextMenu {
}
getDefaultHarOptions(sortedRequests) {
let {
getLongString,
getTabTarget,
requestData,
getTimingMarker,
} = this.props.connector;
let { form: { title, url } } = getTabTarget();
return {
getString: getLongString,
connector: this.props.connector,
items: sortedRequests,
requestData,
getTimingMarker,
title: title || url,
};
}
}