From 29159af867f44a24273c227ced50498bb0652ca4 Mon Sep 17 00:00:00 2001 From: Edward Lee Date: Wed, 28 Apr 2010 16:36:41 -0700 Subject: [PATCH] Bug 561005 - Use FakeSvc to grab binary crypto if js-ctypes doesn't work [r=zpao r=mconnor] Lazily load the binary component service onto FakeSvc if ;2 fails to register on Svc. --- services/sync/modules/util.js | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/services/sync/modules/util.js b/services/sync/modules/util.js index 63102f61882..36aef43d26a 100644 --- a/services/sync/modules/util.js +++ b/services/sync/modules/util.js @@ -857,34 +857,21 @@ let FakeSvc = { } }; +// Use the binary WeaveCrypto (;1) if the js-ctypes version (;2) fails to load +// by adding an alias on FakeSvc from ;2 to ;1 +Utils.lazySvc(FakeSvc, "@labs.mozilla.com/Weave/Crypto;2", + "@labs.mozilla.com/Weave/Crypto;1", "IWeaveCrypto"); + /* * Commonly-used services */ -let cryptoContractID = "@labs.mozilla.com/Weave/Crypto"; - -{ - let versSvc = Cc["@mozilla.org/xpcom/version-comparator;1"]. - getService(Ci.nsIVersionComparator); - let appinfo = Cc["@mozilla.org/xre/app-info;1"]. - getService(Ci.nsIXULAppInfo); - let platVers = appinfo.platformVersion; - - if (versSvc.compare(platVers, "1.9.3a3") < 0) { - // use old binary component - cryptoContractID += ";1"; - } else { - // use new JS-CTypes component - cryptoContractID += ";2"; - } -} - let Svc = {}; Svc.Prefs = new Preferences(PREFS_BRANCH); Svc.Obs = Observers; [["Annos", "@mozilla.org/browser/annotation-service;1", "nsIAnnotationService"], ["AppInfo", "@mozilla.org/xre/app-info;1", "nsIXULAppInfo"], ["Bookmark", "@mozilla.org/browser/nav-bookmarks-service;1", "nsINavBookmarksService"], - ["Crypto", cryptoContractID, "IWeaveCrypto"], + ["Crypto", "@labs.mozilla.com/Weave/Crypto;2", "IWeaveCrypto"], ["Directory", "@mozilla.org/file/directory_service;1", "nsIProperties"], ["Env", "@mozilla.org/process/environment;1", "nsIEnvironment"], ["Favicon", "@mozilla.org/browser/favicon-service;1", "nsIFaviconService"],