Bug 1392653: Remove redundant LegacyExtensionUtils shutdown blocker. r=aswan
authorKris Maglione <maglione.k@gmail.com>
Thu, 24 Aug 2017 15:01:55 -0700
changeset 377127 3aa4bc482372340ca890b1b0b5fd0937d21b725d
parent 377126 d10651944d76db8519d7a317f576377bc83f6d8e
child 377128 b80466887686fbefe5a67aebc86f6f4aaf5feac8
push id32401
push userphilringnalda@gmail.com
push dateMon, 28 Aug 2017 00:32:10 +0000
treeherdermozilla-central@d10c97627b51 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1392653
milestone57.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 1392653: Remove redundant LegacyExtensionUtils shutdown blocker. r=aswan The base Extension class now handles adding shutdown blockers and waiting for extension startup before beginning shutdown, so the redundant logic only causes problems. MozReview-Commit-ID: 2gBWlmIs1KQ
toolkit/components/extensions/LegacyExtensionsUtils.jsm
--- a/toolkit/components/extensions/LegacyExtensionsUtils.jsm
+++ b/toolkit/components/extensions/LegacyExtensionsUtils.jsm
@@ -12,18 +12,16 @@ this.EXPORTED_SYMBOLS = ["LegacyExtensio
  * This file exports helpers for Legacy Extensions that want to embed a webextensions
  * and exchange messages with the embedded WebExtension.
  */
 
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
-XPCOMUtils.defineLazyModuleGetter(this, "AsyncShutdown",
-                                  "resource://gre/modules/AsyncShutdown.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Extension",
                                   "resource://gre/modules/Extension.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "ExtensionChild",
                                   "resource://gre/modules/ExtensionChild.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Services",
                                   "resource://gre/modules/Services.jsm");
 
 Cu.import("resource://gre/modules/ExtensionCommon.jsm");
@@ -203,38 +201,26 @@ class EmbeddedExtension {
   /**
    * Shuts down the embedded webextension.
    *
    * @param {number} reason
    *   The add-on shutdown bootstrap reason received from the XPIProvider.
    *
    * @returns {Promise<void>} a promise that is resolved when the shutdown has been done
    */
-  shutdown(reason) {
+  async shutdown(reason) {
     EmbeddedExtensionManager.untrackEmbeddedExtension(this);
 
-    // If there is a pending startup,  wait to be completed and then shutdown.
-    if (this.startupPromise) {
-      let promise = this.startupPromise.then(() => {
-        return this.extension.shutdown(reason);
-      });
-
-      AsyncShutdown.profileChangeTeardown.addBlocker(
-        `Legacy Extension Shutdown: ${this.addonId}`,
-        promise.catch(() => {}));
+    if (this.extension && !this.extension.hasShutdown) {
+      let {extension} = this;
+      this.extension = null;
 
-      return promise;
+      await extension.shutdown(reason);
     }
-
-    // Run shutdown now if the embedded webextension has been correctly started
-    if (this.extension && this.started && !this.extension.hasShutdown) {
-      this.extension.shutdown(reason);
-    }
-
-    return Promise.resolve();
+    return undefined;
   }
 }
 
 // Keep track on the created EmbeddedExtension instances and destroy
 // them when their container addon is going to be disabled or uninstalled.
 EmbeddedExtensionManager = {
   // Map of the existent EmbeddedExtensions instances by addon id.
   embeddedExtensionsByAddonId: new Map(),