Bug 1497264 - Remove references to AddonTargetActor setAddonOptions;r=ochameau,yulia
authorJulian Descottes <jdescottes@mozilla.com>
Tue, 08 Jan 2019 18:42:44 +0000
changeset 452957 033f84c32bce
parent 452956 a894d406f4ae
child 452958 e62e0dfddefe
push id35336
push userrmaries@mozilla.com
push dateWed, 09 Jan 2019 03:47:21 +0000
treeherdermozilla-central@a36388b88fcc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau, yulia
bugs1497264
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 1497264 - Remove references to AddonTargetActor setAddonOptions;r=ochameau,yulia Depends on D15383 Differential Revision: https://phabricator.services.mozilla.com/D15384
devtools/client/framework/ToolboxProcess.jsm
devtools/server/actors/addon/webextension.js
devtools/server/main.js
toolkit/mozapps/extensions/internal/XPIProvider.jsm
--- a/devtools/client/framework/ToolboxProcess.jsm
+++ b/devtools/client/framework/ToolboxProcess.jsm
@@ -17,17 +17,16 @@ ChromeUtils.defineModuleGetter(this, "Ap
 
 XPCOMUtils.defineLazyGetter(this, "Telemetry", function() {
   return require("devtools/client/shared/telemetry");
 });
 XPCOMUtils.defineLazyGetter(this, "EventEmitter", function() {
   return require("devtools/shared/event-emitter");
 });
 
-const promise = require("promise");
 const Services = require("Services");
 
 this.EXPORTED_SYMBOLS = ["BrowserToolboxProcess"];
 
 var processes = new Set();
 
 /**
  * Constructor for creating a process that will hold a chrome toolbox.
@@ -67,18 +66,16 @@ this.BrowserToolboxProcess = function Br
     if (onRun) {
       this.once("run", onRun);
     }
     this._options = options || {};
   }
 
   this._telemetry = new Telemetry();
 
-  this._onConnectionChange = this._onConnectionChange.bind(this);
-
   this.close = this.close.bind(this);
   Services.obs.addObserver(this.close, "quit-application");
   this._initServer();
   this._initProfile();
   this._create();
 
   processes.add(this);
 };
@@ -107,35 +104,16 @@ BrowserToolboxProcess.getBrowserToolboxS
     // Don't worry about addon toolboxes, we only want to restore the Browser Toolbox.
     if (!process._options || !process._options.addonID) {
       return true;
     }
   }
   return false;
 };
 
-/**
- * Passes a set of options to the AddonTargetActors for the given ID.
- *
- * @param id string
- *        The ID of the add-on to pass the options to
- * @param options object
- *        The options.
- * @return a promise that will be resolved when complete.
- */
-BrowserToolboxProcess.setAddonOptions = function(id, options) {
-  const promises = [];
-
-  for (const process of processes.values()) {
-    promises.push(process.debuggerServer.setAddonOptions(id, options));
-  }
-
-  return promise.all(promises);
-};
-
 BrowserToolboxProcess.prototype = {
   /**
    * Initializes the debugger server.
    */
   _initServer: function() {
     if (this.debuggerServer) {
       dumpn("The chrome toolbox server is already running.");
       return;
@@ -150,19 +128,16 @@ BrowserToolboxProcess.prototype = {
     // invisible to the debugger (unlike the usual loader settings).
     this.loader = new DevToolsLoader();
     this.loader.invisibleToDebugger = true;
     const { DebuggerServer } = this.loader.require("devtools/server/main");
     const { SocketListener } = this.loader.require("devtools/shared/security/socket");
     this.debuggerServer = DebuggerServer;
     dumpn("Created a separate loader instance for the DebuggerServer.");
 
-    // Forward interesting events.
-    this.debuggerServer.on("connectionchange", this._onConnectionChange);
-
     this.debuggerServer.init();
     // We mainly need a root actor and target actors for opening a toolbox, even
     // against chrome/content/addon. But the "no auto hide" button uses the
     // preference actor, so also register the browser actors.
     this.debuggerServer.registerAllActors();
     this.debuggerServer.allowChromeProcess = true;
     dumpn("initialized and added the browser actors for the DebuggerServer.");
 
@@ -327,29 +302,16 @@ BrowserToolboxProcess.prototype = {
 
       return proc;
     }, err => {
       console.log(`Error loading Browser Toolbox: ${command} ${args.join(" ")}`, err);
     });
   },
 
   /**
-   * Called upon receiving the connectionchange event from a debuggerServer.
-   *
-   * @param {String} what
-   *        Type of connection change (can be either 'opened' or 'closed').
-   * @param {DebuggerServerConnection} connection
-   *        The connection that was opened or closed.
-   */
-  _onConnectionChange: function(what, connection) {
-    const wrappedJSObject = { what, connection };
-    Services.obs.notifyObservers({ wrappedJSObject }, "toolbox-connection-change");
-  },
-
-  /**
    * Closes the remote debugging server and kills the toolbox process.
    */
   close: async function() {
     if (this.closed) {
       return;
     }
 
     this.closed = true;
@@ -365,17 +327,16 @@ BrowserToolboxProcess.prototype = {
     // toolbox session id.
     this._telemetry.toolClosed("jsbrowserdebugger", -1, this);
 
     if (this.listener) {
       this.listener.close();
     }
 
     if (this.debuggerServer) {
-      this.debuggerServer.off("connectionchange", this._onConnectionChange);
       this.debuggerServer.destroy();
       this.debuggerServer = null;
     }
 
     dumpn("Chrome toolbox is now closed...");
     this.emit("close", this);
     processes.delete(this);
 
@@ -401,15 +362,8 @@ function dumpn(str) {
 
 var wantLogging = Services.prefs.getBoolPref("devtools.debugger.log");
 
 Services.prefs.addObserver("devtools.debugger.log", {
   observe: (...args) => {
     wantLogging = Services.prefs.getBoolPref(args.pop());
   },
 });
-
-Services.prefs.addObserver("toolbox-update-addon-options", {
-  observe: (subject) => {
-    const {id, options} = subject.wrappedJSObject;
-    BrowserToolboxProcess.setAddonOptions(id, options);
-  },
-});
--- a/devtools/server/actors/addon/webextension.js
+++ b/devtools/server/actors/addon/webextension.js
@@ -55,21 +55,16 @@ const WebExtensionActor = protocol.Actor
     this._childFormPromise = null;
 
     if (this._destroyProxy) {
       this._destroyProxy();
       delete this._destroyProxy;
     }
   },
 
-  setOptions() {
-    // NOTE: not used anymore for webextensions, still used in the legacy addons,
-    // addon manager is currently going to call it automatically on every addon.
-  },
-
   reload() {
     return this.addon.reload().then(() => {
       return {};
     });
   },
 
   form() {
     const policy = ExtensionParent.WebExtensionPolicy.getByID(this.addonId);
--- a/devtools/server/main.js
+++ b/devtools/server/main.js
@@ -164,40 +164,16 @@ var DebuggerServer = {
 
   /**
    * Register all possible actors for this DebuggerServer.
    */
   registerAllActors() {
     this.registerActors({ root: true, browser: true, target: true });
   },
 
-  /**
-   * Passes a set of options to the AddonTargetActors for the given ID.
-   *
-   * @param id string
-   *        The ID of the add-on to pass the options to
-   * @param options object
-   *        The options.
-   * @return a promise that will be resolved when complete.
-   */
-  setAddonOptions(id, options) {
-    if (!this._initialized) {
-      return Promise.resolve();
-    }
-
-    const promises = [];
-
-    // Pass to all connections
-    for (const connID of Object.getOwnPropertyNames(this._connections)) {
-      promises.push(this._connections[connID].setAddonOptions(id, options));
-    }
-
-    return Promise.all(promises);
-  },
-
   get listeningSockets() {
     return this._listeners.length;
   },
 
   /**
    * Add a SocketListener instance to the server's set of active
    * SocketListeners.  This is called by a SocketListener after it is opened.
    */
@@ -1196,41 +1172,16 @@ DebuggerServerConnection.prototype = {
       const prefix = "error occurred while processing '" + type;
       this.transport.send(this._unknownError(from, prefix, error));
     });
 
     this._actorResponses.set(from, responsePromise);
   },
 
   /**
-   * Passes a set of options to the AddonTargetActors for the given ID.
-   *
-   * @param id string
-   *        The ID of the add-on to pass the options to
-   * @param options object
-   *        The options.
-   * @return a promise that will be resolved when complete.
-   */
-  setAddonOptions(id, options) {
-    const addonList = this.rootActor._parameters.addonList;
-    if (!addonList) {
-      return Promise.resolve();
-    }
-    return addonList.getList().then((addonTargetActors) => {
-      for (const actor of addonTargetActors) {
-        if (actor.addonId != id) {
-          continue;
-        }
-        actor.setOptions(options);
-        return;
-      }
-    });
-  },
-
-  /**
    * This function returns whether the connection was accepted by passed SocketListener.
    *
    * @param {SocketListener} socketListener
    * @return {Boolean} return true if this connection was accepted by socketListener,
    *         else returns false.
    */
   isAcceptedBy(socketListener) {
     return this._socketListener === socketListener;
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -101,18 +101,16 @@ const STARTUP_MTIME_SCOPES = [KEY_APP_GL
 
 const NOTIFICATION_FLUSH_PERMISSIONS  = "flush-pending-permissions";
 const XPI_PERMISSION                  = "install";
 
 const XPI_SIGNATURE_CHECK_PERIOD      = 24 * 60 * 60;
 
 const DB_SCHEMA = 28;
 
-const NOTIFICATION_TOOLBOX_CONNECTION_CHANGE      = "toolbox-connection-change";
-
 function encoded(strings, ...values) {
   let result = [];
 
   for (let [i, string] of strings.entries()) {
     result.push(string);
     if (i < values.length)
       result.push(encodeURIComponent(values[i]));
   }
@@ -1699,37 +1697,29 @@ class BootstrapScope {
     } else {
       let loader = AddonManagerPrivate.externalExtensionLoaders.get(this.addon.loader);
       if (!loader) {
         throw new Error(`Cannot find loader for ${this.addon.loader}`);
       }
 
       this.scope = loader.loadScope(this.addon, this.file);
     }
-
-    // Notify the BrowserToolboxProcess that a new addon has been loaded.
-    let wrappedJSObject = { id: this.addon.id, options: { global: this.scope }};
-    Services.obs.notifyObservers({ wrappedJSObject }, "toolbox-update-addon-options");
   }
 
   /**
    * Unloads a bootstrap scope by dropping all references to it and then
    * updating the list of active add-ons with the crash reporter.
    */
   unloadBootstrapScope() {
     XPIProvider.activeAddons.delete(this.addon.id);
     XPIProvider.addAddonsToCrashReporter();
 
     this.scope = null;
     this.startupPromise = null;
     this.instanceID = null;
-
-    // Notify the BrowserToolboxProcess that an addon has been unloaded.
-    let wrappedJSObject = { id: this.addon.id, options: { global: null }};
-    Services.obs.notifyObservers({ wrappedJSObject }, "toolbox-update-addon-options");
   }
 
   /**
    * Calls the bootstrap scope's startup method, with the given reason
    * and extra parameters.
    *
    * @param {integer} reason
    *        The reason code for the startup call.
@@ -2148,17 +2138,16 @@ var XPIProvider = {
 
       this.setupInstallLocations(aAppChanged);
 
       if (!AppConstants.MOZ_REQUIRE_SIGNING || Cu.isInAutomation)
         Services.prefs.addObserver(PREF_XPI_SIGNATURES_REQUIRED, this);
       Services.prefs.addObserver(PREF_LANGPACK_SIGNATURES, this);
       Services.prefs.addObserver(PREF_ALLOW_LEGACY, this);
       Services.obs.addObserver(this, NOTIFICATION_FLUSH_PERMISSIONS);
-      Services.obs.addObserver(this, NOTIFICATION_TOOLBOX_CONNECTION_CHANGE);
 
 
       let flushCaches = this.checkForChanges(aAppChanged, aOldAppVersion,
                                              aOldPlatformVersion);
       if (flushCaches) {
         Services.obs.notifyObservers(null, "startupcache-invalidate");
       }
 
@@ -2714,43 +2703,29 @@ var XPIProvider = {
         isSystem,
         isWebExtension: addon.isWebExtension,
       });
     }
 
     return {addons: result, fullData: false};
   },
 
-  onDebugConnectionChange({what, connection}) {
-    if (what != "opened")
-      return;
-
-    for (let [id, val] of this.activeAddons) {
-      connection.setAddonOptions(
-        id, { global: val.scope });
-    }
-  },
-
   /*
    * Notified when a preference we're interested in has changed.
    *
    * @see nsIObserver
    */
   observe(aSubject, aTopic, aData) {
     switch (aTopic) {
     case NOTIFICATION_FLUSH_PERMISSIONS:
       if (!aData || aData == XPI_PERMISSION) {
         XPIDatabase.importPermissions();
       }
       break;
 
-    case NOTIFICATION_TOOLBOX_CONNECTION_CHANGE:
-      this.onDebugConnectionChange(aSubject.wrappedJSObject);
-      break;
-
     case "nsPref:changed":
       switch (aData) {
       case PREF_XPI_SIGNATURES_REQUIRED:
       case PREF_LANGPACK_SIGNATURES:
       case PREF_ALLOW_LEGACY:
         XPIDatabase.updateAddonAppDisabledStates();
         break;
       }