[Pkg-mozext-commits] [requestpolicy] 211/280: fix addon-upgrade issues regarding factories

David Prévot taffit at moszumanska.debian.org
Sat May 2 20:30:29 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository requestpolicy.

commit b24a36af760c93990ead917438dfce30a400bfa7
Author: Martin Kimmerle <dev at 256k.de>
Date:   Tue Feb 10 01:54:40 2015 +0100

    fix addon-upgrade issues regarding factories
---
 src/content/main/about-uri.jsm      | 19 ++++++++++++++++---
 src/content/main/content-policy.jsm | 14 ++++++++++++--
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/src/content/main/about-uri.jsm b/src/content/main/about-uri.jsm
index 9f37331..3e0eb27 100644
--- a/src/content/main/about-uri.jsm
+++ b/src/content/main/about-uri.jsm
@@ -24,6 +24,7 @@
 const Ci = Components.interfaces;
 const Cc = Components.classes;
 const Cu = Components.utils;
+const Cr = Components.results;
 
 let EXPORTED_SYMBOLS = ["AboutRequestPolicy"];
 
@@ -34,7 +35,10 @@ let globalScope = this;
 
 
 Cu.import("chrome://requestpolicy/content/lib/script-loader.jsm");
-ScriptLoader.importModule("lib/environment", globalScope);
+ScriptLoader.importModules([
+  "lib/environment",
+  "lib/utils"
+], globalScope);
 
 
 var filenames = {
@@ -96,8 +100,17 @@ let AboutRequestPolicy = (function() {
         .registerFactory(self.classID, self.classDescription,
                          self.contractID, self);
   }
-  ProcessEnvironment.addStartupFunction(Environment.LEVELS.INTERFACE,
-                                        registerFactory);
+
+  ProcessEnvironment.addStartupFunction(
+      Environment.LEVELS.INTERFACE,
+      function () {
+        try {
+          registerFactory();
+        } catch (e if e.result === Cr.NS_ERROR_FACTORY_EXISTS) {
+          // When upgrading restartless the old factory might still exist.
+          Utils.runAsync(registerFactory);
+        }
+      });
 
   function unregisterFactory() {
     let registrar = Components.manager
diff --git a/src/content/main/content-policy.jsm b/src/content/main/content-policy.jsm
index c781a3d..4a27159 100644
--- a/src/content/main/content-policy.jsm
+++ b/src/content/main/content-policy.jsm
@@ -24,6 +24,7 @@
 const Ci = Components.interfaces;
 const Cc = Components.classes;
 const Cu = Components.utils;
+const Cr = Components.results;
 
 let EXPORTED_SYMBOLS = ["PolicyImplementation"];
 
@@ -75,8 +76,17 @@ let PolicyImplementation = (function() {
           .getService(Ci.nsIMIMEService);
     }
   }
-  ProcessEnvironment.addStartupFunction(Environment.LEVELS.INTERFACE,
-                                        register);
+
+  ProcessEnvironment.addStartupFunction(
+      Environment.LEVELS.INTERFACE,
+      function () {
+        try {
+          register();
+        } catch (e if e.result === Cr.NS_ERROR_FACTORY_EXISTS) {
+          // When upgrading restartless the old factory might still exist.
+          Utils.runAsync(register);
+        }
+      });
 
 
   function unregister() {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git



More information about the Pkg-mozext-commits mailing list