Bug 564950 - Make more use of mozilla::services, r=surkov, jst, neil, smontagu, roc, joshmoz, gavin, shaver
authorMitchell Field <mitchell.field@live.com.au
Fri, 14 May 2010 18:24:41 +0900
changeset 42314 840fcbf52747568f9011ed58e923acab6b3a5212
parent 42313 b0731e9cd38c004126c637ff8f523a2062507a76
child 42315 897f37baa800ed588a2bc09cfd5528a13731b7ff
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)
reviewerssurkov, jst, neil, smontagu, roc, joshmoz, gavin, shaver
bugs564950
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 564950 - Make more use of mozilla::services, r=surkov, jst, neil, smontagu, roc, joshmoz, gavin, shaver
accessible/src/base/nsAccessNode.cpp
accessible/src/base/nsApplicationAccessible.cpp
caps/src/nsScriptSecurityManager.cpp
chrome/src/nsChromeProtocolHandler.cpp
content/base/src/nsContentUtils.cpp
content/html/document/src/nsMediaDocument.cpp
content/xbl/src/nsXBLDocumentInfo.cpp
content/xslt/src/xslt/txMozillaXSLTProcessor.cpp
content/xul/document/src/nsXULDocument.cpp
content/xul/document/src/nsXULPrototypeCache.cpp
docshell/base/nsDocShell.cpp
dom/base/nsDOMClassInfo.cpp
editor/composer/src/nsEditorSpellCheck.cpp
intl/locale/src/nsLanguageAtomService.cpp
intl/uconv/src/nsCharsetConverterManager.cpp
intl/unicharutil/src/nsEntityConverter.cpp
layout/mathml/nsMathMLChar.cpp
layout/printing/nsPrintData.cpp
layout/style/nsCSSScanner.cpp
layout/xul/base/src/nsMenuFrame.cpp
modules/libpref/src/nsPrefBranch.cpp
modules/plugin/base/src/nsPluginHost.cpp
parser/htmlparser/src/nsParserMsgUtils.cpp
toolkit/components/downloads/src/nsDownloadManager.cpp
toolkit/components/places/src/nsNavHistory.cpp
toolkit/xre/nsAppRunner.cpp
uriloader/base/nsDocLoader.cpp
uriloader/exthandler/nsExternalHelperAppService.cpp
uriloader/exthandler/os2/nsOSHelperAppService.cpp
widget/src/os2/nsRwsService.cpp
widget/src/qt/nsWindow.cpp
widget/src/windows/nsDataObj.cpp
widget/src/windows/nsDeviceContextSpecWin.cpp
widget/src/xpwidgets/nsBaseFilePicker.cpp
xpcom/build/ServiceList.h
xpcom/build/Services.cpp
xpfe/appshell/src/nsAppShellService.cpp
--- a/accessible/src/base/nsAccessNode.cpp
+++ b/accessible/src/base/nsAccessNode.cpp
@@ -249,17 +249,17 @@ nsAccessNode::GetApplicationAccessible()
   }
 
   return gApplicationAccessible;
 }
 
 void nsAccessNode::InitXPAccessibility()
 {
   nsCOMPtr<nsIStringBundleService> stringBundleService =
-    do_GetService(NS_STRINGBUNDLE_CONTRACTID);
+    mozilla::services::GetStringBundleService();
   if (stringBundleService) {
     // Static variables are released in ShutdownAllXPAccessibility();
     stringBundleService->CreateBundle(ACCESSIBLE_BUNDLE_URL, 
                                       &gStringBundle);
     stringBundleService->CreateBundle(PLATFORM_KEYS_BUNDLE_URL, 
                                       &gKeyStringBundle);
   }
 
--- a/accessible/src/base/nsApplicationAccessible.cpp
+++ b/accessible/src/base/nsApplicationAccessible.cpp
@@ -45,16 +45,17 @@
 #include "nsAccessibilityService.h"
 #include "nsAccUtils.h"
 
 #include "nsIComponentManager.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMWindow.h"
 #include "nsIWindowMediator.h"
 #include "nsServiceManagerUtils.h"
+#include "mozilla/Services.h"
 
 nsApplicationAccessible::nsApplicationAccessible() :
   nsAccessibleWrap(nsnull, nsnull)
 {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsISupports
@@ -78,17 +79,17 @@ nsApplicationAccessible::GetRootDocument
 // nsIAccessible
 
 NS_IMETHODIMP
 nsApplicationAccessible::GetName(nsAString& aName)
 {
   aName.Truncate();
 
   nsCOMPtr<nsIStringBundleService> bundleService =
-    do_GetService(NS_STRINGBUNDLE_CONTRACTID);
+    mozilla::services::GetStringBundleService();
 
   NS_ASSERTION(bundleService, "String bundle service must be present!");
   NS_ENSURE_STATE(bundleService);
 
   nsCOMPtr<nsIStringBundle> bundle;
   nsresult rv = bundleService->CreateBundle("chrome://branding/locale/brand.properties",
                                             getter_AddRefs(bundle));
   NS_ENSURE_SUCCESS(rv, rv);
--- a/caps/src/nsScriptSecurityManager.cpp
+++ b/caps/src/nsScriptSecurityManager.cpp
@@ -3383,18 +3383,20 @@ nsresult nsScriptSecurityManager::Init()
         sEnabledID = STRING_TO_JSVAL(::JS_InternString(cx, "enabled"));
     ::JS_EndRequest(cx);
 
     InitPrefs();
 
     nsresult rv = CallGetService(NS_IOSERVICE_CONTRACTID, &sIOService);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+    nsCOMPtr<nsIStringBundleService> bundleService =
+        mozilla::services::GetStringBundleService();
+    if (!bundleService)
+        return NS_ERROR_FAILURE;
 
     rv = bundleService->CreateBundle("chrome://global/locale/security/caps.properties", &sStrBundle);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Create our system principal singleton
     nsRefPtr<nsSystemPrincipal> system = new nsSystemPrincipal();
     NS_ENSURE_TRUE(system, NS_ERROR_OUT_OF_MEMORY);
 
--- a/chrome/src/nsChromeProtocolHandler.cpp
+++ b/chrome/src/nsChromeProtocolHandler.cpp
@@ -178,17 +178,18 @@ nsChromeProtocolHandler::NewChannel(nsIU
     }
 #endif
 
     nsCOMPtr<nsIChannel> result;
 
     if (!nsChromeRegistry::gChromeRegistry) {
         // We don't actually want this ref, we just want the service to
         // initialize if it hasn't already.
-        nsCOMPtr<nsIChromeRegistry> reg(do_GetService(NS_CHROMEREGISTRY_CONTRACTID));
+        nsCOMPtr<nsIChromeRegistry> reg =
+            mozilla::services::GetChromeRegistryService();
         NS_ENSURE_TRUE(nsChromeRegistry::gChromeRegistry, NS_ERROR_FAILURE);
     }
 
     nsCOMPtr<nsIURI> resolvedURI;
     rv = nsChromeRegistry::gChromeRegistry->ConvertChromeURL(aURI, getter_AddRefs(resolvedURI));
     if (NS_FAILED(rv)) {
 #ifdef DEBUG
         nsCAutoString spec;
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -2975,17 +2975,17 @@ nsContentUtils::GetWrapperSafeScriptFile
                                              nsIURI *aURI,
                                              nsACString& aScriptURI)
 {
   PRBool scriptFileNameModified = PR_FALSE;
   aURI->GetSpec(aScriptURI);
 
   if (IsChromeDoc(aDocument)) {
     nsCOMPtr<nsIChromeRegistry> chromeReg =
-      do_GetService(NS_CHROMEREGISTRY_CONTRACTID);
+      mozilla::services::GetChromeRegistryService();
 
     if (!chromeReg) {
       // If we're running w/o a chrome registry we won't modify any
       // script file names.
 
       return scriptFileNameModified;
     }
 
--- a/content/html/document/src/nsMediaDocument.cpp
+++ b/content/html/document/src/nsMediaDocument.cpp
@@ -136,18 +136,18 @@ nsMediaDocument::~nsMediaDocument()
 
 nsresult
 nsMediaDocument::Init()
 {
   nsresult rv = nsHTMLDocument::Init();
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Create a bundle for the localization
-  nsCOMPtr<nsIStringBundleService> stringService(
-    do_GetService(NS_STRINGBUNDLE_CONTRACTID));
+  nsCOMPtr<nsIStringBundleService> stringService =
+    mozilla::services::GetStringBundleService();
   if (stringService) {
     stringService->CreateBundle(NSMEDIADOCUMENT_PROPERTIES_URI,
                                 getter_AddRefs(mStringBundle));
   }
 
   return NS_OK;
 }
 
--- a/content/xbl/src/nsXBLDocumentInfo.cpp
+++ b/content/xbl/src/nsXBLDocumentInfo.cpp
@@ -49,16 +49,17 @@
 #include "nsIURI.h"
 #include "nsIConsoleService.h"
 #include "nsIScriptError.h"
 #include "nsIChromeRegistry.h"
 #include "nsIPrincipal.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsContentUtils.h"
 #include "nsDOMJSUtils.h"
+#include "mozilla/Services.h"
  
 static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
 
 // An XBLDocumentInfo object has a special context associated with it which we can use to pre-compile 
 // properties and methods of XBL bindings against.
 class nsXBLDocGlobalObject : public nsIScriptGlobalObject,
                              public nsIScriptObjectPrincipal
 {
@@ -501,17 +502,18 @@ nsXBLDocumentInfo::nsXBLDocumentInfo(nsI
     mScriptAccess(PR_TRUE),
     mIsChrome(PR_FALSE),
     mBindingTable(nsnull),
     mFirstBinding(nsnull)
 {
   nsIURI* uri = aDocument->GetDocumentURI();
   if (IsChromeURI(uri)) {
     // Cache whether or not this chrome XBL can execute scripts.
-    nsCOMPtr<nsIXULChromeRegistry> reg(do_GetService(NS_CHROMEREGISTRY_CONTRACTID));
+    nsCOMPtr<nsIXULChromeRegistry> reg =
+      mozilla::services::GetXULChromeRegistryService();
     if (reg) {
       PRBool allow = PR_TRUE;
       reg->AllowScriptsForPackage(uri, &allow);
       mScriptAccess = allow;
     }
     mIsChrome = PR_TRUE;
   }
 }
--- a/content/xslt/src/xslt/txMozillaXSLTProcessor.cpp
+++ b/content/xslt/src/xslt/txMozillaXSLTProcessor.cpp
@@ -1075,17 +1075,17 @@ txMozillaXSLTProcessor::reportError(nsre
 
     mTransformResult = aResult;
 
     if (aErrorText) {
         mErrorText.Assign(aErrorText);
     }
     else {
         nsCOMPtr<nsIStringBundleService> sbs =
-            do_GetService(NS_STRINGBUNDLE_CONTRACTID);
+            mozilla::services::GetStringBundleService();
         if (sbs) {
             nsXPIDLString errorText;
             sbs->FormatStatusMessage(aResult, EmptyString().get(),
                                      getter_Copies(errorText));
 
             nsXPIDLString errorMessage;
             nsCOMPtr<nsIStringBundle> bundle;
             sbs->CreateBundle(XSLT_MSGS_URL, getter_AddRefs(bundle));
--- a/content/xul/document/src/nsXULDocument.cpp
+++ b/content/xul/document/src/nsXULDocument.cpp
@@ -575,17 +575,17 @@ nsXULDocument::EndLoad()
     // the cache earlier in nsXULDocument::StartDocumentLoad.
     if (useXULCache && mIsWritingFastLoad && isChrome &&
         mMasterPrototype != mCurrentPrototype) {
         nsXULPrototypeCache::GetInstance()->WritePrototype(mCurrentPrototype);
     }
 
     if (isChrome) {
         nsCOMPtr<nsIXULOverlayProvider> reg =
-            do_GetService(NS_CHROMEREGISTRY_CONTRACTID);
+            mozilla::services::GetXULOverlayProviderService();
 
         if (reg) {
             nsCOMPtr<nsISimpleEnumerator> overlays;
             rv = reg->GetStyleOverlays(uri, getter_AddRefs(overlays));
             if (NS_FAILED(rv)) return;
 
             PRBool moreSheets;
             nsCOMPtr<nsISupports> next;
@@ -2621,17 +2621,18 @@ nsXULDocument::AddChromeOverlays()
 {
     nsresult rv;
 
     nsCOMPtr<nsIURI> docUri = mCurrentPrototype->GetURI();
 
     /* overlays only apply to chrome, skip all content URIs */
     if (!IsChromeURI(docUri)) return NS_OK;
 
-    nsCOMPtr<nsIXULOverlayProvider> chromeReg(do_GetService(NS_CHROMEREGISTRY_CONTRACTID));
+    nsCOMPtr<nsIXULOverlayProvider> chromeReg =
+        mozilla::services::GetXULOverlayProviderService();
     // In embedding situations, the chrome registry may not provide overlays,
     // or even exist at all; that's OK.
     NS_ENSURE_TRUE(chromeReg, NS_OK);
 
     nsCOMPtr<nsISimpleEnumerator> overlays;
     rv = chromeReg->GetXULOverlays(docUri, getter_AddRefs(overlays));
     NS_ENSURE_SUCCESS(rv, rv);
 
@@ -4631,17 +4632,17 @@ nsXULDocument::IsDocumentRightToLeft()
             case 1: return PR_TRUE;
             default: break; // otherwise, not a valid value, so fall through
         }
     }
 
     // otherwise, get the locale from the chrome registry and
     // look up the intl.uidirection.<locale> preference
     nsCOMPtr<nsIXULChromeRegistry> reg =
-        do_GetService(NS_CHROMEREGISTRY_CONTRACTID);
+        mozilla::services::GetXULChromeRegistryService();
     if (!reg)
         return PR_FALSE;
 
     nsCAutoString package;
     PRBool isChrome;
     if (NS_SUCCEEDED(mDocumentURI->SchemeIs("chrome", &isChrome)) &&
         isChrome) {
         mDocumentURI->GetHostPort(package);
--- a/content/xul/document/src/nsXULPrototypeCache.cpp
+++ b/content/xul/document/src/nsXULPrototypeCache.cpp
@@ -747,19 +747,20 @@ nsXULPrototypeCache::StartFastLoad(nsIUR
     // Give the FastLoad service an object by which it can get or create a
     // file output stream given an input stream on the same file.
     nsXULFastLoadFileIO* xio = new nsXULFastLoadFileIO(file);
     nsCOMPtr<nsIFastLoadFileIO> io = static_cast<nsIFastLoadFileIO*>(xio);
     if (! io)
         return NS_ERROR_OUT_OF_MEMORY;
     fastLoadService->SetFileIO(io);
 
-    nsCOMPtr<nsIXULChromeRegistry> chromeReg(do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv));
-    if (NS_FAILED(rv))
-        return rv;
+    nsCOMPtr<nsIXULChromeRegistry> chromeReg =
+        mozilla::services::GetXULChromeRegistryService();
+    if (!chromeReg)
+        return NS_ERROR_FAILURE;
 
     // XXXbe we assume the first package's locale is the same as the locale of
     // all subsequent packages of FastLoaded chrome URIs....
     nsCAutoString package;
     rv = aURI->GetHost(package);
     if (NS_FAILED(rv))
         return rv;
 
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -10172,27 +10172,27 @@ nsDocShell::GetLoadType(PRUint32 * aLoad
 {
     *aLoadType = mLoadType;
     return NS_OK;
 }
 
 nsresult
 nsDocShell::ConfirmRepost(PRBool * aRepost)
 {
-  nsresult rv;
   nsCOMPtr<nsIPrompt> prompter;
   CallGetInterface(this, static_cast<nsIPrompt**>(getter_AddRefs(prompter)));
 
-  nsCOMPtr<nsIStringBundleService> 
-      stringBundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIStringBundleService> stringBundleService =
+    mozilla::services::GetStringBundleService();
+  if (!stringBundleService)
+    return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIStringBundle> appBundle;
-  rv = stringBundleService->CreateBundle(kAppstringsBundleURL,
-                                         getter_AddRefs(appBundle));
+  nsresult rv = stringBundleService->CreateBundle(kAppstringsBundleURL,
+                                                  getter_AddRefs(appBundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIStringBundle> brandBundle;
   rv = stringBundleService->CreateBundle(kBrandBundleURL, getter_AddRefs(brandBundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ASSERTION(prompter && brandBundle && appBundle,
                "Unable to set up repost prompter.");
@@ -10235,18 +10235,18 @@ nsDocShell::ConfirmRepost(PRBool * aRepo
 
 NS_IMETHODIMP
 nsDocShell::GetPromptAndStringBundle(nsIPrompt ** aPrompt,
                                      nsIStringBundle ** aStringBundle)
 {
     NS_ENSURE_SUCCESS(GetInterface(NS_GET_IID(nsIPrompt), (void **) aPrompt),
                       NS_ERROR_FAILURE);
 
-    nsCOMPtr<nsIStringBundleService>
-        stringBundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID));
+    nsCOMPtr<nsIStringBundleService> stringBundleService =
+      mozilla::services::GetStringBundleService();
     NS_ENSURE_TRUE(stringBundleService, NS_ERROR_FAILURE);
 
     NS_ENSURE_SUCCESS(stringBundleService->
                       CreateBundle(kAppstringsBundleURL,
                                    aStringBundle),
                       NS_ERROR_FAILURE);
 
     return NS_OK;
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -1536,18 +1536,18 @@ FindObjectClass(JSObject* aGlobalObject)
   } while (proto);
 
   sObjectClass = obj->getClass();
 }
 
 static void
 PrintWarningOnConsole(JSContext *cx, const char *stringBundleProperty)
 {
-  nsCOMPtr<nsIStringBundleService>
-    stringService(do_GetService(NS_STRINGBUNDLE_CONTRACTID));
+  nsCOMPtr<nsIStringBundleService> stringService =
+    mozilla::services::GetStringBundleService();
   if (!stringService) {
     return;
   }
 
   nsCOMPtr<nsIStringBundle> bundle;
   stringService->CreateBundle(kDOMStringBundleURL, getter_AddRefs(bundle));
   if (!bundle) {
     return;
--- a/editor/composer/src/nsEditorSpellCheck.cpp
+++ b/editor/composer/src/nsEditorSpellCheck.cpp
@@ -53,16 +53,17 @@
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
 #include "nsISupportsPrimitives.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIChromeRegistry.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "nsITextServicesFilter.h"
+#include "mozilla/Services.h"
 
 NS_IMPL_ISUPPORTS1(nsEditorSpellCheck,
                    nsIEditorSpellCheck)
 
 nsEditorSpellCheck::nsEditorSpellCheck()
   : mSuggestedWordIndex(0)
   , mDictionaryIndex(0)
 {
@@ -192,19 +193,19 @@ nsEditorSpellCheck::InitSpellChecker(nsI
   }
 
   if (dictName.IsEmpty())
   {
     // Prefs didn't give us a dictionary name, so just get the current
     // locale and use that as the default dictionary name!
 
     nsCOMPtr<nsIXULChromeRegistry> packageRegistry =
-      do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv);
+      mozilla::services::GetXULChromeRegistryService();
 
-    if (NS_SUCCEEDED(rv) && packageRegistry) {
+    if (packageRegistry) {
       nsCAutoString utf8DictName;
       rv = packageRegistry->GetSelectedLocale(NS_LITERAL_CSTRING("global"),
                                               utf8DictName);
       AppendUTF8toUTF16(utf8DictName, dictName);
     }
   }
 
   PRBool setDictionary = PR_FALSE;
--- a/intl/locale/src/nsLanguageAtomService.cpp
+++ b/intl/locale/src/nsLanguageAtomService.cpp
@@ -38,37 +38,38 @@
 #include "nsIComponentManager.h"
 #include "nsLanguageAtomService.h"
 #include "nsICharsetConverterManager.h"
 #include "nsILocaleService.h"
 #include "nsXPIDLString.h"
 #include "nsUnicharUtils.h"
 #include "nsIServiceManager.h"
 #include "nsIAtom.h"
+#include "mozilla/Services.h"
 
 NS_IMPL_ISUPPORTS1(nsLanguageAtomService, nsILanguageAtomService)
 
 nsLanguageAtomService::nsLanguageAtomService()
 {
   mLangToGroup.Init();
 }
 
 nsresult
 nsLanguageAtomService::InitLangGroupTable()
 {
-  if (mLangGroups) return NS_OK;
-  nsresult rv;
-  
+  if (mLangGroups)
+    return NS_OK;
+
   nsCOMPtr<nsIStringBundleService> bundleService =
-    do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  if (NS_FAILED(rv)) return rv;
+    mozilla::services::GetStringBundleService();
+  if (!bundleService)
+    return NS_ERROR_FAILURE;
 
-  rv = bundleService->CreateBundle("resource://gre/res/langGroups.properties",
-                                   getter_AddRefs(mLangGroups));
-  return rv;
+  return bundleService->CreateBundle("resource://gre/res/langGroups.properties",
+                                     getter_AddRefs(mLangGroups));
 }
 
 nsIAtom*
 nsLanguageAtomService::LookupLanguage(const nsAString &aLanguage,
                                       nsresult *aError)
 {
   nsAutoString lowered(aLanguage);
   ToLowerCase(lowered);
--- a/intl/uconv/src/nsCharsetConverterManager.cpp
+++ b/intl/uconv/src/nsCharsetConverterManager.cpp
@@ -47,16 +47,17 @@
 #include "nsEncoderDecoderUtils.h"
 #include "nsIStringBundle.h"
 #include "nsUConvDll.h"
 #include "prmem.h"
 #include "nsCRT.h"
 #include "nsTArray.h"
 #include "nsStringEnumerator.h"
 #include "nsThreadUtils.h"
+#include "mozilla/Services.h"
 
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 
 // just for CONTRACTIDs
 #include "nsCharsetConverterManager.h"
 
 #ifdef MOZ_USE_NATIVE_UCONV
@@ -106,22 +107,20 @@ nsCharsetConverterManager::RegisterConve
   return catman->AddCategoryEntry(aCategory, aURL, "",
                                   PR_TRUE, PR_TRUE, nsnull);
 }
 
 nsresult nsCharsetConverterManager::LoadExtensibleBundle(
                                     const char* aCategory, 
                                     nsIStringBundle ** aResult)
 {
-  nsresult rv = NS_OK;
-
-  nsCOMPtr<nsIStringBundleService> sbServ = 
-           do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  if (NS_FAILED(rv))
-    return rv;
+  nsCOMPtr<nsIStringBundleService> sbServ =
+    mozilla::services::GetStringBundleService();
+  if (!sbServ)
+    return NS_ERROR_FAILURE;
 
   return sbServ->CreateExtensibleBundle(aCategory, aResult);
 }
 
 nsresult nsCharsetConverterManager::GetBundleValue(nsIStringBundle * aBundle, 
                                                    const char * aName, 
                                                    const nsAFlatString& aProp, 
                                                    PRUnichar ** aResult)
--- a/intl/unicharutil/src/nsEntityConverter.cpp
+++ b/intl/unicharutil/src/nsEntityConverter.cpp
@@ -40,16 +40,17 @@
 #include "nsIServiceManager.h"
 #include "nsIComponentManager.h"
 #include "nsReadableUtils.h"
 #include "nsCRT.h"
 #include "nsLiteralString.h"
 #include "nsXPIDLString.h"
 #include "nsString.h"
 #include "nsUnicharUtils.h"
+#include "mozilla/Services.h"
 
 //
 // implementation methods
 //
 nsEntityConverter::nsEntityConverter()
 :	mVersionList(NULL),
   mVersionListLength(0)
 {
@@ -59,24 +60,24 @@ nsEntityConverter::~nsEntityConverter()
 {
   if (NULL != mVersionList) delete [] mVersionList;
 }
 
 NS_IMETHODIMP 
 nsEntityConverter::LoadVersionPropertyFile()
 {
     NS_NAMED_LITERAL_CSTRING(url, "resource://gre/res/entityTables/htmlEntityVersions.properties");
-	nsresult rv;
+
     nsCOMPtr<nsIStringBundleService> bundleService =
-        do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-
-    if (NS_FAILED(rv)) return rv;
+        mozilla::services::GetStringBundleService();
+    if (!bundleService)
+        return NS_ERROR_FAILURE;
     
     nsCOMPtr<nsIStringBundle> entities;
-    rv = bundleService->CreateBundle(url.get(), getter_AddRefs(entities));
+    nsresult rv = bundleService->CreateBundle(url.get(), getter_AddRefs(entities));
     if (NS_FAILED(rv)) return rv;
     
     PRInt32	result;
 
     nsAutoString key;
     nsXPIDLString value;
     rv = entities->GetStringFromName(NS_LITERAL_STRING("length").get(),
                                      getter_Copies(value));
--- a/layout/mathml/nsMathMLChar.cpp
+++ b/layout/mathml/nsMathMLChar.cpp
@@ -146,17 +146,18 @@ CheckFontExistence(nsPresContext* aPresC
 }
 
 #if ALERT_MISSING_FONTS
 // alert the user if some of the needed MathML fonts are not installed.
 // it is non-modal (i.e., it doesn't wait for input from the user)
 static void
 AlertMissingFonts(nsString& aMissingFonts)
 {
-  nsCOMPtr<nsIStringBundleService> sbs(do_GetService(NS_STRINGBUNDLE_CONTRACTID));
+  nsCOMPtr<nsIStringBundleService> sbs =
+    mozilla::services::GetStringBundleService();
   if (!sbs)
     return;
 
   nsCOMPtr<nsIStringBundle> sb;
   sbs->CreateBundle("resource://gre/res/fonts/mathfont.properties", getter_AddRefs(sb));
   if (!sb)
     return;
 
--- a/layout/printing/nsPrintData.cpp
+++ b/layout/printing/nsPrintData.cpp
@@ -37,16 +37,17 @@
 
 #include "nsPrintData.h"
 
 #include "nsIStringBundle.h"
 #include "nsIServiceManager.h"
 #include "nsPrintObject.h"
 #include "nsPrintPreviewListener.h"
 #include "nsIWebProgressListener.h"
+#include "mozilla/Services.h"
 
 //-----------------------------------------------------
 // PR LOGGING
 #ifdef MOZ_LOGGING
 #define FORCE_PR_LOG /* Allow logging in the release build */
 #endif
 
 #include "prlog.h"
@@ -70,17 +71,18 @@ nsPrintData::nsPrintData(ePrintDataType 
   mIsAborted(PR_FALSE), mPreparingForPrint(PR_FALSE), mDocWasToBeDestroyed(PR_FALSE),
   mShrinkToFit(PR_FALSE), mPrintFrameType(nsIPrintSettings::kFramesAsIs), 
   mNumPrintablePages(0), mNumPagesPrinted(0),
   mShrinkRatio(1.0), mOrigDCScale(1.0), mPPEventListeners(NULL), 
   mBrandName(nsnull)
 {
 
   nsCOMPtr<nsIStringBundle> brandBundle;
-  nsCOMPtr<nsIStringBundleService> svc( do_GetService( NS_STRINGBUNDLE_CONTRACTID ) );
+  nsCOMPtr<nsIStringBundleService> svc =
+    mozilla::services::GetStringBundleService();
   if (svc) {
     svc->CreateBundle( "chrome://branding/locale/brand.properties", getter_AddRefs( brandBundle ) );
     if (brandBundle) {
       brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(), &mBrandName );
     }
   }
 
   if (!mBrandName) {
--- a/layout/style/nsCSSScanner.cpp
+++ b/layout/style/nsCSSScanner.cpp
@@ -52,16 +52,17 @@
 #include "nsIServiceManager.h"
 #include "nsIComponentManager.h"
 #include "nsReadableUtils.h"
 #include "nsIURI.h"
 #include "nsIConsoleService.h"
 #include "nsIScriptError.h"
 #include "nsIStringBundle.h"
 #include "nsContentUtils.h"
+#include "mozilla/Services.h"
 
 #ifdef CSS_REPORT_PARSE_ERRORS
 static PRBool gReportErrors = PR_TRUE;
 static nsIConsoleService *gConsoleService;
 static nsIFactory *gScriptErrorFactory;
 static nsIStringBundle *gStringBundle;
 #endif
 
@@ -442,17 +443,17 @@ nsCSSScanner::OutputError()
 
 static PRBool
 InitStringBundle()
 {
   if (gStringBundle)
     return PR_TRUE;
 
   nsCOMPtr<nsIStringBundleService> sbs =
-    do_GetService(NS_STRINGBUNDLE_CONTRACTID);
+    mozilla::services::GetStringBundleService();
   if (!sbs)
     return PR_FALSE;
 
   nsresult rv = 
     sbs->CreateBundle("chrome://global/locale/css.properties", &gStringBundle);
   if (NS_FAILED(rv)) {
     gStringBundle = nsnull;
     return PR_FALSE;
--- a/layout/xul/base/src/nsMenuFrame.cpp
+++ b/layout/xul/base/src/nsMenuFrame.cpp
@@ -77,16 +77,17 @@
 #include "nsIStringBundle.h"
 #include "nsGUIEvent.h"
 #include "nsContentUtils.h"
 #include "nsDisplayList.h"
 #include "nsIReflowCallback.h"
 #include "nsISound.h"
 #include "nsEventStateManager.h"
 #include "nsIDOMXULMenuListElement.h"
+#include "mozilla/Services.h"
 
 #define NS_MENU_POPUP_LIST_INDEX 0
 
 #if defined(XP_WIN) || defined(XP_OS2)
 #define NSCONTEXTMENUISMOUSEUP 1
 #endif
 
 static PRInt32 gEatMouseMove = PR_FALSE;
@@ -266,23 +267,23 @@ nsMenuFrame::Init(nsIContent*      aCont
   mTimerMediator = new nsMenuTimerMediator(this);
   if (NS_UNLIKELY(!mTimerMediator))
     return NS_ERROR_OUT_OF_MEMORY;
 
   InitMenuParent(aParent);
 
   //load the display strings for the keyboard accelerators, but only once
   if (gRefCnt++ == 0) {
-    
-    nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
+    nsCOMPtr<nsIStringBundleService> bundleService =
+      mozilla::services::GetStringBundleService();
     nsCOMPtr<nsIStringBundle> bundle;
-    if (NS_SUCCEEDED(rv) && bundleService) {
+    if (bundleService) {
       rv = bundleService->CreateBundle( "chrome://global-platform/locale/platformKeys.properties",
                                         getter_AddRefs(bundle));
-    }    
+    }
     
     NS_ASSERTION(NS_SUCCEEDED(rv) && bundle, "chrome://global/locale/platformKeys.properties could not be loaded");
     nsXPIDLString shiftModifier;
     nsXPIDLString metaModifier;
     nsXPIDLString altModifier;
     nsXPIDLString controlModifier;
     nsXPIDLString modifierSeparator;
     if (NS_SUCCEEDED(rv) && bundle) {
@@ -1050,18 +1051,19 @@ nsMenuFrame::BuildAcceleratorText()
     if (!accelString.IsEmpty()) {
       ToUpperCase(accelString);
     } else {
       nsAutoString keyCode;
       keyElement->GetAttr(kNameSpaceID_None, nsGkAtoms::keycode, keyCode);
       ToUpperCase(keyCode);
 
       nsresult rv;
-      nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
-      if (NS_SUCCEEDED(rv) && bundleService) {
+      nsCOMPtr<nsIStringBundleService> bundleService =
+        mozilla::services::GetStringBundleService();
+      if (bundleService) {
         nsCOMPtr<nsIStringBundle> bundle;
         rv = bundleService->CreateBundle("chrome://global/locale/keys.properties",
                                          getter_AddRefs(bundle));
 
         if (NS_SUCCEEDED(rv) && bundle) {
           nsXPIDLString keyName;
           rv = bundle->GetStringFromName(keyCode.get(), getter_Copies(keyName));
           if (keyName)
--- a/modules/libpref/src/nsPrefBranch.cpp
+++ b/modules/libpref/src/nsPrefBranch.cpp
@@ -748,21 +748,21 @@ nsresult nsPrefBranch::GetDefaultFromPro
   nsresult rv;
 
   // the default value contains a URL to a .properties file
     
   nsXPIDLCString propertyFileURL;
   rv = PREF_CopyCharPref(aPrefName, getter_Copies(propertyFileURL), PR_TRUE);
   if (NS_FAILED(rv))
     return rv;
-    
+
   nsCOMPtr<nsIStringBundleService> bundleService =
-      do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  if (NS_FAILED(rv))
-    return rv;
+    mozilla::services::GetStringBundleService();
+  if (!bundleService)
+    return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIStringBundle> bundle;
   rv = bundleService->CreateBundle(propertyFileURL,
                                    getter_AddRefs(bundle));
   if (NS_FAILED(rv))
     return rv;
 
   // string names are in unicode
--- a/modules/plugin/base/src/nsPluginHost.cpp
+++ b/modules/plugin/base/src/nsPluginHost.cpp
@@ -4585,19 +4585,20 @@ nsPluginHost::HandleBadPlugin(PRLibrary*
 
   nsCOMPtr<nsIPluginInstanceOwner> owner;
   if (aInstance)
     aInstance->GetOwner(getter_AddRefs(owner));
 
   nsCOMPtr<nsIPrompt> prompt;
   GetPrompt(owner, getter_AddRefs(prompt));
   if (prompt) {
-    nsCOMPtr<nsIStringBundleService> strings(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
-    if (NS_FAILED(rv))
-      return rv;
+    nsCOMPtr<nsIStringBundleService> strings =
+      mozilla::services::GetStringBundleService();
+    if (!strings)
+      return NS_ERROR_FAILURE;
 
     nsCOMPtr<nsIStringBundle> bundle;
     rv = strings->CreateBundle(BRAND_PROPERTIES_URL, getter_AddRefs(bundle));
     if (NS_FAILED(rv))
       return rv;
 
     nsXPIDLString brandName;
     if (NS_FAILED(rv = bundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
--- a/parser/htmlparser/src/nsParserMsgUtils.cpp
+++ b/parser/htmlparser/src/nsParserMsgUtils.cpp
@@ -35,31 +35,31 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsIServiceManager.h"
 #include "nsIStringBundle.h"
 #include "nsXPIDLString.h"
 #include "nsParserMsgUtils.h"
 #include "nsNetCID.h"
+#include "mozilla/Services.h"
 
 static nsresult GetBundle(const char * aPropFileName, nsIStringBundle **aBundle)
 {
   NS_ENSURE_ARG_POINTER(aPropFileName);
   NS_ENSURE_ARG_POINTER(aBundle);
 
   // Create a bundle for the localization
-  nsresult rv;
-  
-  nsCOMPtr<nsIStringBundleService> stringService = 
-    do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  if (NS_SUCCEEDED(rv))
-    rv = stringService->CreateBundle(aPropFileName, aBundle);
-  
-  return rv;
+
+  nsCOMPtr<nsIStringBundleService> stringService =
+    mozilla::services::GetStringBundleService();
+  if (!stringService)
+    return NS_ERROR_FAILURE;
+
+  return stringService->CreateBundle(aPropFileName, aBundle);
 }
 
 nsresult
 nsParserMsgUtils::GetLocalizedStringByName(const char * aPropFileName, const char* aKey, nsString& oVal)
 {
   oVal.Truncate();
 
   NS_ENSURE_ARG_POINTER(aKey);
--- a/toolkit/components/downloads/src/nsDownloadManager.cpp
+++ b/toolkit/components/downloads/src/nsDownloadManager.cpp
@@ -841,23 +841,22 @@ nsDownloadManager::Init()
       (void)oldDownloadsFile->Remove(PR_FALSE);
     }
   }
 
   mObserverService = mozilla::services::GetObserverService();
   if (!mObserverService)
     return NS_ERROR_FAILURE;
 
-  nsresult rv;
-
   nsCOMPtr<nsIStringBundleService> bundleService =
-    do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = InitDB();
+    mozilla::services::GetStringBundleService();
+  if (!bundleService)
+    return NS_ERROR_FAILURE;
+
+  nsresult rv = InitDB();
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = bundleService->CreateBundle(DOWNLOAD_MANAGER_BUNDLE,
                                    getter_AddRefs(mBundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
 #ifdef DOWNLOAD_SCANNER
   mScanner = new nsDownloadScanner();
--- a/toolkit/components/places/src/nsNavHistory.cpp
+++ b/toolkit/components/places/src/nsNavHistory.cpp
@@ -8082,32 +8082,32 @@ nsNavHistory::GetCollation()
   return mCollation;
 }
 
 nsIStringBundle *
 nsNavHistory::GetBundle()
 {
   if (!mBundle) {
     nsCOMPtr<nsIStringBundleService> bundleService =
-      do_GetService(NS_STRINGBUNDLE_CONTRACTID);
+      mozilla::services::GetStringBundleService();
     NS_ENSURE_TRUE(bundleService, nsnull);
     nsresult rv = bundleService->CreateBundle(
         "chrome://places/locale/places.properties",
         getter_AddRefs(mBundle));
     NS_ENSURE_SUCCESS(rv, nsnull);
   }
   return mBundle;
 }
 
 nsIStringBundle *
 nsNavHistory::GetDateFormatBundle()
 {
   if (!mDateFormatBundle) {
     nsCOMPtr<nsIStringBundleService> bundleService =
-      do_GetService(NS_STRINGBUNDLE_CONTRACTID);
+      mozilla::services::GetStringBundleService();
     NS_ENSURE_TRUE(bundleService, nsnull);
     nsresult rv = bundleService->CreateBundle(
         "chrome://global/locale/dateFormat.properties",
         getter_AddRefs(mDateFormatBundle));
     NS_ENSURE_SUCCESS(rv, nsnull);
   }
   return mDateFormatBundle;
 }
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -1239,17 +1239,18 @@ ScopedXPCOMStartup::SetWindowCreator(nsI
 
   rv = registrar->RegisterFactory(kNativeAppSupportCID,
                                   "Native App Support",
                                   NS_NATIVEAPPSUPPORT_CONTRACTID,
                                   nativeFactory);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Inform the chrome registry about OS accessibility
-  nsCOMPtr<nsIToolkitChromeRegistry> cr (do_GetService(NS_CHROMEREGISTRY_CONTRACTID));
+  nsCOMPtr<nsIToolkitChromeRegistry> cr =
+    mozilla::services::GetToolkitChromeRegistryService();
   if (cr)
     cr->CheckForOSAccessibility();
 
   nsCOMPtr<nsIWindowCreator> creator (do_GetService(NS_APPSTARTUP_CONTRACTID));
   if (!creator) return NS_ERROR_UNEXPECTED;
 
   nsCOMPtr<nsIWindowWatcher> wwatch
     (do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv));
@@ -1798,18 +1799,18 @@ ProfileLockedDialog(nsILocalFile* aProfi
   rv = xpcom.Initialize();
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = xpcom.DoAutoreg();
   rv |= xpcom.SetWindowCreator(aNative);
   NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
 
   { //extra scoping is needed so we release these components before xpcom shutdown
-    nsCOMPtr<nsIStringBundleService> sbs
-      (do_GetService(NS_STRINGBUNDLE_CONTRACTID));
+    nsCOMPtr<nsIStringBundleService> sbs =
+      mozilla::services::GetStringBundleService();
     NS_ENSURE_TRUE(sbs, NS_ERROR_FAILURE);
 
     nsCOMPtr<nsIStringBundle> sb;
     sbs->CreateBundle(kProfileProperties, getter_AddRefs(sb));
     NS_ENSURE_TRUE_LOG(sbs, NS_ERROR_FAILURE);
 
     NS_ConvertUTF8toUTF16 appName(gAppData->name);
     const PRUnichar* params[] = {appName.get(), appName.get()};
@@ -1872,18 +1873,18 @@ ProfileMissingDialog(nsINativeAppSupport
   rv = xpcom.Initialize();
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = xpcom.DoAutoreg();
   rv |= xpcom.SetWindowCreator(aNative);
   NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
 
   { //extra scoping is needed so we release these components before xpcom shutdown
-    nsCOMPtr<nsIStringBundleService> sbs
-      (do_GetService(NS_STRINGBUNDLE_CONTRACTID));
+    nsCOMPtr<nsIStringBundleService> sbs =
+      mozilla::services::GetStringBundleService();
     NS_ENSURE_TRUE(sbs, NS_ERROR_FAILURE);
   
     nsCOMPtr<nsIStringBundle> sb;
     sbs->CreateBundle(kProfileProperties, getter_AddRefs(sb));
     NS_ENSURE_TRUE_LOG(sbs, NS_ERROR_FAILURE);
   
     NS_ConvertUTF8toUTF16 appName(gAppData->name);
     const PRUnichar* params[] = {appName.get(), appName.get()};
@@ -3071,18 +3072,18 @@ XRE_main(int argc, char* argv[], const n
       PR_fprintf(PR_STDERR, "Error: argument -register is invalid when argument -osint is specified\n");
       return 1;
     } else if (ar == ARG_FOUND) {
       ScopedXPCOMStartup xpcom;
       rv = xpcom.Initialize();
       NS_ENSURE_SUCCESS(rv, 1);
 
       {
-        nsCOMPtr<nsIChromeRegistry> chromeReg
-          (do_GetService("@mozilla.org/chrome/chrome-registry;1"));
+        nsCOMPtr<nsIChromeRegistry> chromeReg =
+          mozilla::services::GetChromeRegistryService();
         NS_ENSURE_TRUE(chromeReg, 1);
 
         chromeReg->CheckForNewChrome();
       }
       return 0;
     }
 
 #if defined(MOZ_WIDGET_GTK2) || defined(MOZ_ENABLE_XREMOTE)
--- a/uriloader/base/nsDocLoader.cpp
+++ b/uriloader/base/nsDocLoader.cpp
@@ -1150,23 +1150,26 @@ NS_IMETHODIMP nsDocLoader::OnStatus(nsIR
         mCurrentSelfProgress  = mMaxSelfProgress  = LL_ZERO;
         mCurrentTotalProgress = mMaxTotalProgress = LL_ZERO;
         mCompletedTotalProgress = LL_ZERO;
         info->mUploading = uploading;
         info->mCurrentProgress = LL_ZERO;
         info->mMaxProgress = LL_ZERO;
       }
     }
-    
-    nsresult rv;
-    nsCOMPtr<nsIStringBundleService> sbs = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-    if (NS_FAILED(rv)) return rv;
+
+    nsCOMPtr<nsIStringBundleService> sbs =
+      mozilla::services::GetStringBundleService();
+    if (!sbs)
+      return NS_ERROR_FAILURE;
     nsXPIDLString msg;
-    rv = sbs->FormatStatusMessage(aStatus, aStatusArg, getter_Copies(msg));
-    if (NS_FAILED(rv)) return rv;
+    nsresult rv = sbs->FormatStatusMessage(aStatus, aStatusArg,
+                                           getter_Copies(msg));
+    if (NS_FAILED(rv))
+      return rv;
 
     // Keep around the message. In case a request finishes, we need to make sure
     // to send the status message of another request to our user to that we
     // don't display, for example, "Transferring" messages for requests that are
     // already done.
     if (info) {
       info->mLastStatus = msg;
       info->mLastStatusCode = aStatus;
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -1733,21 +1733,22 @@ void nsExternalAppHandler::SendStatusCha
     }
     PR_LOG(nsExternalHelperAppService::mLog, PR_LOG_ERROR,
         ("Error: %s, type=%i, listener=0x%p, rv=0x%08X\n",
          NS_LossyConvertUTF16toASCII(msgId).get(), type, mWebProgressListener.get(), rv));
     PR_LOG(nsExternalHelperAppService::mLog, PR_LOG_ERROR,
         ("       path='%s'\n", NS_ConvertUTF16toUTF8(path).get()));
 
     // Get properties file bundle and extract status string.
-    nsCOMPtr<nsIStringBundleService> s = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
-    if (s)
+    nsCOMPtr<nsIStringBundleService> stringService =
+        mozilla::services::GetStringBundleService();
+    if (stringService)
     {
         nsCOMPtr<nsIStringBundle> bundle;
-        if (NS_SUCCEEDED(s->CreateBundle("chrome://global/locale/nsWebBrowserPersist.properties", getter_AddRefs(bundle))))
+        if (NS_SUCCEEDED(stringService->CreateBundle("chrome://global/locale/nsWebBrowserPersist.properties", getter_AddRefs(bundle))))
         {
             nsXPIDLString msgText;
             const PRUnichar *strings[] = { path.get() };
             if(NS_SUCCEEDED(bundle->FormatStringFromName(msgId.get(), strings, 1, getter_Copies(msgText))))
             {
               if (mWebProgressListener)
               {
                 // We have a listener, let it handle the error.
--- a/uriloader/exthandler/os2/nsOSHelperAppService.cpp
+++ b/uriloader/exthandler/os2/nsOSHelperAppService.cpp
@@ -57,16 +57,17 @@
 #include "nsHashtable.h"
 #include "nsCRT.h"
 #include "prenv.h"      // for PR_GetEnv()
 #include "nsMIMEInfoOS2.h"
 #include "nsAutoPtr.h"
 #include "nsIRwsService.h"
 #include "nsIStringBundle.h"
 #include "nsLocalHandlerApp.h"
+#include "mozilla/Services.h"
 #include <stdlib.h>     // for system()
 
 //------------------------------------------------------------------------
 
 // reduces overhead by preventing calls to nsRws when it isn't present
 static PRBool sUseRws = PR_TRUE;
 
 static nsresult
@@ -1358,24 +1359,23 @@ nsOSHelperAppService::GetFromType(const 
 
 //------------------------------------------------------------------------
 
 // returns a localized string from unknownContentType.properties
 
 static nsresult
 GetNLSString(const PRUnichar *aKey, nsAString& result)
 {
-  nsresult rv;
-
   nsCOMPtr<nsIStringBundleService> bundleSvc =
-    do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+    mozilla::services::GetStringBundleService();
+  if (!bundleSvc)
+    return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIStringBundle> bundle;
-  rv = bundleSvc->CreateBundle(
+  nsresult rv = bundleSvc->CreateBundle(
     "chrome://mozapps/locale/downloads/unknownContentType.properties",
     getter_AddRefs(bundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsXPIDLString string;
   rv = bundle->GetStringFromName(aKey, getter_Copies(string));
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/widget/src/os2/nsRwsService.cpp
+++ b/widget/src/os2/nsRwsService.cpp
@@ -760,18 +760,18 @@ static nsresult DeleteFileForExtension(c
 
 static void AssignNLSString(const PRUnichar *aKey, nsAString& result)
 {
   nsresult      rv;
   nsXPIDLString title;
 
   do {
     nsCOMPtr<nsIStringBundleService> bundleSvc =
-      do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-    if (NS_FAILED(rv))
+      mozilla::services::GetStringBundleService();
+    if (!bundleSvc)
       break;
 
     nsCOMPtr<nsIStringBundle> bundle;
     rv = bundleSvc->CreateBundle(
       "chrome://mozapps/locale/downloads/unknownContentType.properties",
       getter_AddRefs(bundle));
     if (NS_FAILED(rv))
       break;
--- a/widget/src/qt/nsWindow.cpp
+++ b/widget/src/qt/nsWindow.cpp
@@ -74,16 +74,17 @@
 #include "nsIDeviceContext.h"
 #include "nsIdleService.h"
 #include "nsIRenderingContext.h"
 #include "nsIRegion.h"
 #include "nsIRollupListener.h"
 #include "nsIMenuRollup.h"
 #include "nsWidgetsCID.h"
 #include "nsQtKeyUtils.h"
+#include "mozilla/Services.h"
 
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsIStringBundle.h"
 #include "nsGfxCIID.h"
 
 #include "imgIContainer.h"
 #include "nsGfxCIID.h"
@@ -1646,18 +1647,18 @@ nsWindow::OnDragEnter(QGraphicsSceneDrag
 
     nsMouseEvent event(PR_TRUE, NS_DRAGDROP_ENTER, this, nsMouseEvent::eReal);
     return DispatchEvent(&event);
 }
 
 static void
 GetBrandName(nsXPIDLString& brandName)
 {
-    nsCOMPtr<nsIStringBundleService> bundleService = 
-        do_GetService(NS_STRINGBUNDLE_CONTRACTID);
+    nsCOMPtr<nsIStringBundleService> bundleService =
+        mozilla::services::GetStringBundleService();
 
     nsCOMPtr<nsIStringBundle> bundle;
     if (bundleService)
         bundleService->CreateBundle(
             "chrome://branding/locale/brand.properties",
             getter_AddRefs(bundle));
 
     if (bundle)
--- a/widget/src/windows/nsDataObj.cpp
+++ b/widget/src/windows/nsDataObj.cpp
@@ -994,23 +994,24 @@ CreateFilenameFromTextW(nsString & aText
   return PR_TRUE;
 }
 
 #define PAGEINFO_PROPERTIES "chrome://navigator/locale/pageInfo.properties"
 
 static PRBool
 GetLocalizedString(const PRUnichar * aName, nsXPIDLString & aString)
 {
-  nsresult rv;
-  nsCOMPtr<nsIStringBundleService> stringService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  if (NS_FAILED(rv)) 
+  nsCOMPtr<nsIStringBundleService> stringService =
+    mozilla::services::GetStringBundleService();
+  if (!stringService)
     return PR_FALSE;
 
   nsCOMPtr<nsIStringBundle> stringBundle;
-  rv = stringService->CreateBundle(PAGEINFO_PROPERTIES, getter_AddRefs(stringBundle));
+  nsresult rv = stringService->CreateBundle(PAGEINFO_PROPERTIES,
+                                            getter_AddRefs(stringBundle));
   if (NS_FAILED(rv))
     return PR_FALSE;
 
   rv = stringBundle->GetStringFromName(aName, getter_Copies(aString));
   return NS_SUCCEEDED(rv);
 }
 
 //
--- a/widget/src/windows/nsDeviceContextSpecWin.cpp
+++ b/widget/src/windows/nsDeviceContextSpecWin.cpp
@@ -57,16 +57,17 @@
 #include "nsStringEnumerator.h"
 
 #include "gfxPDFSurface.h"
 #include "gfxWindowsSurface.h"
 
 #include "nsIFileStreams.h"
 #include "nsIWindowWatcher.h"
 #include "nsIDOMWindow.h"
+#include "mozilla/Services.h"
 
 // For NS_CopyNativeToUnicode
 #include "nsNativeCharsetUtils.h"
 
 // File Picker
 #include "nsILocalFile.h"
 #include "nsIFile.h"
 #include "nsIFilePicker.h"
@@ -284,18 +285,20 @@ GetFileNameForPrintSettings(nsIPrintSett
   return NS_OK;
 #endif
 
   nsresult rv;
 
   nsCOMPtr<nsIFilePicker> filePicker = do_CreateInstance("@mozilla.org/filepicker;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
+  if (!bundleService)
+    return NS_ERROR_FAILURE;
   nsCOMPtr<nsIStringBundle> bundle;
   rv = bundleService->CreateBundle(NS_ERROR_GFX_PRINTER_BUNDLE_URL, getter_AddRefs(bundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsXPIDLString title;
   rv = bundle->GetStringFromName(NS_LITERAL_STRING("PrintToFile").get(), getter_Copies(title));
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/widget/src/xpwidgets/nsBaseFilePicker.cpp
+++ b/widget/src/xpwidgets/nsBaseFilePicker.cpp
@@ -49,16 +49,17 @@
 #include "nsIWidget.h"
 
 #include "nsIStringBundle.h"
 #include "nsXPIDLString.h"
 #include "nsIServiceManager.h"
 #include "nsCOMArray.h"
 #include "nsILocalFile.h"
 #include "nsEnumeratorUtils.h"
+#include "mozilla/Services.h"
 
 #include "nsBaseFilePicker.h"
 
 #define FILEPICKER_TITLES "chrome://global/locale/filepicker.properties"
 #define FILEPICKER_FILTERS "chrome://global/content/filepicker.properties"
 
 nsBaseFilePicker::nsBaseFilePicker()
 {
@@ -119,23 +120,25 @@ NS_IMETHODIMP nsBaseFilePicker::Init(nsI
 
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
 nsBaseFilePicker::AppendFilters(PRInt32 aFilterMask)
 {
-  nsresult rv;
-  nsCOMPtr<nsIStringBundleService> stringService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIStringBundleService> stringService =
+    mozilla::services::GetStringBundleService();
+  if (!stringService)
+    return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIStringBundle> titleBundle, filterBundle;
 
-  rv = stringService->CreateBundle(FILEPICKER_TITLES, getter_AddRefs(titleBundle));
+  nsresult rv = stringService->CreateBundle(FILEPICKER_TITLES,
+                                            getter_AddRefs(titleBundle));
   if (NS_FAILED(rv))
     return NS_ERROR_FAILURE;
 
   rv = stringService->CreateBundle(FILEPICKER_FILTERS, getter_AddRefs(filterBundle));
   if (NS_FAILED(rv))
     return NS_ERROR_FAILURE;
 
   nsXPIDLString title;
--- a/xpcom/build/ServiceList.h
+++ b/xpcom/build/ServiceList.h
@@ -1,2 +1,7 @@
+MOZ_SERVICE(ChromeRegistryService, nsIChromeRegistry, "@mozilla.org/chrome/chrome-registry;1")
+MOZ_SERVICE(ToolkitChromeRegistryService, nsIToolkitChromeRegistry, "@mozilla.org/chrome/chrome-registry;1")
+MOZ_SERVICE(XULChromeRegistryService, nsIXULChromeRegistry, "@mozilla.org/chrome/chrome-registry;1")
+MOZ_SERVICE(XULOverlayProviderService, nsIXULOverlayProvider, "@mozilla.org/chrome/chrome-registry;1")
 MOZ_SERVICE(IOService, nsIIOService, "@mozilla.org/network/io-service;1")
 MOZ_SERVICE(ObserverService, nsIObserverService, "@mozilla.org/observer-service;1")
+MOZ_SERVICE(StringBundleService, nsIStringBundleService, "@mozilla.org/intl/stringbundle;1")
--- a/xpcom/build/Services.cpp
+++ b/xpcom/build/Services.cpp
@@ -40,16 +40,19 @@
 #include "nsComponentManager.h"
 #include "nsIIOService.h"
 #include "nsIDirectoryService.h"
 #include "nsIChromeRegistry.h"
 #include "nsIObserverService.h"
 #include "nsNetCID.h"
 #include "nsObserverService.h"
 #include "nsXPCOMPrivate.h"
+#include "nsIStringBundle.h"
+#include "nsIToolkitChromeRegistry.h"
+#include "nsIXULOverlayProvider.h"
 
 using namespace mozilla::services;
 
 /*
  * Define a global variable and a getter for every service in ServiceList.
  * eg. gIOService and GetIOService()
  */
 #define MOZ_SERVICE(NAME, TYPE, CONTRACT_ID)                            \
--- a/xpfe/appshell/src/nsAppShellService.cpp
+++ b/xpfe/appshell/src/nsAppShellService.cpp
@@ -371,17 +371,17 @@ nsAppShellService::JustCreateTopWindow(n
     aInitialWidth = 1;
     aInitialHeight = 1;
     window->SetIntrinsicallySized(PR_TRUE);
   }
 
   PRBool center = aChromeMask & nsIWebBrowserChrome::CHROME_CENTER_SCREEN;
 
   nsCOMPtr<nsIXULChromeRegistry> reg =
-    do_GetService(NS_CHROMEREGISTRY_CONTRACTID);
+    mozilla::services::GetXULChromeRegistryService();
   if (reg) {
     nsCAutoString package;
     package.AssignLiteral("global");
     PRBool isRTL = PR_FALSE;
     reg->IsLocaleRTL(package, &isRTL);
     widgetInitData.mRTL = isRTL;
   }