Bug 1392653 - Remove redundant LegacyExtensionUtils shutdown blocker. r=aswan, a=lizzard
authorKris Maglione <maglione.k@gmail.com>
Thu, 24 Aug 2017 15:01:55 -0700
changeset 423897 c46525d6bf12e6a0bf18250bb7643312450fed97
parent 423896 55b8650bcc3bdbaca143433c8ad121ec80bbfa34
child 423898 7b0b48569ec86d62017a87759e5b9f48bb0a4a25
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan, lizzard
bugs1392653
milestone56.0
Bug 1392653 - Remove redundant LegacyExtensionUtils shutdown blocker. r=aswan, a=lizzard 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(),