Bug 956678 - Replace TaskUtils.spawn() by Task.spawn() in Session Restore. r=yoric
authorJohannes Mittendorfer <johannes@johannes-mittendorfer.com>
Wed, 08 Jan 2014 09:50:54 -0500
changeset 162518 77d90521f46f
parent 162517 ad1a0f745246
child 162519 ad0783cbd9e5
push id4233
push userryanvm@gmail.com
push date2014-01-08 14:51 +0000
treeherderfx-team@77d90521f46f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyoric
bugs956678
milestone29.0a1
Bug 956678 - Replace TaskUtils.spawn() by Task.spawn() in Session Restore. r=yoric
browser/components/sessionstore/src/SessionFile.jsm
--- 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