--- a/toolkit/components/telemetry/TelemetryStopwatch.jsm
+++ b/toolkit/components/telemetry/TelemetryStopwatch.jsm
@@ -163,38 +163,49 @@ this.TelemetryStopwatch = {
*
* @param {String} aHistogram - a string which must be a valid histogram name.
* If an invalid name is given, the function will
* throw.
*
* @param (Object) aObj - Optional parameter which associates the histogram
* timer with the given object.
*
+ * @param {Boolean} aCanceledOkay - Optional parameter which will suppress any
+ * warnings that normally fire when a stopwatch
+ * is finished after being cancelled. Defaults
+ * to false.
+ *
* @returns {Integer} time in milliseconds or -1 if the stopwatch was not
* found.
*/
- timeElapsed(aHistogram, aObj) {
- return TelemetryStopwatchImpl.timeElapsed(aHistogram, aObj, null);
+ timeElapsed(aHistogram, aObj, aCanceledOkay) {
+ return TelemetryStopwatchImpl.timeElapsed(aHistogram, aObj, null,
+ aCanceledOkay);
},
/**
* Stops the timer associated with the given histogram (and object),
* calculates the time delta between start and finish, and adds the value
* to the histogram.
*
* @param {String} aHistogram - a string which must be a valid histogram name.
*
* @param {Object} aObj - Optional parameter which associates the histogram
* timer with the given object.
*
+ * @param {Boolean} aCanceledOkay - Optional parameter which will suppress any
+ * warnings that normally fire when a stopwatch
+ * is finished after being cancelled. Defaults
+ * to false.
+ *
* @returns {Boolean} True if the timer was succesfully stopped and the data
* was added to the histogram, False otherwise.
*/
- finish(aHistogram, aObj) {
- return TelemetryStopwatchImpl.finish(aHistogram, aObj, null);
+ finish(aHistogram, aObj, aCanceledOkay) {
+ return TelemetryStopwatchImpl.finish(aHistogram, aObj, null, aCanceledOkay);
},
/**
* Starts a timer associated with a keyed telemetry histogram. The timer can
* be directly associated with a histogram and its key. Similarly to
* @see{TelemetryStopwatch.stat} the histogram and its key can be associated
* with an object. Each key may have multiple associated objects and each
* object can be associated with multiple keys.
@@ -246,37 +257,43 @@ this.TelemetryStopwatch = {
*
* @param {Object} aObj - Optional parameter. If specified, the timer
* associated with this object is used to calculate
* the elapsed time.
*
* @return {Integer} time in milliseconds or -1 if the stopwatch was not
* found.
*/
- timeElapsedKeyed(aHistogram, aKey, aObj) {
- return TelemetryStopwatchImpl.timeElapsed(aHistogram, aObj, aKey);
+ timeElapsedKeyed(aHistogram, aKey, aObj, aCanceledOkay) {
+ return TelemetryStopwatchImpl.timeElapsed(aHistogram, aObj, aKey,
+ aCanceledOkay);
},
/**
* Stops the timer associated with the given keyed histogram (and object),
* calculates the time delta between start and finish, and adds the value
* to the keyed histogram.
*
* @param {String} aHistogram - a string which must be a valid histogram name.
*
* @param {String} aKey - a string which must be a valid histgram key.
*
* @param {Object} aObj - optional parameter which associates the histogram
* timer with the given object.
*
+ * @param {Boolean} aCanceledOkay - Optional parameter which will suppress any
+ * warnings that normally fire when a stopwatch
+ * is finished after being cancelled. Defaults
+ * to false.
+ *
* @returns {Boolean} True if the timer was succesfully stopped and the data
* was added to the histogram, False otherwise.
*/
- finishKeyed(aHistogram, aKey, aObj) {
- return TelemetryStopwatchImpl.finish(aHistogram, aObj, aKey);
+ finishKeyed(aHistogram, aKey, aObj, aCanceledOkay) {
+ return TelemetryStopwatchImpl.finish(aHistogram, aObj, aKey, aCanceledOkay);
}
};
this.TelemetryStopwatchImpl = {
start(histogram, object, key) {
if (Timers.has(histogram, object, key)) {
Timers.delete(histogram, object, key);
Cu.reportError(`TelemetryStopwatch: key "${histogram}" was already ` +
@@ -286,38 +303,40 @@ this.TelemetryStopwatchImpl = {
return Timers.put(histogram, object, key, Components.utils.now());
},
cancel(histogram, object, key) {
return Timers.delete(histogram, object, key);
},
- timeElapsed(histogram, object, key) {
+ timeElapsed(histogram, object, key, aCanceledOkay) {
let startTime = Timers.get(histogram, object, key);
if (startTime === null) {
- Cu.reportError("TelemetryStopwatch: requesting elapsed time for " +
- `nonexisting stopwatch. Histogram: "${histogram}", ` +
- `key: "${key}"`);
+ if (!aCanceledOkay) {
+ Cu.reportError("TelemetryStopwatch: requesting elapsed time for " +
+ `nonexisting stopwatch. Histogram: "${histogram}", ` +
+ `key: "${key}"`);
+ }
return -1;
}
try {
let delta = Components.utils.now() - startTime
return Math.round(delta);
} catch (e) {
Cu.reportError("TelemetryStopwatch: failed to calculate elapsed time " +
`for Histogram: "${histogram}", key: "${key}", ` +
`exception: ${Log.exceptionStr(e)}`);
return -1;
}
},
- finish(histogram, object, key) {
- let delta = this.timeElapsed(histogram, object, key);
+ finish(histogram, object, key, aCanceledOkay) {
+ let delta = this.timeElapsed(histogram, object, key, aCanceledOkay);
if (delta == -1) {
return false;
}
try {
if (key) {
Telemetry.getKeyedHistogramById(histogram).add(key, delta);
} else {