Commit 9c95f650 authored by Kris Maglione's avatar Kris Maglione
Browse files

Bug 1385880: Part 2 - Store promise returned by bootstrap startup method. r=aswan

This is also the first step in moving async startup/shutdown tracking into the
add-on manager.

MozReview-Commit-ID: Uf4ecSW77S

--HG--
extra : rebase_source : 16029f3c84feec4b98b23b3beabf763978a6b60d
extra : histedit_source : a7478fd19ebd6fa827856f299ebb824f29db5575
parent 2a0de7a2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -758,7 +758,7 @@ class BootstrapScope {

  startup(data, reason) {
    this.extension = new Extension(data, this.BOOTSTRAP_REASON_TO_STRING_MAP[reason]);
    this.extension.startup();
    return this.extension.startup();
  }

  shutdown(data, reason) {
+19 −1
Original line number Diff line number Diff line
@@ -4390,11 +4390,18 @@ this.XPIProvider = {
      } else {
        logger.debug("Calling bootstrap method " + aMethod + " on " + aAddon.id + " version " +
                     aAddon.version);

        let result;
        try {
          method.call(scope, params, aReason);
          result = method.call(scope, params, aReason);
        } catch (e) {
          logger.warn("Exception running bootstrap method " + aMethod + " on " + aAddon.id, e);
        }

        if (aMethod == "startup") {
          activeAddon.startupPromise = Promise.resolve(result);
          activeAddon.startupPromise.catch(Cu.reportError);
        }
      }
    } finally {
      // Extensions are automatically initialized in the correct order at startup.
@@ -5483,6 +5490,17 @@ AddonWrapper.prototype = {
    return addon.bootstrap && canRunInSafeMode(addon);
  },

  get startupPromise() {
    let addon = addonFor(this);
    if (!addon.bootstrap || !this.isActive)
      return null;

    let activeAddon = XPIProvider.activeAddons.get(addon.id);
    if (activeAddon)
      return activeAddon.startupPromise || null;
    return null;
  },

  updateBlocklistState(applySoftBlock = true) {
    addonFor(this).updateBlocklistState({applySoftBlock});
  },