Bug 913260 (part 1) - Simplify TelemetryPing.js a little. r=nfroyd.

--HG--
extra : rebase_source : 0c7e18e269a49ca6dc79623ebc370a6c8440a663
This commit is contained in:
Nicholas Nethercote 2013-09-17 19:28:56 -07:00
parent 3383f63348
commit da1fae2328

View File

@ -344,15 +344,6 @@ TelemetryPing.prototype = {
return ret;
},
addValue: function addValue(name, id, val) {
let h = this._histograms[name];
if (!h) {
h = Telemetry.getHistogramById(id);
this._histograms[name] = h;
}
h.add(val);
},
/**
* Descriptive metadata
*
@ -477,7 +468,7 @@ TelemetryPing.prototype = {
function h(process, path, kind, units, amount, desc) {
if (!hasReported) {
boundHandleMemoryReport(id, path, units, amount);
boundHandleMemoryReport(id, units, amount);
hasReported = true;
} else {
NS_ASSERT(false,
@ -492,7 +483,7 @@ TelemetryPing.prototype = {
histogram.add(new Date() - startTime);
},
handleMemoryReport: function(id, path, units, amount) {
handleMemoryReport: function(id, units, amount) {
let val;
if (units == Ci.nsIMemoryReporter.UNITS_BYTES) {
val = Math.floor(amount / 1024);
@ -508,23 +499,28 @@ TelemetryPing.prototype = {
// If the reporter gives us a cumulative count, we'll report the
// difference in its value between now and our previous ping.
if (!(path in this._prevValues)) {
if (!(id in this._prevValues)) {
// If this is the first time we're reading this reporter, store its
// current value but don't report it in the telemetry ping, so we
// ignore the effect startup had on the reporter.
this._prevValues[path] = amount;
this._prevValues[id] = amount;
return;
}
val = amount - this._prevValues[path];
this._prevValues[path] = amount;
val = amount - this._prevValues[id];
this._prevValues[id] = amount;
}
else {
NS_ASSERT(false, "Can't handle memory reporter with units " + units);
return;
}
this.addValue(path, id, val);
let h = this._histograms[id];
if (!h) {
h = Telemetry.getHistogramById(id);
this._histograms[id] = h;
}
h.add(val);
},
/**