Bug 1305444 - Move telemetry assignment, remove variable use; r?Yoric
We have an unused "telemetry" variable. Use this variable and move
the telemetry assignment to immediately after the operation it is
recording.
While I was here, I also cleaned up the timing variables. I eliminated
the end time variable and moved the declaration of the start time
variable so its scope is shorter.
MozReview-Commit-ID: IbGOK5pPkcR
--- a/browser/components/sessionstore/SessionWorker.js
+++ b/browser/components/sessionstore/SessionWorker.js
@@ -145,34 +145,33 @@ var Agent = {
tab.entries = tab.entries.slice(lower, upper);
tab.index -= lower;
}
}
}
let stateString = JSON.stringify(state);
let data = Encoder.encode(stateString);
- let startWriteMs, stopWriteMs;
try {
if (this.state == STATE_CLEAN || this.state == STATE_EMPTY) {
// The backups directory may not exist yet. In all other cases,
// we have either already read from or already written to this
// directory, so we are satisfied that it exists.
File.makeDir(this.Paths.backups);
}
if (this.state == STATE_CLEAN) {
// Move $Path.clean out of the way, to avoid any ambiguity as
// to which file is more recent.
File.move(this.Paths.clean, this.Paths.cleanBackup);
}
- startWriteMs = Date.now();
+ let startWriteMs = Date.now();
if (options.isFinalWrite) {
// We are shutting down. At this stage, we know that
// $Paths.clean is either absent or corrupted. If it was
// originally present and valid, it has been moved to
// $Paths.cleanBackup a long time ago. We can therefore write
// with the guarantees that we erase no important data.
File.writeAtomic(this.Paths.clean, data, {
@@ -193,17 +192,18 @@ var Agent = {
// In other cases, either $Path.recovery is not necessary, or
// it doesn't exist or it has been corrupted. Regardless,
// don't backup $Path.recovery.
File.writeAtomic(this.Paths.recovery, data, {
tmpPath: this.Paths.recovery + ".tmp"
});
}
- stopWriteMs = Date.now();
+ telemetry[FX_SESSION_RESTORE_WRITE_FILE_MS] = Date.now() - startWriteMs;
+ telemetry[FX_SESSION_RESTORE_FILE_SIZE_BYTES] = data.byteLength;
} catch (ex) {
// Don't throw immediately
exn = exn || ex;
}
// If necessary, perform an upgrade backup
let upgradeBackupComplete = false;
@@ -271,20 +271,17 @@ var Agent = {
if (exn) {
throw exn;
}
return {
result: {
upgradeBackup: upgradeBackupComplete
},
- telemetry: {
- FX_SESSION_RESTORE_WRITE_FILE_MS: stopWriteMs - startWriteMs,
- FX_SESSION_RESTORE_FILE_SIZE_BYTES: data.byteLength,
- }
+ telemetry: telemetry,
};
},
/**
* Wipes all files holding session data from disk.
*/
wipe: function () {