Bug 1013601 - Part 1: Add uptimeMillis() to UITelemetry.jsm. r=rnewman

This commit is contained in:
Chenxia Liu 2014-05-21 11:24:17 -07:00
parent a945a0b9c4
commit 13afe3aeb4

View File

@ -84,6 +84,15 @@ this.UITelemetry = {
*/
_simpleMeasureFunctions: {},
/**
* A hack to generate the relative timestamp from start when we don't have
* access to the Java timer.
* XXX: Bug 1007647 - Support realtime and/or uptime in JavaScript.
*/
uptimeMillis: function() {
return Date.now() - Services.startup.getStartupInfo().process;
},
/**
* Adds a single event described by a timestamp, an action, and the calling
* method.
@ -104,7 +113,7 @@ this.UITelemetry = {
action: aAction,
method: aMethod,
sessions: sessions,
timestamp: aTimestamp,
timestamp: (aTimestamp == undefined) ? this.uptimeMillis() : aTimestamp,
};
if (aExtras) {
@ -126,7 +135,7 @@ this.UITelemetry = {
// Do not overwrite a previous event start if it already exists.
return;
}
this._activeSessions[aName] = aTimestamp;
this._activeSessions[aName] = (aTimestamp == undefined) ? this.uptimeMillis() : aTimestamp;
},
/**
@ -149,7 +158,7 @@ this.UITelemetry = {
name: aName,
reason: aReason,
start: sessionStart,
end: aTimestamp,
end: (aTimestamp == undefined) ? this.uptimeMillis() : aTimestamp,
};
this._recordEvent(aEvent);