Bug 1280235 Part 1 remove createAddonDetails from XPIProvider r=kmag
authorAndrew Swan <aswan@mozilla.com>
Sun, 08 Oct 2017 09:54:18 -0700
changeset 387286 71ea8cf2a217d5bccdc422b5462afa870e4699cd
parent 387285 23b3ec9f9b2a19714f80f829bd89b8a587f2155a
child 387287 d4961b5813af00baad4cd63517f52b55d275fb62
push id53712
push useraswan@mozilla.com
push dateFri, 20 Oct 2017 01:54:30 +0000
treeherderautoland@d4961b5813af [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1280235
milestone58.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 1280235 Part 1 remove createAddonDetails from XPIProvider r=kmag MozReview-Commit-ID: 7NWVD1Rvb2X
toolkit/mozapps/extensions/internal/XPIProvider.jsm
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -863,30 +863,16 @@ function isUsableAddon(aAddon) {
       logger.warn(`Add-on ${aAddon.id} is not compatible with target application.`);
       return false;
     }
   }
 
   return true;
 }
 
-function createAddonDetails(id, aAddon) {
-  return {
-    id: id || aAddon.id,
-    type: aAddon.type,
-    version: aAddon.version,
-    multiprocessCompatible: aAddon.multiprocessCompatible,
-    mpcOptedOut: aAddon.mpcOptedOut,
-    runInSafeMode: aAddon.runInSafeMode,
-    dependencies: aAddon.dependencies,
-    hasEmbeddedWebExtension: aAddon.hasEmbeddedWebExtension,
-    startupData: aAddon.startupData,
-  };
-}
-
 /**
  * Converts an internal add-on type to the type presented through the API.
  *
  * @param  aType
  *         The internal add-on type
  * @return an external add-on type
  */
 function getExternalType(aType) {
@@ -2231,18 +2217,17 @@ this.XPIProvider = {
           }
           try {
             let reason = BOOTSTRAP_REASONS.APP_STARTUP;
             // Eventually set INSTALLED reason when a bootstrap addon
             // is dropped in profile folder and automatically installed
             if (AddonManager.getStartupChanges(AddonManager.STARTUP_CHANGE_INSTALLED)
                             .indexOf(addon.id) !== -1)
               reason = BOOTSTRAP_REASONS.ADDON_INSTALL;
-            this.callBootstrapMethod(createAddonDetails(addon.id, addon),
-                                     addon.file, "startup", reason);
+            this.callBootstrapMethod(addon, addon.file, "startup", reason);
           } catch (e) {
             logger.error("Failed to load bootstrap addon " + addon.id + " from " +
                          addon.descriptor, e);
           }
         }
         AddonManagerPrivate.recordTimestamp("XPI_bootstrap_addons_end");
       } catch (e) {
         logger.error("bootstrap startup failed", e);
@@ -2256,33 +2241,31 @@ this.XPIProvider = {
           XPIProvider._closing = true;
           for (let addon of XPIProvider.sortBootstrappedAddons().reverse()) {
             // If no scope has been loaded for this add-on then there is no need
             // to shut it down (should only happen when a bootstrapped add-on is
             // pending enable)
             if (!XPIProvider.activeAddons.has(addon.id))
               continue;
 
-            let addonDetails = createAddonDetails(addon.id, addon);
-
             // If the add-on was pending disable then shut it down and remove it
             // from the persisted data.
             let reason = BOOTSTRAP_REASONS.APP_SHUTDOWN;
             if (addon.disable) {
               reason = BOOTSTRAP_REASONS.ADDON_DISABLE;
             } else if (addon.location.name == KEY_APP_TEMPORARY) {
               reason = BOOTSTRAP_REASONS.ADDON_UNINSTALL;
               let locations = Array.from(XPIStates.db.values())
                                    .filter(loc => loc.name != TemporaryInstallLocation.name);
               let existing = XPIStates.findAddon(addon.id, locations);
               if (existing) {
                 reason = newVersionReason(addon.version, existing.version);
               }
             }
-            XPIProvider.callBootstrapMethod(addonDetails, addon.file,
+            XPIProvider.callBootstrapMethod(addon, addon.file,
                                             "shutdown", reason);
           }
           Services.obs.removeObserver(this, "quit-application-granted");
         }
       }, "quit-application-granted");
 
       // Detect final-ui-startup for telemetry reporting
       Services.obs.addObserver({
@@ -2368,29 +2351,27 @@ this.XPIProvider = {
 
         let locations = Array.from(XPIStates.db.values())
                              .filter(loc => loc != tempLocation);
         let existing = XPIStates.findAddon(id, locations);
         if (existing) {
           reason = newVersionReason(addon.version, existing.version);
         }
 
-        this.callBootstrapMethod(createAddonDetails(id, addon),
-                                 addon.file, "uninstall", reason);
+        this.callBootstrapMethod(addon, addon.file, "uninstall", reason);
         this.unloadBootstrapScope(id);
         TemporaryInstallLocation.uninstallAddon(id);
 
         if (existing) {
           let newAddon = XPIDatabase.makeAddonLocationVisible(id, existing.location.name);
 
           let file = new nsIFile(newAddon.path);
 
           let data = {oldVersion: addon.version};
-          this.callBootstrapMethod(createAddonDetails(id, newAddon),
-                                   file, "install", reason, data);
+          this.callBootstrapMethod(newAddon, file, "install", reason, data);
         }
       }
     }
 
     this.activeAddons.clear();
     this.allAppGlobal = true;
 
     // If there are pending operations then we must update the list of active
@@ -2959,17 +2940,17 @@ this.XPIProvider = {
               oldBootstrap = existingAddon;
 
               // We'll be replacing a currently active bootstrapped add-on so
               // call its uninstall method
               let newVersion = addon.version;
               let oldVersion = existingAddon;
               let uninstallReason = newVersionReason(oldVersion, newVersion);
 
-              this.callBootstrapMethod(createAddonDetails(existingAddonID, existingAddon),
+              this.callBootstrapMethod(existingAddon,
                                        file, "uninstall", uninstallReason,
                                        { newVersion });
               this.unloadBootstrapScope(existingAddonID);
               flushChromeCaches();
             }
           } catch (e) {
           }
         }
@@ -2988,18 +2969,17 @@ this.XPIProvider = {
           new StagedAddonInstall(location, stageDirEntry, addon);
           // Make sure not to delete the cached manifest json file
           seenFiles.pop();
 
           delete aManifests[location.name][id];
 
           if (oldBootstrap) {
             // Re-install the old add-on
-            this.callBootstrapMethod(createAddonDetails(existingAddonID, oldBootstrap),
-                                     existingAddon, "install",
+            this.callBootstrapMethod(oldBootstrap, existingAddon, "install",
                                      BOOTSTRAP_REASONS.ADDON_INSTALL);
           }
           continue;
         }
       }
 
       try {
         location.cleanStagingDir(seenFiles);