Bug 956678 - Replace TaskUtils.spawn() by Task.spawn() in Session Restore. r=yoric
--- a/browser/components/sessionstore/src/SessionFile.jsm
+++ b/browser/components/sessionstore/src/SessionFile.jsm
@@ -87,49 +87,16 @@ this.SessionFile = {
}
};
Object.freeze(SessionFile);
/**
* Utilities for dealing with promises and Task.jsm
*/
-const TaskUtils = {
- /**
- * Add logging to a promise.
- *
- * @param {Promise} promise
- * @return {Promise} A promise behaving as |promise|, but with additional
- * logging in case of uncaught error.
- */
- captureErrors: function captureErrors(promise) {
- return promise.then(
- null,
- function onError(reason) {
- console.error("Uncaught asynchronous error", reason, "at", reason.stack);
- throw reason;
- }
- );
- },
- /**
- * Spawn a new Task from a generator.
- *
- * This function behaves as |Task.spawn|, with the exception that it
- * adds logging in case of uncaught error. For more information, see
- * the documentation of |Task.jsm|.
- *
- * @param {generator} gen Some generator.
- * @return {Promise} A promise built from |gen|, with the same semantics
- * as |Task.spawn(gen)|.
- */
- spawn: function spawn(gen) {
- return this.captureErrors(Task.spawn(gen));
- }
-};
-
let SessionFileInternal = {
/**
* The path to sessionstore.js
*/
path: OS.Path.join(OS.Constants.Path.profileDir, "sessionstore.js"),
/**
* The path to sessionstore.bak
@@ -163,17 +130,17 @@ let SessionFileInternal = {
let isFinalWrite = false;
if (Services.startup.shuttingDown) {
// If shutdown has started, we will want to stop receiving
// write instructions.
isFinalWrite = this._isClosed = true;
}
- return this._latestWrite = TaskUtils.spawn(function task() {
+ return this._latestWrite = Task.spawn(function task() {
TelemetryStopwatch.start("FX_SESSION_RESTORE_WRITE_FILE_LONGEST_OP_MS", refObj);
try {
let promise = SessionWorker.post("write", [aData]);
// At this point, we measure how long we stop the main thread
TelemetryStopwatch.finish("FX_SESSION_RESTORE_WRITE_FILE_LONGEST_OP_MS", refObj);
// Now wait for the result and record how long the write took