Bug 1517456 - Remove remaining production code references to Task.jsm. r=florian
authorMark Banner <standard8@mozilla.com>
Fri, 04 Jan 2019 08:41:49 +0000
changeset 509623 f26ec01f436a9ac376be18b3be41c03de7812c7b
parent 509622 d11632d4bde430996964c3599d4d878832ed6aaa
child 509624 777128d1fd48dff16999326fb8a475784a5de03a
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs1517456
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1517456 - Remove remaining production code references to Task.jsm. r=florian Differential Revision: https://phabricator.services.mozilla.com/D15646
toolkit/components/asyncshutdown/AsyncShutdown.jsm
toolkit/components/osfile/modules/osfile_async_front.jsm
toolkit/components/thumbnails/PageThumbs.jsm
toolkit/modules/Log.jsm
toolkit/modules/docs/AsyncShutdown.rst
--- a/toolkit/components/asyncshutdown/AsyncShutdown.jsm
+++ b/toolkit/components/asyncshutdown/AsyncShutdown.jsm
@@ -38,18 +38,16 @@
 
 "use strict";
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", this);
 ChromeUtils.import("resource://gre/modules/Services.jsm", this);
 
 ChromeUtils.defineModuleGetter(this, "PromiseUtils",
   "resource://gre/modules/PromiseUtils.jsm");
-ChromeUtils.defineModuleGetter(this, "Task",
-  "resource://gre/modules/Task.jsm");
 XPCOMUtils.defineLazyServiceGetter(this, "gDebug",
   "@mozilla.org/xpcom/debug;1", "nsIDebug2");
 Object.defineProperty(this, "gCrashReporter", {
   get() {
     delete this.gCrashReporter;
     try {
       let reporter = Cc["@mozilla.org/xre/app-info;1"].
             getService(Ci.nsICrashReporter);
@@ -308,27 +306,21 @@ function getOrigin(topFrame, filename = 
       filename = frame ? frame.filename : "?";
     }
     if (lineNumber == null) {
       lineNumber = frame ? frame.lineNumber : 0;
     }
     if (stack == null) {
       // Now build the rest of the stack as a string, using Task.jsm's rewriting
       // to ensure that we do not lose information at each call to `Task.spawn`.
-      let frames = [];
+      stack = [];
       while (frame != null) {
-        frames.push(frame.filename + ":" + frame.name + ":" + frame.lineNumber);
+        stack.push(frame.filename + ":" + frame.name + ":" + frame.lineNumber);
         frame = frame.caller;
       }
-      stack = frames.join("\n");
-      // Avoid loading Task.jsm if there's no task on the stack.
-      if (stack.includes("/Task.jsm:")) {
-        stack = Task.Debugging.generateReadableStack(stack);
-      }
-      stack = stack.split("\n");
     }
 
     return {
       filename,
       lineNumber,
       stack,
     };
   } catch (ex) {
--- a/toolkit/components/osfile/modules/osfile_async_front.jsm
+++ b/toolkit/components/osfile/modules/osfile_async_front.jsm
@@ -43,18 +43,16 @@ var OSError = SysAll.Error;
 var Type = SysAll.Type;
 
 var Path = {};
 ChromeUtils.import("resource://gre/modules/osfile/ospath.jsm", Path);
 
 // The library of promises.
 ChromeUtils.defineModuleGetter(this, "PromiseUtils",
                                "resource://gre/modules/PromiseUtils.jsm");
-ChromeUtils.defineModuleGetter(this, "Task",
-                               "resource://gre/modules/Task.jsm");
 
 // The implementation of communications
 ChromeUtils.import("resource://gre/modules/PromiseWorker.jsm", this);
 ChromeUtils.import("resource://gre/modules/Services.jsm", this);
 ChromeUtils.import("resource://gre/modules/AsyncShutdown.jsm", this);
 var Native = ChromeUtils.import("resource://gre/modules/osfile/osfile_native.jsm", {});
 
 
@@ -308,19 +306,16 @@ var Scheduler = this.Scheduler = {
         }
 
         // Exit critical section
 
         let message = ["Meta_shutdown", [reset]];
 
         Scheduler.latestReceived = [];
         let stack = new Error().stack;
-        // Avoid loading Task.jsm if there's no task on the stack.
-        if (stack.includes("/Task.jsm:"))
-          stack = Task.Debugging.generateReadableStack(stack);
         Scheduler.latestSent = [Date.now(), stack, ...message];
 
         // Wait for result
         let resources;
         try {
           resources = await this._worker.post(...message);
 
           Scheduler.latestReceived = [Date.now(), message];
--- a/toolkit/components/thumbnails/PageThumbs.jsm
+++ b/toolkit/components/thumbnails/PageThumbs.jsm
@@ -42,17 +42,17 @@ XPCOMUtils.defineLazyModuleGetters(this,
 
 XPCOMUtils.defineLazyServiceGetter(this, "gUpdateTimerManager",
   "@mozilla.org/updates/timer-manager;1", "nsIUpdateTimerManager");
 
 XPCOMUtils.defineLazyServiceGetter(this, "PageThumbsStorageService",
   "@mozilla.org/thumbnails/pagethumbs-service;1", "nsIPageThumbsStorageService");
 
 /**
- * Utilities for dealing with promises and Task.jsm
+ * Utilities for dealing with promises.
  */
 const TaskUtils = {
   /**
    * Read the bytes from a blob, asynchronously.
    *
    * @return {Promise}
    * @resolve {ArrayBuffer} In case of success, the bytes contained in the blob.
    * @reject {DOMException} In case of error, the underlying DOMException.
--- a/toolkit/modules/Log.jsm
+++ b/toolkit/modules/Log.jsm
@@ -2,20 +2,18 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 var EXPORTED_SYMBOLS = ["Log"];
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-XPCOMUtils.defineLazyModuleGetters(this, {
-  Services: "resource://gre/modules/Services.jsm",
-  Task: "resource://gre/modules/Task.jsm",
-});
+ChromeUtils.defineModuleGetter(this, "Services",
+                               "resource://gre/modules/Services.jsm");
 const INTERNAL_FIELDS = new Set(["_level", "_message", "_time", "_namespace"]);
 
 
 /*
  * Dump a message everywhere we can if we have a failure.
  */
 function dumpError(text) {
   dump(text + "\n");
@@ -124,19 +122,16 @@ var Log = {
         }
         frame = frame.caller;
       }
       return `Stack trace: ${output.join("\n")}`;
     }
     // Standard JS exception
     if (e.stack) {
       let stack = e.stack;
-      // Avoid loading Task.jsm if there's no task on the stack.
-      if (stack.includes("/Task.jsm:"))
-        stack = Task.Debugging.generateReadableStack(stack);
       return "JS Stack trace: " + stack.trim()
         .replace(/@[^@]*?([^\/\.]+\.\w+:)/g, "@$1");
     }
 
     return "No traceback available";
   },
 };
 
--- a/toolkit/modules/docs/AsyncShutdown.rst
+++ b/toolkit/modules/docs/AsyncShutdown.rst
@@ -70,31 +70,30 @@ The following snippet presents an exampl
 wishes to ensure that all clients have had a chance to complete any
 outstanding operations before FooService shuts down.
 
 .. code-block:: javascript
 
     // Module FooService
 
     Components.utils.import("resource://gre/modules/AsyncShutdown.jsm", this);
-    Components.utils.import("resource://gre/modules/Task.jsm", this);
 
     this.exports = ["FooService"];
 
     let shutdown = new AsyncShutdown.Barrier("FooService: Waiting for clients before shutting down");
 
     // Export the `client` capability, to let clients register shutdown blockers
     FooService.shutdown = shutdown.client;
 
-    // This Task should be triggered at some point during shutdown, generally
-    // as a client to another Barrier or Phase. Triggering this Task is not covered
+    // This function should be triggered at some point during shutdown, generally
+    // as a client to another Barrier or Phase. Triggering this function is not covered
     // in this snippet.
-    let onshutdown = Task.async(function*() {
+    let onshutdown = async function() {
       // Wait for all registered clients to have lifted the barrier
-      yield shutdown.wait();
+      await shutdown.wait();
 
       // Now deactivate FooService itself.
       // ...
     });
 
 Frequently, a service that owns a ``AsyncShutdown.Barrier`` is itself a client of another Barrier.
 
 .. _AsyncShutdown.Barrier.state:
@@ -116,50 +115,49 @@ The following snippet presents FooClient
       () => Blocker.state
     );
 
     let Blocker = {
       // This field contains information on the status of the blocker.
       // It can be any JSON serializable object.
       state: "Not started",
 
-      wait: Task.async(function*() {
+      async wait() {
         // This method is called once FooService starts informing its clients that
         // FooService wishes to shut down.
 
         // Update the state as we go. If the Barrier is used in conjunction with
         // a Phase, this state will be reported as part of a crash report if FooClient fails
         // to shutdown properly.
         this.state = "Starting";
 
-        let data = yield collectSomeData();
+        let data = await collectSomeData();
         this.state = "Data collection complete";
 
         try {
-          yield writeSomeDataToDisk(data);
+          await writeSomeDataToDisk(data);
           this.state = "Data successfully written to disk";
         } catch (ex) {
           this.state = "Writing data to disk failed, proceeding with shutdown: " + ex;
         }
 
-        yield FooService.oneLastCall();
+        await FooService.oneLastCall();
         this.state = "Ready";
-      }.bind(this)
+      }
     };
 
 
 Example 4: A service with both internal and external dependencies
 -----------------------------------------------------------------
 
  .. code-block:: javascript
 
     // Module FooService2
 
     Components.utils.import("resource://gre/modules/AsyncShutdown.jsm", this);
-    Components.utils.import("resource://gre/modules/Task.jsm", this);
     Components.utils.import("resource://gre/modules/Promise.jsm", this);
 
     this.exports = ["FooService2"];
 
     let shutdown = new AsyncShutdown.Barrier("FooService2: Waiting for clients before shutting down");
 
     // Export the `client` capability, to let clients register shutdown blockers
     FooService2.shutdown = shutdown.client;
@@ -194,29 +192,29 @@ Example 4: A service with both internal 
 
           // The barrier MUST be lifted, even if removeBlocker has been called.
           deferred.resolve();
         }
       };
     };
 
 
-    // This Task should be triggered at some point during shutdown, generally
-    // as a client to another Barrier. Triggering this Task is not covered
+    // This function should be triggered at some point during shutdown, generally
+    // as a client to another Barrier. Triggering this function is not covered
     // in this snippet.
-    let onshutdown = Task.async(function*() {
+    let onshutdown = async function() {
       // Wait for all registered clients to have lifted the barrier.
       // These clients may open instances of FooConnection if they need to.
-      yield shutdown.wait();
+      await shutdown.wait();
 
       // Now stop accepting any other connection request.
       isClosed = true;
 
       // Wait for all instances of FooConnection to be closed.
-      yield connections.wait();
+      await connections.wait();
 
       // Now finish shutting down FooService2
       // ...
     });
 
 .. _AsyncShutdown_phases:
 
 Phases: Expressing dependencies towards phases of shutdown