assume in loaded modules that the resource:// alias has already been added - remove all the templatey code to do that
authorDan Mills <thunder@mozilla.com>
Tue, 11 Dec 2007 11:57:13 -0800
changeset 44310 c1f771c8987ea81a2011a9342c377345be9dec0c
parent 44309 3e65a92ca4237f7a4d46c5ad41b9723131ba544d
child 44311 cba639f9157551ff3effb93e136d856a7906d15a
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
assume in loaded modules that the resource:// alias has already been added - remove all the templatey code to do that
services/sync/modules/crypto.js
services/sync/modules/dav.js
services/sync/modules/engines.js
services/sync/modules/identity.js
services/sync/modules/service.js
services/sync/modules/util.js
services/sync/modules/weave.js
--- a/services/sync/modules/crypto.js
+++ b/services/sync/modules/crypto.js
@@ -36,17 +36,16 @@
 
 const EXPORTED_SYMBOLS = ['WeaveCrypto'];
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 const Cu = Components.utils;
 
-addModuleAlias("weave", "{340c2bbc-ce74-4362-90b5-7c26312808ef}");
 Cu.import("resource://weave/log4moz.js");
 Cu.import("resource://weave/constants.js");
 Cu.import("resource://weave/util.js");
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 function WeaveCrypto() {
   this._init();
@@ -173,24 +172,8 @@ WeaveCrypto.prototype = {
       break;
     default:
       this._log.error("Unknown encryption algorithm: " + algorithm);
       throw 'decrypt failed';
     }
     return out;
   }
 };
-
-function addModuleAlias(alias, extensionId) {
-  let ioSvc = Cc["@mozilla.org/network/io-service;1"]
-    .getService(Ci.nsIIOService);
-  let resProt = ioSvc.getProtocolHandler("resource")
-    .QueryInterface(Ci.nsIResProtocolHandler);
-
-  if (!resProt.hasSubstitution(alias)) {
-    let extMgr = Cc["@mozilla.org/extensions/manager;1"]
-      .getService(Ci.nsIExtensionManager);
-    let loc = extMgr.getInstallLocation(extensionId);
-    let extD = loc.getItemLocation(extensionId);
-    extD.append("modules");
-    resProt.setSubstitution(alias, ioSvc.newFileURI(extD));
-  }
-}
--- a/services/sync/modules/dav.js
+++ b/services/sync/modules/dav.js
@@ -36,17 +36,16 @@
 
 const EXPORTED_SYMBOLS = ['DAVCollection'];
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 const Cu = Components.utils;
 
-addModuleAlias("weave", "{340c2bbc-ce74-4362-90b5-7c26312808ef}");
 Cu.import("resource://weave/log4moz.js");
 Cu.import("resource://weave/util.js");
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 Function.prototype.async = generatorAsync;
 
 /*
@@ -536,24 +535,8 @@ DummyAuthProvider.prototype = {
   onProgress: function DAP_onProgress(aRequest, aContext,
                                       aProgress, aProgressMax) {
   },
 
   onStatus: function DAP_onStatus(aRequest, aContext,
                                   aStatus, aStatusArg) {
   }
 };
-
-function addModuleAlias(alias, extensionId) {
-  let ioSvc = Cc["@mozilla.org/network/io-service;1"]
-    .getService(Ci.nsIIOService);
-  let resProt = ioSvc.getProtocolHandler("resource")
-    .QueryInterface(Ci.nsIResProtocolHandler);
-
-  if (!resProt.hasSubstitution(alias)) {
-    let extMgr = Cc["@mozilla.org/extensions/manager;1"]
-      .getService(Ci.nsIExtensionManager);
-    let loc = extMgr.getInstallLocation(extensionId);
-    let extD = loc.getItemLocation(extensionId);
-    extD.append("modules");
-    resProt.setSubstitution(alias, ioSvc.newFileURI(extD));
-  }
-}
--- a/services/sync/modules/engines.js
+++ b/services/sync/modules/engines.js
@@ -36,17 +36,16 @@
 
 const EXPORTED_SYMBOLS = ['BookmarksEngine'];
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 const Cu = Components.utils;
 
-addModuleAlias("weave", "{340c2bbc-ce74-4362-90b5-7c26312808ef}");
 Cu.import("resource://weave/log4moz.js");
 Cu.import("resource://weave/constants.js");
 Cu.import("resource://weave/util.js");
 Cu.import("resource://weave/crypto.js");
 Cu.import("resource://weave/stores.js");
 Cu.import("resource://weave/syncCores.js");
 
 Function.prototype.async = generatorAsync;
@@ -674,24 +673,8 @@ serializeCommands: function serializeCom
   return json;
 }
 
 serializeConflicts: function serializeConflicts(conflicts) {
   let json = uneval(conflicts);
   json = json.replace(/ {action/g, "\n {action");
   return json;
 }
-
-function addModuleAlias(alias, extensionId) {
-  let ioSvc = Cc["@mozilla.org/network/io-service;1"]
-    .getService(Ci.nsIIOService);
-  let resProt = ioSvc.getProtocolHandler("resource")
-    .QueryInterface(Ci.nsIResProtocolHandler);
-
-  if (!resProt.hasSubstitution(alias)) {
-    let extMgr = Cc["@mozilla.org/extensions/manager;1"]
-      .getService(Ci.nsIExtensionManager);
-    let loc = extMgr.getInstallLocation(extensionId);
-    let extD = loc.getItemLocation(extensionId);
-    extD.append("modules");
-    resProt.setSubstitution(alias, ioSvc.newFileURI(extD));
-  }
-}
--- a/services/sync/modules/identity.js
+++ b/services/sync/modules/identity.js
@@ -36,17 +36,16 @@
 
 const EXPORTED_SYMBOLS = ['Identity'];
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 const Cu = Components.utils;
 
-addModuleAlias("weave", "{340c2bbc-ce74-4362-90b5-7c26312808ef}");
 Cu.import("resource://weave/log4moz.js");
 Cu.import("resource://weave/constants.js");
 Cu.import("resource://weave/util.js");
 
 /*
  * Identity
  * These objects hold a realm, username, and password
  * They can hold a password in memory, but will try to fetch it from
@@ -110,24 +109,8 @@ function setPassword(realm, username, pa
 
   // save the new one
   let nsLoginInfo = new Components.Constructor(
     "@mozilla.org/login-manager/loginInfo;1", Ci.nsILoginInfo, "init");
   let login = new nsLoginInfo('chrome://sync', null, realm,
                               username, password, null, null);
   lm.addLogin(login);
 }
-
-function addModuleAlias(alias, extensionId) {
-  let ioSvc = Cc["@mozilla.org/network/io-service;1"]
-    .getService(Ci.nsIIOService);
-  let resProt = ioSvc.getProtocolHandler("resource")
-    .QueryInterface(Ci.nsIResProtocolHandler);
-
-  if (!resProt.hasSubstitution(alias)) {
-    let extMgr = Cc["@mozilla.org/extensions/manager;1"]
-      .getService(Ci.nsIExtensionManager);
-    let loc = extMgr.getInstallLocation(extensionId);
-    let extD = loc.getItemLocation(extensionId);
-    extD.append("modules");
-    resProt.setSubstitution(alias, ioSvc.newFileURI(extD));
-  }
-}
--- a/services/sync/modules/service.js
+++ b/services/sync/modules/service.js
@@ -36,17 +36,16 @@
 
 const EXPORTED_SYMBOLS = ['WeaveSyncService'];
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 const Cu = Components.utils;
 
-addModuleAlias("weave", "{340c2bbc-ce74-4362-90b5-7c26312808ef}");
 Cu.import("resource://weave/log4moz.js");
 Cu.import("resource://weave/constants.js");
 Cu.import("resource://weave/util.js");
 Cu.import("resource://weave/crypto.js");
 Cu.import("resource://weave/engines.js");
 Cu.import("resource://weave/dav.js");
 Cu.import("resource://weave/identity.js");
 
@@ -424,25 +423,8 @@ WeaveSyncService.prototype = {
 
   resetClient: function BSS_resetClient() {
     if (!this._lock())
       return;
     let self = this;
     this._bmkEngine.resetClient(function() {self._unlock()});
   }
 };
-
-
-function addModuleAlias(alias, extensionId) {
-  let ioSvc = Cc["@mozilla.org/network/io-service;1"]
-    .getService(Ci.nsIIOService);
-  let resProt = ioSvc.getProtocolHandler("resource")
-    .QueryInterface(Ci.nsIResProtocolHandler);
-
-  if (!resProt.hasSubstitution(alias)) {
-    let extMgr = Cc["@mozilla.org/extensions/manager;1"]
-      .getService(Ci.nsIExtensionManager);
-    let loc = extMgr.getInstallLocation(extensionId);
-    let extD = loc.getItemLocation(extensionId);
-    extD.append("modules");
-    resProt.setSubstitution(alias, ioSvc.newFileURI(extD));
-  }
-}
--- a/services/sync/modules/util.js
+++ b/services/sync/modules/util.js
@@ -37,17 +37,16 @@
 const EXPORTED_SYMBOLS = ['deepEquals', 'makeFile', 'makeURI', 'xpath',
 			  'bind2', 'generatorAsync', 'generatorDone', 'EventListener'];
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 const Cu = Components.utils;
 
-addModuleAlias("weave", "{340c2bbc-ce74-4362-90b5-7c26312808ef}");
 Cu.import("resource://weave/constants.js");
 Cu.import("resource://weave/log4moz.js");
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 /*
  * Utility functions
  */
@@ -187,24 +186,8 @@ EventListener.prototype = {
   },
 
   // nsITimerCallback
   notify: function EL_notify(timer) {
     this._log.trace("Timer fired");
     this._handler(timer);
   }
 };
-
-function addModuleAlias(alias, extensionId) {
-  let ioSvc = Cc["@mozilla.org/network/io-service;1"]
-    .getService(Ci.nsIIOService);
-  let resProt = ioSvc.getProtocolHandler("resource")
-    .QueryInterface(Ci.nsIResProtocolHandler);
-
-  if (!resProt.hasSubstitution(alias)) {
-    let extMgr = Cc["@mozilla.org/extensions/manager;1"]
-      .getService(Ci.nsIExtensionManager);
-    let loc = extMgr.getInstallLocation(extensionId);
-    let extD = loc.getItemLocation(extensionId);
-    extD.append("modules");
-    resProt.setSubstitution(alias, ioSvc.newFileURI(extD));
-  }
-}
--- a/services/sync/modules/weave.js
+++ b/services/sync/modules/weave.js
@@ -36,30 +36,13 @@
 
 const EXPORTED_SYMBOLS = ['Weave'];
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 const Cu = Components.utils;
 
-addModuleAlias("weave", "{340c2bbc-ce74-4362-90b5-7c26312808ef}");
 Cu.import("resource://weave/service.js");
 
 let Weave = {};
 //Weave.Crypto = new WeaveCrypto();
 Weave.Service = new WeaveSyncService();
-
-function addModuleAlias(alias, extensionId) {
-  let ioSvc = Cc["@mozilla.org/network/io-service;1"]
-    .getService(Ci.nsIIOService);
-  let resProt = ioSvc.getProtocolHandler("resource")
-    .QueryInterface(Ci.nsIResProtocolHandler);
-
-  if (!resProt.hasSubstitution(alias)) {
-    let extMgr = Cc["@mozilla.org/extensions/manager;1"]
-      .getService(Ci.nsIExtensionManager);
-    let loc = extMgr.getInstallLocation(extensionId);
-    let extD = loc.getItemLocation(extensionId);
-    extD.append("modules");
-    resProt.setSubstitution(alias, ioSvc.newFileURI(extD));
-  }
-}