Bug 1374457: Key cached manifest and locale data by add-on version. r=rhelmer
authorKris Maglione <maglione.k@gmail.com>
Mon, 19 Jun 2017 15:14:08 -0700
changeset 364842 d1970a5ac27cda1be85e82494281850a93d03091
parent 364841 369de2fe16f5a0f5bb476e26873a18e0e9c3d09d
child 364843 4135740caaa4588b80449a58a5f6582f834f5306
push id32055
push usercbook@mozilla.com
push dateTue, 20 Jun 2017 09:26:54 +0000
treeherdermozilla-central@7a6baa6cca32 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrhelmer
bugs1374457
milestone56.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 1374457: Key cached manifest and locale data by add-on version. r=rhelmer MozReview-Commit-ID: 7NdS0Etmhot
toolkit/components/extensions/Extension.jsm
toolkit/components/extensions/LegacyExtensionsUtils.jsm
--- a/toolkit/components/extensions/Extension.jsm
+++ b/toolkit/components/extensions/Extension.jsm
@@ -743,16 +743,17 @@ this.Extension = class extends Extension
       Cu.reportError(new Error("Remote extensions should not be enabled without also setting " +
                                "the layers.popups.compositing.enabled preference to true"));
     }
 
     // This is filled in the first time an extension child is created.
     this.parentMessageManager = null;
 
     this.id = addonData.id;
+    this.version = addonData.version;
     this.baseURI = NetUtil.newURI(this.getURL("")).QueryInterface(Ci.nsIURL);
     this.principal = this.createPrincipal();
 
     this.onStartup = null;
 
     this.hasShutdown = false;
     this.onShutdown = new Set();
 
@@ -850,25 +851,25 @@ this.Extension = class extends Extension
   isExtensionURL(url) {
     let uri = Services.io.newURI(url);
 
     let common = this.baseURI.getCommonBaseSpec(uri);
     return common == this.baseURI.spec;
   }
 
   readLocaleFile(locale) {
-    return StartupCache.locales.get([this.id, locale],
+    return StartupCache.locales.get([this.id, this.version, locale],
                                     () => super.readLocaleFile(locale))
       .then(result => {
         this.localeData.messages.set(locale, result);
       });
   }
 
   parseManifest() {
-    return StartupCache.manifests.get([this.id, Locale.getLocale()],
+    return StartupCache.manifests.get([this.id, this.version, Locale.getLocale()],
                                       () => super.parseManifest());
   }
 
   loadManifest() {
     return super.loadManifest().then(manifest => {
       if (this.errors.length) {
         return Promise.reject({errors: this.errors});
       }
--- a/toolkit/components/extensions/LegacyExtensionsUtils.jsm
+++ b/toolkit/components/extensions/LegacyExtensionsUtils.jsm
@@ -104,22 +104,25 @@ class EmbeddedExtension {
    * Create a new EmbeddedExtension given the add-on id and the base resource URI of the
    * container add-on (the webextension resources will be loaded from the "webextension/"
    * subdir of the base resource URI for the legacy extension add-on).
    *
    * @param {Object} containerAddonParams
    *   An object with the following properties:
    * @param {string} containerAddonParams.id
    *   The Add-on id of the Legacy Extension which will contain the embedded webextension.
+   * @param {string} containerAddonParams.version
+   *   The add-on version.
    * @param {nsIURI} containerAddonParams.resourceURI
    *   The nsIURI of the Legacy Extension container add-on.
    */
-  constructor({id, resourceURI}) {
+  constructor({id, resourceURI, version}) {
     this.addonId = id;
     this.resourceURI = resourceURI;
+    this.version = version;
 
     // Setup status flag.
     this.started = false;
   }
 
   /**
    * Start the embedded webextension.
    *
@@ -134,16 +137,17 @@ class EmbeddedExtension {
     // Setup the startup promise.
     this.startupPromise = new Promise((resolve, reject) => {
       let embeddedExtensionURI = Services.io.newURI("webextension/", null, this.resourceURI);
 
       // This is the instance of the WebExtension embedded in the hybrid add-on.
       this.extension = new Extension({
         id: this.addonId,
         resourceURI: embeddedExtensionURI,
+        version: this.version,
       });
 
       // This callback is register to the "startup" event, emitted by the Extension instance
       // after the extension manifest.json has been loaded without any errors, but before
       // starting any of the defined contexts (which give the legacy part a chance to subscribe
       // runtime.onMessage/onConnect listener before the background page has been loaded).
       const onBeforeStarted = () => {
         this.extension.off("startup", onBeforeStarted);
@@ -222,21 +226,21 @@ EmbeddedExtensionManager = {
   untrackEmbeddedExtension(embeddedExtensionInstance) {
     // Remove this instance from the tracked embedded extensions
     let id = embeddedExtensionInstance.addonId;
     if (this.embeddedExtensionsByAddonId.get(id) == embeddedExtensionInstance) {
       this.embeddedExtensionsByAddonId.delete(id);
     }
   },
 
-  getEmbeddedExtensionFor({id, resourceURI}) {
+  getEmbeddedExtensionFor({id, resourceURI, version}) {
     let embeddedExtension = this.embeddedExtensionsByAddonId.get(id);
 
     if (!embeddedExtension) {
-      embeddedExtension = new EmbeddedExtension({id, resourceURI});
+      embeddedExtension = new EmbeddedExtension({id, resourceURI, version});
       // Keep track of the embedded extension instance.
       this.embeddedExtensionsByAddonId.set(id, embeddedExtension);
     }
 
     return embeddedExtension;
   },
 };