Bug 1320671 - Add total transferred size to the network perf analysis button tooltip. r?
MozReview-Commit-ID: 6bxGVHEbnAb
--- a/devtools/client/locales/en-US/netmonitor.properties
+++ b/devtools/client/locales/en-US/netmonitor.properties
@@ -145,16 +145,23 @@ networkMenu.empty=No requests
# LOCALIZATION NOTE (networkMenu.summary): Semi-colon list of plural forms.
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
# This label is displayed in the network table footer providing concise
# information about all requests. Parameters: #1 is the number of requests,
# #2 is the size, #3 is the number of seconds.
networkMenu.summary=One request, #2 KB, #3 s;#1 requests, #2 KB, #3 s
+# LOCALIZATION NOTE (networkMenu.summaryTitle): Semi-colon list of plural forms.
+# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
+# This title is displayed in the network table footer providing concise
+# information about all requests. Parameters: #1 is the number of requests,
+# #2 is the size, #3 is the transferred size, #4 is the number of seconds.
+networkMenu.summaryTitle=One request, #2 KB, #3 KB transferred, #4 s;#1 requests, #2 KB, #3 KB transferred, #4 s
+
# LOCALIZATION NOTE (networkMenu.sizeB): This is the label displayed
# in the network menu specifying the size of a request (in bytes).
networkMenu.sizeB=%S B
# LOCALIZATION NOTE (networkMenu.sizeKB): This is the label displayed
# in the network menu specifying the size of a request (in kilobytes).
networkMenu.sizeKB=%S KB
--- a/devtools/client/netmonitor/components/summary-button.js
+++ b/devtools/client/netmonitor/components/summary-button.js
@@ -17,27 +17,33 @@ const { L10N } = require("../l10n");
const { getDisplayedRequestsSummary } = require("../selectors/index");
const { button, span } = DOM;
function SummaryButton({
summary,
triggerSummary,
}) {
- let { count, bytes, millis } = summary;
+ let { count, bytes, transferredBytes, millis } = summary;
const text = (count === 0) ? L10N.getStr("networkMenu.empty") :
PluralForm.get(count, L10N.getStr("networkMenu.summary"))
.replace("#1", count)
.replace("#2", L10N.numberWithDecimals(bytes / 1024, CONTENT_SIZE_DECIMALS))
.replace("#3", L10N.numberWithDecimals(millis / 1000, REQUEST_TIME_DECIMALS));
+ const titleText = (count === 0) ? L10N.getStr("networkMenu.empty") :
+ PluralForm.get(count, L10N.getStr("networkMenu.summaryTitle"))
+ .replace("#1", count)
+ .replace("#2", L10N.numberWithDecimals(bytes / 1024, CONTENT_SIZE_DECIMALS))
+ .replace("#3", L10N.numberWithDecimals(transferredBytes / 1024, CONTENT_SIZE_DECIMALS))
+ .replace("#4", L10N.numberWithDecimals(millis / 1000, REQUEST_TIME_DECIMALS));
return button({
id: "requests-menu-network-summary-button",
className: "devtools-button",
- title: count ? text : L10N.getStr("netmonitor.toolbar.perf"),
+ title: count ? titleText : L10N.getStr("netmonitor.toolbar.perf"),
onClick: triggerSummary,
},
span({ className: "summary-info-icon" }),
span({ className: "summary-info-text" }, text));
}
SummaryButton.propTypes = {
summary: PropTypes.object.isRequired,
--- a/devtools/client/netmonitor/selectors/requests.js
+++ b/devtools/client/netmonitor/selectors/requests.js
@@ -80,19 +80,27 @@ const getDisplayedRequestsSummary = crea
const totalBytes = requests.reduce((total, item) => {
if (typeof item.contentSize == "number") {
total += item.contentSize;
}
return total;
}, 0);
+ const totalTransferredBytes = requests.reduce((total, item) => {
+ if (typeof item.transferredSize == "number") {
+ total += item.transferredSize;
+ }
+ return total;
+ }, 0);
+
return {
count: requests.size,
bytes: totalBytes,
+ transferredBytes: totalTransferredBytes,
millis: totalMillis,
};
}
);
function getRequestById(state, id) {
return state.requests.requests.find(r => r.id === id);
}