From cf60fc042efa0b57124e3d51808e918485a760e5 Mon Sep 17 00:00:00 2001 From: "dougt%netscape.com" Date: Fri, 19 Oct 2001 20:52:59 +0000 Subject: [PATCH] nsIObserver and nsIObserverService API freeze. r=rpotts@netscape.com, alecf@netscape.com. bug 99163 git-svn-id: svn://10.0.0.236/trunk@105800 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/caps/src/nsScriptSecurityManager.cpp | 3 +- mozilla/chrome/src/nsChromeRegistry.cpp | 13 +- mozilla/content/base/src/nsDocument.cpp | 3 +- .../content/build/nsContentHTTPStartup.cpp | 2 +- mozilla/content/build/nsContentModule.cpp | 9 +- .../events/src/nsEventStateManager.cpp | 18 +- .../html/content/src/nsFormSubmitter.cpp | 1 + mozilla/content/xbl/src/nsXBLService.cpp | 5 +- .../xml/document/src/nsXMLContentSink.cpp | 5 +- .../xml/document/src/nsXMLContentSink.h | 2 +- .../xul/document/src/nsXULDocument.cpp | 2 +- mozilla/dom/src/base/nsJSEnvironment.cpp | 12 +- mozilla/dom/src/build/nsDOMFactory.cpp | 12 +- .../composer/src/nsEditorParserObserver.cpp | 2 +- .../browser/powerplant/source/CBrowserApp.cp | 7 +- .../appstartup/src/nsAppStartupNotifier.cpp | 15 +- .../appstartup/src/nsIAppStartupNotifier.h | 2 +- .../windowwatcher/src/nsWindowWatcher.cpp | 18 +- mozilla/embedding/qa/testembed/TestEmbed.cpp | 7 +- mozilla/embedding/tests/mfcembed/MfcEmbed.cpp | 15 +- .../tests/winEmbed/WebBrowserChrome.cpp | 4 +- mozilla/embedding/tests/winEmbed/winEmbed.cpp | 17 +- .../accessproxy/nsAccessProxy.cpp | 2 +- .../resources/content/pref-contentpacks.xul | 2 +- mozilla/extensions/cookie/nsCookieService.cpp | 11 +- .../extensions/cookie/nsPermissionManager.cpp | 11 +- .../inspector/resources/content/inspector.js | 4 +- .../inspector/resources/content/inspector.xml | 14 +- .../inspector/resources/content/object.js | 2 +- .../inspector/resources/content/sidebar.js | 2 +- .../content/sidebar/InspectorSidebar.js | 2 +- .../p3p/src/nsP3PObserverFormSubmit.cpp | 11 +- .../p3p/src/nsP3PObserverFormSubmit.h | 2 - .../extensions/p3p/src/nsP3PObserverHTML.cpp | 11 +- .../extensions/p3p/src/nsP3PObserverHTML.h | 2 - .../p3p/src/nsP3PObserverLayout.cpp | 11 +- .../extensions/p3p/src/nsP3PObserverLayout.h | 2 - .../extensions/p3p/src/nsP3PObserverXML.cpp | 11 +- mozilla/extensions/pics/src/nsPICS.cpp | 4 +- mozilla/extensions/pics/tests/TestPICS.cpp | 1 + mozilla/extensions/python/xpcom/components.py | 2 +- .../source/xslt/XSLTProcessor.cpp | 7 +- .../resources/content/history/history.js | 2 +- .../vixen/resources/content/vfd/vfd.js | 4 +- .../content/walletNavigatorOverlay.xul | 2 +- .../extensions/wallet/src/nsWalletService.cpp | 20 +- mozilla/gfx/src/windows/nsFontMetricsWin.cpp | 8 +- .../chardet/src/nsMetaCharsetObserver.cpp | 11 +- .../chardet/src/nsXMLEncodingObserver.cpp | 13 +- .../intl/strres/public/nsIStringBundle.idl | 2 +- mozilla/intl/strres/src/nsStringBundle.cpp | 10 +- .../xpconnect/loader/mozJSComponentLoader.cpp | 13 +- .../tests/js/old/xpctest_observer.js | 10 +- mozilla/layout/base/nsPresContext.cpp | 13 +- mozilla/layout/base/nsPresShell.cpp | 12 +- mozilla/layout/base/src/nsPresContext.cpp | 13 +- mozilla/layout/base/src/nsPresContext.h | 3 +- mozilla/layout/build/nsContentHTTPStartup.cpp | 2 +- mozilla/layout/html/base/src/nsPresShell.cpp | 12 +- mozilla/layout/html/forms/src/nsFormFrame.cpp | 19 +- .../layout/mathml/base/src/nsMathMLChar.cpp | 4 +- .../base/resources/content/commandglue.js | 4 +- .../base/resources/content/widgetglue.js | 2 +- .../mailnews/base/src/nsMessengerMigrator.cpp | 14 +- .../mailnews/base/src/nsMsgAccountManager.cpp | 47 ++- .../mailnews/base/src/nsMsgBiffManager.cpp | 14 +- .../mailnews/base/src/nsMsgOfflineManager.cpp | 2 +- .../mailnews/base/src/nsMsgRDFDataSource.cpp | 9 +- .../resources/content/MsgComposeCommands.js | 14 +- .../mailnews/db/msgdb/src/nsDBFolderInfo.cpp | 10 +- mozilla/modules/libjar/nsJAR.cpp | 5 +- mozilla/modules/libjar/nsJAR.h | 1 + mozilla/modules/libpref/src/nsAutoConfig.cpp | 8 +- mozilla/modules/libpref/src/nsPref.cpp | 2 +- mozilla/modules/libpref/src/nsPrefBranch.cpp | 2 +- mozilla/modules/libpref/src/nsPrefService.cpp | 13 +- .../plugin/base/src/nsPluginHostImpl.cpp | 21 +- .../plugin/base/src/nsPluginHostImpl.h | 2 +- mozilla/netwerk/base/src/nsIOService.cpp | 21 +- mozilla/netwerk/cache/src/nsCacheService.cpp | 40 +-- mozilla/netwerk/dns/src/nsDnsService.cpp | 11 +- .../http/public/nsIHttpProtocolHandler.idl | 2 +- .../protocol/http/src/nsHttpHandler.cpp | 19 +- mozilla/profile/src/nsProfile.cpp | 17 +- mozilla/rdf/chrome/src/nsChromeRegistry.cpp | 13 +- mozilla/rdf/datasource/src/nsLocalStore.cpp | 14 +- .../exthandler/nsExternalHelperAppService.cpp | 7 +- mozilla/xpcom/base/nsExceptionService.cpp | 6 +- mozilla/xpcom/base/nsExceptionService.h | 1 + mozilla/xpcom/base/nsIMemory.idl | 8 +- mozilla/xpcom/base/nsMemoryImpl.cpp | 11 +- mozilla/xpcom/build/nsXPComInit.cpp | 6 +- .../xpcom/components/nsCategoryManager.cpp | 2 +- .../xpcom/components/nsComponentManager.cpp | 14 +- .../xpcom/components/nsICategoryManager.idl | 2 +- .../components/nsNativeComponentLoader.cpp | 14 +- mozilla/xpcom/ds/MANIFEST | 2 +- mozilla/xpcom/ds/Makefile.in | 2 +- mozilla/xpcom/ds/makefile.win | 2 +- mozilla/xpcom/ds/nsEnumeratorUtils.cpp | 10 + mozilla/xpcom/ds/nsIEnumerator.idl | 1 - mozilla/xpcom/ds/nsIObserver.idl | 35 ++- mozilla/xpcom/ds/nsIObserverList.h | 66 ----- mozilla/xpcom/ds/nsIObserverService.idl | 81 +++++- mozilla/xpcom/ds/nsObserver.cpp | 2 +- mozilla/xpcom/ds/nsObserver.h | 4 + mozilla/xpcom/ds/nsObserverList.cpp | 268 ++++-------------- mozilla/xpcom/ds/nsObserverList.h | 38 +-- mozilla/xpcom/ds/nsObserverService.cpp | 173 ++++------- mozilla/xpcom/ds/nsObserverService.h | 17 +- mozilla/xpcom/tests/TestObserverService.cpp | 52 ++-- mozilla/xpcom/threads/nsEventQueue.cpp | 6 +- .../xpfe/appshell/src/nsAppShellService.cpp | 54 ++-- .../xpfe/appshell/src/nsWebShellWindow.cpp | 9 +- mozilla/xpfe/appshell/src/nsXULWindow.cpp | 11 +- mozilla/xpfe/bootstrap/nsAppRunner.cpp | 5 +- mozilla/xpfe/bootstrap/nsDocLoadObserver.cpp | 4 +- .../xpfe/bootstrap/nsNativeAppSupportWin.cpp | 3 +- .../browser/resources/content/navigator.js | 2 +- .../content/nsBrowserStatusHandler.js | 4 +- .../xpfe/browser/src/nsBrowserInstance.cpp | 5 +- .../resources/content/utilityOverlay.js | 6 +- .../bookmarks/src/nsBookmarksService.cpp | 11 +- .../history/src/nsGlobalHistory.cpp | 19 +- .../xpfe/components/intl/nsCharsetMenu.cpp | 5 +- .../resources/content/pref-appearance.xul | 2 +- .../resources/content/pref-themes.js | 2 +- .../related/resources/related-panel.js | 12 +- .../search/src/nsInternetSearchService.cpp | 11 +- .../components/xfer/src/nsStreamXferOp.cpp | 10 +- .../global/resources/content/globalOverlay.js | 2 +- .../xpfe/global/resources/content/strres.js | 2 +- mozilla/xpinstall/src/nsSoftwareUpdate.cpp | 8 +- mozilla/xpinstall/src/nsXPIProxy.cpp | 3 +- 134 files changed, 752 insertions(+), 1036 deletions(-) delete mode 100644 mozilla/xpcom/ds/nsIObserverList.h diff --git a/mozilla/caps/src/nsScriptSecurityManager.cpp b/mozilla/caps/src/nsScriptSecurityManager.cpp index bc2fab6dda2..121f1cf0f59 100644 --- a/mozilla/caps/src/nsScriptSecurityManager.cpp +++ b/mozilla/caps/src/nsScriptSecurityManager.cpp @@ -2008,7 +2008,7 @@ static const char sPrincipalPrefix[] = "capability.principal"; static const char sPolicyPrefix[] = "capability.policy"; NS_IMETHODIMP -nsScriptSecurityManager::Observe(nsISupports* aObject, const PRUnichar* aAction, +nsScriptSecurityManager::Observe(nsISupports* aObject, const char* aAction, const PRUnichar* aPrefName) { nsresult rv = NS_OK; @@ -2428,7 +2428,6 @@ nsScriptSecurityManager::InitPrefs() // set observer callbacks in case the value of the pref changes prefBranchInternal->AddObserver(sJSEnabledPrefName, this); prefBranchInternal->AddObserver(sJSMailEnabledPrefName, this); - PRUint32 prefCount; char** prefNames; diff --git a/mozilla/chrome/src/nsChromeRegistry.cpp b/mozilla/chrome/src/nsChromeRegistry.cpp index f5447b4a9ed..4fd267e1568 100644 --- a/mozilla/chrome/src/nsChromeRegistry.cpp +++ b/mozilla/chrome/src/nsChromeRegistry.cpp @@ -102,6 +102,7 @@ #include "nsAppDirectoryServiceDefs.h" #include "nsIPref.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIDOMElement.h" #include "nsIChromeEventHandler.h" #include "nsIContent.h" @@ -355,8 +356,8 @@ nsChromeRegistry::Init() nsCOMPtr observerService = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (observerService) { - observerService->AddObserver(this, NS_LITERAL_STRING("profile-before-change").get()); - observerService->AddObserver(this, NS_LITERAL_STRING("profile-do-change").get()); + observerService->AddObserver(this, "profile-before-change", PR_TRUE); + observerService->AddObserver(this, "profile-do-change", PR_TRUE); } CheckForNewChrome(); @@ -3235,25 +3236,25 @@ nsChromeRegistry::GetProviderCount(const nsCString& aProviderType, nsIRDFDataSou } -NS_IMETHODIMP nsChromeRegistry::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +NS_IMETHODIMP nsChromeRegistry::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { nsresult rv = NS_OK; - if (!nsCRT::strcmp(NS_LITERAL_STRING("profile-before-change").get(), aTopic)) { + if (!nsCRT::strcmp("profile-before-change", aTopic)) { mChromeDataSource = nsnull; mScrollbarSheet = mFormSheet = nsnull; mInstallInitialized = mProfileInitialized = PR_FALSE; (void)FlushCaches(); - if (!nsCRT::strcmp(NS_LITERAL_STRING("shutdown-cleanse").get(), someData)) { + if (!nsCRT::strcmp("shutdown-cleanse", NS_ConvertUCS2toUTF8(someData).get())) { nsCOMPtr userChromeDir; rv = NS_GetSpecialDirectory(NS_APP_USER_CHROME_DIR, getter_AddRefs(userChromeDir)); if (NS_SUCCEEDED(rv) && userChromeDir) rv = userChromeDir->Remove(PR_TRUE); } } - else if (!nsCRT::strcmp(NS_LITERAL_STRING("profile-do-change").get(), aTopic)) { + else if (!nsCRT::strcmp("profile-do-change", aTopic)) { if (!mProfileInitialized) rv = LoadProfileDataSource(); } diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index e8db2452517..0f0e4a6f75c 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -896,8 +896,7 @@ NS_IMETHODIMP nsDocument::SetDocumentCharacterSet(const nsAReadableString& aChar PRInt32 n = mCharSetObservers.Count(); for (PRInt32 i = 0; i < n; i++) { nsIObserver* observer = (nsIObserver*) mCharSetObservers.ElementAt(i); - observer->Observe((nsIDocument*) this, NS_LITERAL_STRING("charset").get(), - PromiseFlatString(aCharSetID).get()); + observer->Observe((nsIDocument*) this, "charset", PromiseFlatString(aCharSetID).get()); } } return NS_OK; diff --git a/mozilla/content/build/nsContentHTTPStartup.cpp b/mozilla/content/build/nsContentHTTPStartup.cpp index 2560f6717ac..9f00ce77054 100644 --- a/mozilla/content/build/nsContentHTTPStartup.cpp +++ b/mozilla/content/build/nsContentHTTPStartup.cpp @@ -54,7 +54,7 @@ NS_IMPL_ISUPPORTS1(nsContentHTTPStartup,nsIObserver) nsresult nsContentHTTPStartup::Observe( nsISupports *aSubject, - const PRUnichar *aTopic, + const char *aTopic, const PRUnichar *aData) { if (nsCRT::strcmp(aTopic, NS_HTTP_STARTUP_TOPIC) != 0) diff --git a/mozilla/content/build/nsContentModule.cpp b/mozilla/content/build/nsContentModule.cpp index 4dc423c5c9c..84d1964bc53 100644 --- a/mozilla/content/build/nsContentModule.cpp +++ b/mozilla/content/build/nsContentModule.cpp @@ -85,6 +85,7 @@ #include "nsINodeInfo.h" #include "nsIObserver.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIPresContext.h" #include "nsIPresShell.h" #include "nsIPrivateDOMImplementation.h" @@ -136,16 +137,14 @@ public: NS_DECL_NSIOBSERVER }; -static NS_NAMED_LITERAL_STRING(kXPCOMShutdownObserverID, NS_XPCOM_SHUTDOWN_OBSERVER_ID); - NS_IMPL_ISUPPORTS1(ContentShutdownObserver, nsIObserver) NS_IMETHODIMP ContentShutdownObserver::Observe(nsISupports *aSubject, - const PRUnichar *aTopic, + const char *aTopic, const PRUnichar *someData) { - if (kXPCOMShutdownObserverID.Equals(aTopic)) + if (!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) nsContentUtils::Shutdown(); return NS_OK; @@ -190,7 +189,7 @@ Initialize(nsIModule* aSelf) new ContentShutdownObserver(); if (observer) - observerService->AddObserver(observer, kXPCOMShutdownObserverID.get()); + observerService->AddObserver(observer, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE); } return NS_OK; diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index 1d08cac9e97..1d9fddd5cb4 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -86,6 +86,7 @@ #include "nsXULAtoms.h" #include "nsIDOMXULDocument.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIDocShell.h" #include "nsIMarkupDocumentViewer.h" #include "nsITreeFrame.h" @@ -194,8 +195,7 @@ nsEventStateManager::Init() do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { - nsAutoString topic; topic.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); - observerService->AddObserver(this, topic.get()); + observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE); } rv = getPrefService(); @@ -257,8 +257,7 @@ nsEventStateManager::~nsEventStateManager() do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { - nsAutoString topic; topic.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); - observerService->RemoveObserver(this, topic.get()); + observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID); } } @@ -292,12 +291,11 @@ nsEventStateManager::getPrefService() } NS_IMETHODIMP -nsEventStateManager::Observe(nsISupports *aSubject, const PRUnichar *aTopic, - const PRUnichar *someData) { - nsAutoString topicString(aTopic); - nsAutoString shutdownString; shutdownString.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); - - if (topicString == shutdownString) +nsEventStateManager::Observe(nsISupports *aSubject, + const char *aTopic, + const PRUnichar *someData) +{ + if (!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) Shutdown(); return NS_OK; diff --git a/mozilla/content/html/content/src/nsFormSubmitter.cpp b/mozilla/content/html/content/src/nsFormSubmitter.cpp index ac44d9ada4e..3da70cb4b65 100644 --- a/mozilla/content/html/content/src/nsFormSubmitter.cpp +++ b/mozilla/content/html/content/src/nsFormSubmitter.cpp @@ -45,6 +45,7 @@ static NS_DEFINE_CID(kFormProcessorCID, NS_FORMPROCESSOR_CID); #include "nsNetUtil.h" static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIFormSubmitObserver.h" #include "nsIDOMWindowInternal.h" #include "nsIUnicodeEncoder.h" diff --git a/mozilla/content/xbl/src/nsXBLService.cpp b/mozilla/content/xbl/src/nsXBLService.cpp index 6845c1d8f10..f990eab237f 100644 --- a/mozilla/content/xbl/src/nsXBLService.cpp +++ b/mozilla/content/xbl/src/nsXBLService.cpp @@ -70,6 +70,7 @@ #include "nsITextContent.h" #include "nsIMemory.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIDOMNodeList.h" #include "nsIXBLBinding.h" @@ -903,7 +904,7 @@ nsXBLService::AttachGlobalDragHandler(nsIDOMEventReceiver* aReceiver) NS_IMETHODIMP -nsXBLService::Observe(nsISupports* aSubject, const PRUnichar* aTopic, const PRUnichar* aSomeData) +nsXBLService::Observe(nsISupports* aSubject, const char* aTopic, const PRUnichar* aSomeData) { if (nsCRT::strcmp(aTopic, NS_MEMORY_PRESSURE_TOPIC) == 0) FlushMemory(); @@ -1502,7 +1503,7 @@ NS_NewXBLService(nsIXBLService** aResult) // so it can flush the LRU list in low-memory situations. nsCOMPtr os = do_GetService(NS_OBSERVERSERVICE_CONTRACTID); if (os) - os->AddObserver(result, NS_MEMORY_PRESSURE_TOPIC); + os->AddObserver(result, NS_MEMORY_PRESSURE_TOPIC, PR_TRUE); return NS_OK; } diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index 0223d94d503..a60bfc6d815 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -374,12 +374,11 @@ nsXMLContentSink::DidBuildModel(PRInt32 aQualityLevel) // The observe method is called on completion of the transform. The nsISupports argument is an // nsIDOMElement interface to the root node of the output content model. NS_IMETHODIMP -nsXMLContentSink::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +nsXMLContentSink::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { nsresult rv = NS_OK; - nsAutoString topic(aTopic); - if (topic.Equals(NS_LITERAL_STRING("xslt-done"))) { + if (!nsCRT::strcmp(aTopic, "xslt-done")) { nsCOMPtr content; // Set the output content model on the document diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.h b/mozilla/content/xml/document/src/nsXMLContentSink.h index 57d63cc499c..344f95bb6c8 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.h +++ b/mozilla/content/xml/document/src/nsXMLContentSink.h @@ -127,7 +127,7 @@ public: // nsIObserver NS_IMETHOD Observe(nsISupports *aSubject, - const PRUnichar *aTopic, + const char *aTopic, const PRUnichar *someData); protected: diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index c8f8316a7c4..962f39eef6a 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -927,7 +927,7 @@ nsXULDocument::SetDocumentCharacterSet(const nsAReadableString& aCharSetID) PRInt32 n = mCharSetObservers.Count(); for (PRInt32 i = 0; i < n; i++) { nsIObserver* observer = (nsIObserver*) mCharSetObservers.ElementAt(i); - observer->Observe((nsIDocument*) this, NS_LITERAL_STRING("charset").get(), + observer->Observe((nsIDocument*) this, "charset", PromiseFlatString(aCharSetID).get()); } } diff --git a/mozilla/dom/src/base/nsJSEnvironment.cpp b/mozilla/dom/src/base/nsJSEnvironment.cpp index 7020d8c21f9..68073f74d8b 100644 --- a/mozilla/dom/src/base/nsJSEnvironment.cpp +++ b/mozilla/dom/src/base/nsJSEnvironment.cpp @@ -70,6 +70,7 @@ #include "nsIInterfaceRequestorUtils.h" #include "nsIPrompt.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsGUIEvent.h" #include "nsScriptNameSpaceManager.h" #include "nsIThread.h" @@ -1548,9 +1549,7 @@ nsJSEnvironment::nsJSEnvironment() NS_ASSERTION(NS_SUCCEEDED(rv), "going to leak a nsJSEnvironment"); if (NS_SUCCEEDED(rv)) { - nsAutoString topic; - topic.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); - observerService->AddObserver(this,topic.get()); + observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE); } mRuntimeService = nsnull; @@ -1621,13 +1620,12 @@ nsJSEnvironment::~nsJSEnvironment() NS_IMPL_ISUPPORTS1(nsJSEnvironment,nsIObserver); NS_IMETHODIMP nsJSEnvironment::Observe(nsISupports *aSubject, - const PRUnichar *aTopic, + const char *aTopic, const PRUnichar *someData) { #ifdef DEBUG - nsAutoString topic; - topic.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); - NS_ASSERTION(topic.EqualsWithConversion(aTopic), "not shutdown"); + if (nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) + NS_ASSERTION(0,"not shutdown"); #endif NS_RELEASE_THIS(); // release ref from |GetScriptingEnvironment| return NS_OK; diff --git a/mozilla/dom/src/build/nsDOMFactory.cpp b/mozilla/dom/src/build/nsDOMFactory.cpp index a15bb597612..9847d265a87 100644 --- a/mozilla/dom/src/build/nsDOMFactory.cpp +++ b/mozilla/dom/src/build/nsDOMFactory.cpp @@ -45,6 +45,7 @@ #include "nsDOMClassInfo.h" #include "nsGlobalWindow.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIJSContextStack.h" @@ -92,9 +93,7 @@ nsDOMSOFactory::nsDOMSOFactory() do_GetService(NS_OBSERVERSERVICE_CONTRACTID); if (observerService) { - nsAutoString topic; - topic.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); - observerService->AddObserver(this, topic.get()); + observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE); } } @@ -142,12 +141,11 @@ nsDOMSOFactory::GetClassInfoInstance(nsDOMClassInfoID aID) } NS_IMETHODIMP -nsDOMSOFactory::Observe(nsISupports *aSubject, const PRUnichar *aTopic, +nsDOMSOFactory::Observe(nsISupports *aSubject, + const char *aTopic, const PRUnichar *someData) { - nsAutoString topic; - topic.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); - if (topic.EqualsWithConversion(aTopic)) { + if (!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) { nsCOMPtr stack = do_GetService("@mozilla.org/js/xpc/ContextStack;1"); diff --git a/mozilla/editor/composer/src/nsEditorParserObserver.cpp b/mozilla/editor/composer/src/nsEditorParserObserver.cpp index 7aa4d787a73..fe826413357 100644 --- a/mozilla/editor/composer/src/nsEditorParserObserver.cpp +++ b/mozilla/editor/composer/src/nsEditorParserObserver.cpp @@ -101,7 +101,7 @@ NS_IMETHODIMP nsEditorParserObserver::Notify(nsISupports* aWebShell, return NS_OK; } -NS_IMETHODIMP nsEditorParserObserver::Observe(nsISupports*, const PRUnichar*, const PRUnichar*) +NS_IMETHODIMP nsEditorParserObserver::Observe(nsISupports*, const char*, const PRUnichar*) { return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/mozilla/embedding/browser/powerplant/source/CBrowserApp.cp b/mozilla/embedding/browser/powerplant/source/CBrowserApp.cp index 45fbf2d2dd5..1dc5861bec9 100644 --- a/mozilla/embedding/browser/powerplant/source/CBrowserApp.cp +++ b/mozilla/embedding/browser/powerplant/source/CBrowserApp.cp @@ -65,6 +65,7 @@ #include "nsDirectoryServiceDefs.h" #include "nsAppDirectoryServiceDefs.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIPref.h" #include "nsRepeater.h" #include "nsILocalFile.h" @@ -252,9 +253,9 @@ CBrowserApp::StartUp() nsCOMPtr observerService = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); ThrowIfNil_(observerService); - observerService->AddObserver(this, NS_LITERAL_STRING("profile-approve-change").get()); - observerService->AddObserver(this, NS_LITERAL_STRING("profile-change-teardown").get()); - observerService->AddObserver(this, NS_LITERAL_STRING("profile-after-change").get()); + observerService->AddObserver(this, "profile-approve-change", PR_FALSE); + observerService->AddObserver(this, "profile-change-teardown", PR_FALSE); + observerService->AddObserver(this, "profile-after-change", PR_FALSE); CProfileManager *profileMgr = new CProfileManager; profileMgr->StartUp(); diff --git a/mozilla/embedding/components/appstartup/src/nsAppStartupNotifier.cpp b/mozilla/embedding/components/appstartup/src/nsAppStartupNotifier.cpp index 9b35ff0b051..47b7a985484 100644 --- a/mozilla/embedding/components/appstartup/src/nsAppStartupNotifier.cpp +++ b/mozilla/embedding/components/appstartup/src/nsAppStartupNotifier.cpp @@ -55,14 +55,9 @@ nsAppStartupNotifier::~nsAppStartupNotifier() { } -NS_IMETHODIMP nsAppStartupNotifier::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +NS_IMETHODIMP nsAppStartupNotifier::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { NS_ENSURE_ARG(aTopic); - - nsCAutoString strCategory; - if(aTopic) - strCategory.AssignWithConversion(aTopic); - nsresult rv; // now initialize all startup listeners @@ -71,7 +66,7 @@ NS_IMETHODIMP nsAppStartupNotifier::Observe(nsISupports *aSubject, const PRUnich NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr enumerator; - rv = categoryManager->EnumerateCategory(strCategory.get(), + rv = categoryManager->EnumerateCategory(aTopic, getter_AddRefs(enumerator)); if (NS_FAILED(rv)) return rv; @@ -84,9 +79,9 @@ NS_IMETHODIMP nsAppStartupNotifier::Observe(nsISupports *aSubject, const PRUnich rv = category->GetData(getter_Copies(categoryEntry)); nsXPIDLCString contractId; - categoryManager->GetCategoryEntry(strCategory.get(), - categoryEntry, - getter_Copies(contractId)); + categoryManager->GetCategoryEntry(aTopic, + categoryEntry, + getter_Copies(contractId)); if (NS_SUCCEEDED(rv)) { diff --git a/mozilla/embedding/components/appstartup/src/nsIAppStartupNotifier.h b/mozilla/embedding/components/appstartup/src/nsIAppStartupNotifier.h index 4ab39008a4f..5e68c7886d0 100644 --- a/mozilla/embedding/components/appstartup/src/nsIAppStartupNotifier.h +++ b/mozilla/embedding/components/appstartup/src/nsIAppStartupNotifier.h @@ -81,7 +81,7 @@ #define NS_APPSTARTUPNOTIFIER_CLASSNAME "AppStartup Notifier" #define APPSTARTUP_CATEGORY "app-startup" -#define APPSTARTUP_TOPIC (NS_LITERAL_STRING("app-startup").get()) +#define APPSTARTUP_TOPIC "app-startup" /* diff --git a/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp b/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp index 7a532e12faf..abe8bb1c24f 100644 --- a/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp +++ b/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp @@ -64,6 +64,7 @@ #include "nsIGenericFactory.h" #include "nsIJSContextStack.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIScriptGlobalObject.h" #include "nsIScriptSecurityManager.h" #include "nsISupportsArray.h" @@ -91,8 +92,7 @@ #include "nsIWeakReference.h" #endif -#define NOTIFICATION_OPENED NS_LITERAL_STRING("domwindowopened") -#define NOTIFICATION_CLOSED NS_LITERAL_STRING("domwindowclosed") +#define NOTIFICATION_CLOSED NS_LITERAL_CSTRING("domwindowclosed") #ifdef HAVE_LAME_APPSHELL static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID); @@ -732,9 +732,9 @@ nsWindowWatcher::RegisterNotification(nsIObserver *aObserver) nsCOMPtr os(do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv)); if (os) { - rv = os->AddObserver(aObserver, NOTIFICATION_OPENED.get()); + rv = os->AddObserver(aObserver, "domwindowopened", PR_FALSE); if (NS_SUCCEEDED(rv)) - rv = os->AddObserver(aObserver, NOTIFICATION_CLOSED.get()); + rv = os->AddObserver(aObserver, "domwindowclosed", PR_FALSE); } return rv; } @@ -750,8 +750,8 @@ nsWindowWatcher::UnregisterNotification(nsIObserver *aObserver) nsCOMPtr os(do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv)); if (os) { - os->RemoveObserver(aObserver, NOTIFICATION_OPENED.get()); - os->RemoveObserver(aObserver, NOTIFICATION_CLOSED.get()); + os->RemoveObserver(aObserver, "domwindowopened"); + os->RemoveObserver(aObserver, "domwindowclosed"); } return rv; } @@ -841,7 +841,7 @@ nsWindowWatcher::AddWindow(nsIDOMWindow *aWindow, nsIWebBrowserChrome *aChrome) nsCOMPtr os(do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv)); if (os) { nsCOMPtr domwin(do_QueryInterface(aWindow)); - rv = os->Notify(domwin, NOTIFICATION_OPENED.get(), 0); + rv = os->NotifyObservers(domwin, "domwindowopened", 0); } return rv; @@ -932,11 +932,11 @@ nsresult nsWindowWatcher::RemoveWindow(nsWatcherWindowEntry *inInfo) #ifdef USEWEAKREFS nsCOMPtr domwin(do_QueryReferent(inInfo->mWindow)); if (domwin) - rv = os->Notify(domwin, NOTIFICATION_CLOSED.get(), 0); + rv = os->NotifyObservers(domwin, "domwindowclosed", 0); // else bummer. since the window is gone, there's nothing to notify with. #else nsCOMPtr domwin(do_QueryInterface(inInfo->mWindow)); - rv = os->Notify(domwin, NOTIFICATION_CLOSED.get(), 0); + rv = os->NotifyObservers(domwin, "domwindowclosed", 0); #endif } diff --git a/mozilla/embedding/qa/testembed/TestEmbed.cpp b/mozilla/embedding/qa/testembed/TestEmbed.cpp index fb8a63935eb..4d5f30d0144 100644 --- a/mozilla/embedding/qa/testembed/TestEmbed.cpp +++ b/mozilla/embedding/qa/testembed/TestEmbed.cpp @@ -64,6 +64,7 @@ #include "BrowserImpl.h" #include "BrowserView.h" #include "nsIWindowWatcher.h" +#include "nsObserverService.h" #include "plstr.h" #include "Preferences.h" #include @@ -493,9 +494,9 @@ BOOL CTestEmbedApp::InitializeProfiles() nsCOMPtrobserverService(do_GetService(NS_OBSERVERSERVICE_CONTRACTID,&rv)); if (NS_SUCCEEDED(rv)) { - observerService->AddObserver(this, NS_LITERAL_STRING("profile-approve-change").get()); - observerService->AddObserver(this, NS_LITERAL_STRING("profile-change-teardown").get()); - observerService->AddObserver(this, NS_LITERAL_STRING("profile-after-change").get()); + observerService->AddObserver(this, "profile-approve-change", PR_FALSE); + observerService->AddObserver(this, "profile-change-teardown", PR_FALSE); + observerService->AddObserver(this, "profile-after-change", PR_FALSE); } m_ProfileMgr->StartUp(); diff --git a/mozilla/embedding/tests/mfcembed/MfcEmbed.cpp b/mozilla/embedding/tests/mfcembed/MfcEmbed.cpp index 516799f502f..0bf4529667f 100644 --- a/mozilla/embedding/tests/mfcembed/MfcEmbed.cpp +++ b/mozilla/embedding/tests/mfcembed/MfcEmbed.cpp @@ -63,6 +63,7 @@ #include "ProfileMgr.h" #include "BrowserImpl.h" #include "nsIWindowWatcher.h" +#include "nsObserverService.h" #include "plstr.h" #include "Preferences.h" #include @@ -482,9 +483,9 @@ BOOL CMfcEmbedApp::InitializeProfiles() nsresult rv; nsCOMPtr observerService = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); - observerService->AddObserver(this, NS_LITERAL_STRING("profile-approve-change").get()); - observerService->AddObserver(this, NS_LITERAL_STRING("profile-change-teardown").get()); - observerService->AddObserver(this, NS_LITERAL_STRING("profile-after-change").get()); + observerService->AddObserver(this, "profile-approve-change", PR_FALSE); + observerService->AddObserver(this, "profile-change-teardown", PR_FALSE); + observerService->AddObserver(this, "profile-after-change", PR_FALSE); m_ProfileMgr->StartUp(); @@ -587,11 +588,11 @@ NS_IMPL_THREADSAFE_ISUPPORTS3(CMfcEmbedApp, nsIObserver, nsIWindowCreator, nsISu // Mainly needed to support "on the fly" profile switching -NS_IMETHODIMP CMfcEmbedApp::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +NS_IMETHODIMP CMfcEmbedApp::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { nsresult rv = NS_OK; - if (nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-approve-change").get()) == 0) + if (nsCRT::strcmp(aTopic, "profile-approve-change") == 0) { // Ask the user if they want to int result = MessageBox(NULL, "Do you want to close all windows in order to switch the profile?", "Confirm", MB_YESNO | MB_ICONQUESTION); @@ -602,7 +603,7 @@ NS_IMETHODIMP CMfcEmbedApp::Observe(nsISupports *aSubject, const PRUnichar *aTop status->VetoChange(); } } - else if (nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-change-teardown").get()) == 0) + else if (nsCRT::strcmp(aTopic, "profile-change-teardown") == 0) { // Close all open windows. Alternatively, we could just call CBrowserWindow::Stop() // on each. Either way, we have to stop all network activity on this phase. @@ -623,7 +624,7 @@ NS_IMETHODIMP CMfcEmbedApp::Observe(nsISupports *aSubject, const PRUnichar *aTop } } } - else if (nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-after-change").get()) == 0) + else if (nsCRT::strcmp(aTopic, "profile-after-change") == 0) { InitializePrefs(); // In case we have just switched to a newly created profile. diff --git a/mozilla/embedding/tests/winEmbed/WebBrowserChrome.cpp b/mozilla/embedding/tests/winEmbed/WebBrowserChrome.cpp index 477446646ff..287471c7c9b 100644 --- a/mozilla/embedding/tests/winEmbed/WebBrowserChrome.cpp +++ b/mozilla/embedding/tests/winEmbed/WebBrowserChrome.cpp @@ -549,10 +549,10 @@ NS_IMETHODIMP WebBrowserChrome::GetSiteWindow(void * *aSiteWindow) // WebBrowserChrome::nsIObserver //***************************************************************************** -NS_IMETHODIMP WebBrowserChrome::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +NS_IMETHODIMP WebBrowserChrome::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { nsresult rv = NS_OK; - if (nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-change-teardown").get()) == 0) + if (nsCRT::strcmp(aTopic, "profile-change-teardown") == 0) { // A profile change means death for this window WebBrowserChromeUI::Destroy(this); diff --git a/mozilla/embedding/tests/winEmbed/winEmbed.cpp b/mozilla/embedding/tests/winEmbed/winEmbed.cpp index 9ae59a421b2..6f9238891bd 100644 --- a/mozilla/embedding/tests/winEmbed/winEmbed.cpp +++ b/mozilla/embedding/tests/winEmbed/winEmbed.cpp @@ -57,6 +57,7 @@ #include "nsIWindowWatcher.h" #include "nsIProfile.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIObserver.h" #include "nsIProfileChangeStatus.h" #include "nsIURI.h" @@ -172,9 +173,9 @@ int main(int argc, char *argv[]) ProfileChangeObserver *observer = new ProfileChangeObserver; observer->AddRef(); - observerService->AddObserver(NS_STATIC_CAST(nsIObserver *, observer), NS_LITERAL_STRING("profile-approve-change").get()); - observerService->AddObserver(NS_STATIC_CAST(nsIObserver *, observer), NS_LITERAL_STRING("profile-change-teardown").get()); - observerService->AddObserver(NS_STATIC_CAST(nsIObserver *, observer), NS_LITERAL_STRING("profile-after-change").get()); + observerService->AddObserver(NS_STATIC_CAST(nsIObserver *, observer), "profile-approve-change", PR_FALSE); + observerService->AddObserver(NS_STATIC_CAST(nsIObserver *, observer), "profile-change-teardown", PR_FALSE); + observerService->AddObserver(NS_STATIC_CAST(nsIObserver *, observer), "profile-after-change", PR_FALSE); InitializeWindowCreator(); @@ -211,11 +212,11 @@ ProfileChangeObserver::ProfileChangeObserver() // CMfcEmbedApp : nsIObserver // --------------------------------------------------------------------------- -NS_IMETHODIMP ProfileChangeObserver::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +NS_IMETHODIMP ProfileChangeObserver::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { nsresult rv = NS_OK; - if (nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-approve-change").get()) == 0) + if (nsCRT::strcmp(aTopic, "profile-approve-change") == 0) { // The profile is about to change! @@ -228,14 +229,14 @@ NS_IMETHODIMP ProfileChangeObserver::Observe(nsISupports *aSubject, const PRUnic status->VetoChange(); } } - else if (nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-change-teardown").get()) == 0) + else if (nsCRT::strcmp(aTopic, "profile-change-teardown") == 0) { // The profile is changing! // Prevent WM_QUIT by incrementing the dialog count gDialogCount++; } - else if (nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-after-change").get()) == 0) + else if (nsCRT::strcmp(aTopic, "profile-after-change") == 0) { // Decrease the dialog count so WM_QUIT can once more happen gDialogCount--; @@ -1344,7 +1345,7 @@ nsresult AppCallbacks::CreateBrowserWindow(PRUint32 aChromeFlags, nsCOMPtr observerService(do_GetService(NS_OBSERVERSERVICE_CONTRACTID)); if (observerService) observerService->AddObserver(NS_STATIC_CAST(nsIObserver *, chrome), - NS_LITERAL_STRING("profile-change-teardown").get()); + "profile-change-teardown", PR_FALSE); return NS_OK; } diff --git a/mozilla/extensions/access-builtin/accessproxy/nsAccessProxy.cpp b/mozilla/extensions/access-builtin/accessproxy/nsAccessProxy.cpp index c4f44fea2ce..dae8ee3f2b8 100644 --- a/mozilla/extensions/access-builtin/accessproxy/nsAccessProxy.cpp +++ b/mozilla/extensions/access-builtin/accessproxy/nsAccessProxy.cpp @@ -186,7 +186,7 @@ NS_IMETHODIMP nsAccessProxy::Observe(nsISupports *aSubject, const PRUnichar *aTo if (NS_SUCCEEDED(rv)) { nsCOMPtr observerService(do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv)); if (NS_SUCCEEDED(rv)) - rv = observerService->AddObserver(this, NS_LITERAL_STRING(NS_XPCOM_SHUTDOWN_OBSERVER_ID).get()); + rv = observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE); } } return rv; diff --git a/mozilla/extensions/content-packs/resources/content/pref-contentpacks.xul b/mozilla/extensions/content-packs/resources/content/pref-contentpacks.xul index 7101fbf5253..bf123f70733 100644 --- a/mozilla/extensions/content-packs/resources/content/pref-contentpacks.xul +++ b/mozilla/extensions/content-packs/resources/content/pref-contentpacks.xul @@ -83,7 +83,7 @@ var chromeRegistry = Components.classes["@mozilla.org/chrome/chrome-registry;1"].getService(Components.interfaces.nsIChromeRegistry); chromeRegistry.selectLocale(newContentPack, true); var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService); - observerService.Notify(null, "locale-selected", null); + observerService.notifyObservers(null, "locale-selected", null); var contentBundle = document.getElementById("bundle_contentPack"); var brandBundle = document.getElementById("bundle_brand"); var alertText = contentBundle.getString("contentAlert"); diff --git a/mozilla/extensions/cookie/nsCookieService.cpp b/mozilla/extensions/cookie/nsCookieService.cpp index 518c2dde1dd..8cbfce4dc99 100644 --- a/mozilla/extensions/cookie/nsCookieService.cpp +++ b/mozilla/extensions/cookie/nsCookieService.cpp @@ -47,6 +47,7 @@ #include "nsIDOMWindowInternal.h" #include "nsIPrompt.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIDocumentLoader.h" #include "nsIWebProgress.h" #include "nsCURILoader.h" @@ -85,8 +86,8 @@ nsresult nsCookieService::Init() nsCOMPtr observerService = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (observerService) { - observerService->AddObserver(this, NS_LITERAL_STRING("profile-before-change").get()); - observerService->AddObserver(this, NS_LITERAL_STRING("profile-do-change").get()); + observerService->AddObserver(this, "profile-before-change", PR_TRUE); + observerService->AddObserver(this, "profile-do-change", PR_TRUE); } // Register as an observer for the document loader @@ -211,11 +212,11 @@ nsCookieService::SetCookieStringFromHttp(nsIURI *aURL, nsIURI *aFirstURL, nsIPro return NS_OK; } -NS_IMETHODIMP nsCookieService::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +NS_IMETHODIMP nsCookieService::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { nsresult rv = NS_OK; - if (!nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-before-change").get())) { + if (!nsCRT::strcmp(aTopic, "profile-before-change")) { // The profile is about to change. // Dump current cookies. This will be done by calling @@ -230,7 +231,7 @@ NS_IMETHODIMP nsCookieService::Observe(nsISupports *aSubject, const PRUnichar *a if (!nsCRT::strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get())) COOKIE_DeletePersistentUserData(); } - else if (!nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-do-change").get())) { + else if (!nsCRT::strcmp(aTopic, "profile-do-change")) { // The profile has aleady changed. // Now just read them from the new profile location. COOKIE_Read(); diff --git a/mozilla/extensions/cookie/nsPermissionManager.cpp b/mozilla/extensions/cookie/nsPermissionManager.cpp index 9dd4281f24f..c0e08009df0 100644 --- a/mozilla/extensions/cookie/nsPermissionManager.cpp +++ b/mozilla/extensions/cookie/nsPermissionManager.cpp @@ -46,6 +46,7 @@ #include "nsIDOMWindowInternal.h" #include "nsIPrompt.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsPermission.h" #include "nsNetCID.h" @@ -126,8 +127,8 @@ nsresult nsPermissionManager::Init() nsCOMPtr observerService = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (observerService) { - observerService->AddObserver(this, NS_LITERAL_STRING("profile-before-change").get()); - observerService->AddObserver(this, NS_LITERAL_STRING("profile-do-change").get()); + observerService->AddObserver(this, "profile-before-change", PR_FALSE); + observerService->AddObserver(this, "profile-do-change", PR_FALSE); } mIOService = do_GetService(NS_IOSERVICE_CONTRACTID, &rv); return rv; @@ -161,11 +162,11 @@ NS_IMETHODIMP nsPermissionManager::Remove(const char* host, PRInt32 type) { return NS_OK; } -NS_IMETHODIMP nsPermissionManager::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +NS_IMETHODIMP nsPermissionManager::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { nsresult rv = NS_OK; - if (!nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-before-change").get())) { + if (!nsCRT::strcmp(aTopic, "profile-before-change")) { // The profile is about to change. // Dump current permission. This will be done by calling @@ -180,7 +181,7 @@ NS_IMETHODIMP nsPermissionManager::Observe(nsISupports *aSubject, const PRUnicha if (!nsCRT::strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get())) PERMISSION_DeletePersistentUserData(); } - else if (!nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-do-change").get())) { + else if (!nsCRT::strcmp(aTopic, "profile-do-change")) { // The profile has aleady changed. // Now just read them from the new profile location. PERMISSION_Read(); diff --git a/mozilla/extensions/inspector/resources/content/inspector.js b/mozilla/extensions/inspector/resources/content/inspector.js index 8ba5605112a..21bb844e771 100644 --- a/mozilla/extensions/inspector/resources/content/inspector.js +++ b/mozilla/extensions/inspector/resources/content/inspector.js @@ -113,7 +113,7 @@ InspectorApp.prototype = this.mClipboardHelper = XPCU.getService(kClipboardHelperCID, "nsIClipboardHelper"); this.mPanelSet = document.getElementById("bxPanelSet"); - this.mPanelSet.addObserver("panelsetready", this); + this.mPanelSet.addObserver("panelsetready", this, false); this.mPanelSet.initialize(); }, @@ -129,7 +129,7 @@ InspectorApp.prototype = initViewerPanels: function() { this.mDocPanel = this.mPanelSet.getPanel(0); - this.mDocPanel.addObserver("subjectChange", this); + this.mDocPanel.addObserver("subjectChange", this, false); this.mObjectPanel = this.mPanelSet.getPanel(1); if (this.mInitTarget) { diff --git a/mozilla/extensions/inspector/resources/content/inspector.xml b/mozilla/extensions/inspector/resources/content/inspector.xml index a8e356d18f8..70974f8ae8f 100644 --- a/mozilla/extensions/inspector/resources/content/inspector.xml +++ b/mozilla/extensions/inspector/resources/content/inspector.xml @@ -48,8 +48,8 @@ var panels = this.panels; for (var i = 0; i < panels.length; ++i) { panels[i].initialize(); - panels[i].addObserver("viewerChange", this); - panels[i].addObserver("subjectChange", this); + panels[i].addObserver("viewerChange", this, false); + panels[i].addObserver("subjectChange", this, false); } this.setAllViewerCmdAttributes("disabled", "true"); @@ -229,7 +229,7 @@ this.mLinkedPanel = val; if (val) - val.addObserver("viewerChange", this); + val.addObserver("viewerChange", this, false); @@ -273,7 +273,7 @@ old.removeObserver("subjectChange", this); if (aViewer) - aViewer.addObserver("subjectChange", this); + aViewer.addObserver("subjectChange", this, false); this.mObsMan.dispatchEvent("viewerChange", { viewerPane: this, oldViewer: old, newViewer: aViewer }); @@ -506,7 +506,7 @@ this.mLinkedViewer.removeObserver("selectionChange", this); this.mLinkedViewer = this.mLinkedPanel.viewer; - this.mLinkedViewer.addObserver("selectionChange", this); + this.mLinkedViewer.addObserver("selectionChange", this, false); ]]> @@ -577,7 +577,7 @@ @@ -593,4 +593,4 @@ - \ No newline at end of file + diff --git a/mozilla/extensions/inspector/resources/content/object.js b/mozilla/extensions/inspector/resources/content/object.js index 7248885e307..ba2b763d16e 100644 --- a/mozilla/extensions/inspector/resources/content/object.js +++ b/mozilla/extensions/inspector/resources/content/object.js @@ -82,7 +82,7 @@ ObjectApp.prototype = this.mInitTarget = window.arguments && window.arguments.length > 0 ? window.arguments[0] : null; this.mPanelSet = document.getElementById("bxPanelSet"); - this.mPanelSet.addObserver("panelsetready", this); + this.mPanelSet.addObserver("panelsetready", this, false); this.mPanelSet.initialize(); }, diff --git a/mozilla/extensions/inspector/resources/content/sidebar.js b/mozilla/extensions/inspector/resources/content/sidebar.js index d287934b283..d78245e7a77 100644 --- a/mozilla/extensions/inspector/resources/content/sidebar.js +++ b/mozilla/extensions/inspector/resources/content/sidebar.js @@ -110,7 +110,7 @@ InspectorSidebar.prototype = installNavObserver: function() { var observerService = XPCU.getService(kObserverServiceIID, "nsIObserverService"); - observerService.AddObserver(NavLoadObserver, "EndDocumentLoad"); + observerService.addObserver(NavLoadObserver, "EndDocumentLoad", false); } }; diff --git a/mozilla/extensions/inspector/resources/content/sidebar/InspectorSidebar.js b/mozilla/extensions/inspector/resources/content/sidebar/InspectorSidebar.js index cbba6d59c48..42504210b7e 100644 --- a/mozilla/extensions/inspector/resources/content/sidebar/InspectorSidebar.js +++ b/mozilla/extensions/inspector/resources/content/sidebar/InspectorSidebar.js @@ -378,7 +378,7 @@ InspectorSidebar.prototype = installNavObserver: function() { var observerService = XPCU.getService(kObserverServiceIID, "nsIObserverService"); - observerService.AddObserver(NavLoadObserver, "EndDocumentLoad"); + observerService.addObserver(NavLoadObserver, "EndDocumentLoad", false); } }; diff --git a/mozilla/extensions/p3p/src/nsP3PObserverFormSubmit.cpp b/mozilla/extensions/p3p/src/nsP3PObserverFormSubmit.cpp index 909626ceead..0363a2e8051 100644 --- a/mozilla/extensions/p3p/src/nsP3PObserverFormSubmit.cpp +++ b/mozilla/extensions/p3p/src/nsP3PObserverFormSubmit.cpp @@ -27,7 +27,7 @@ #include "nsP3PObserverFormSubmit.h" #include "nsIServiceManager.h" - +#include "nsObserverService.h" #include "nsIPresShell.h" #include "nsString.h" @@ -93,8 +93,7 @@ nsP3PObserverFormSubmit::nsP3PObserverFormSubmit( ) nsP3PObserverFormSubmit::~nsP3PObserverFormSubmit( ) { if (mObserverService) { - mObserverService->RemoveObserver( this, - mObserverTopic.get() ); + mObserverService->RemoveObserver( this, NS_FORMSUBMIT_SUBJECT ); } } @@ -114,17 +113,13 @@ nsP3PObserverFormSubmit::Init( ) { PR_LOG_NOTICE, ("P3PObserverFormSubmit: Init, initializing.\n") ); - // Set the topic to be observed - mObserverTopic.AssignWithConversion( NS_FORMSUBMIT_SUBJECT ); - // Get the Observer service mObserverService = do_GetService( NS_OBSERVERSERVICE_CONTRACTID, &rv ); if (NS_SUCCEEDED( rv )) { // Register to observe form submissions - rv = mObserverService->AddObserver( this, - mObserverTopic.get() ); + rv = mObserverService->AddObserver( this, NS_FORMSUBMIT_SUBJECT, PR_FALSE); if (NS_FAILED( rv )) { #ifdef DEBUG_P3P diff --git a/mozilla/extensions/p3p/src/nsP3PObserverFormSubmit.h b/mozilla/extensions/p3p/src/nsP3PObserverFormSubmit.h index a88229605d0..bfcb02ff46a 100644 --- a/mozilla/extensions/p3p/src/nsP3PObserverFormSubmit.h +++ b/mozilla/extensions/p3p/src/nsP3PObserverFormSubmit.h @@ -69,8 +69,6 @@ protected: PRBool mP3PIsEnabled; // An indicator as to whether the P3P Service is enabled - nsString mObserverTopic; // The topic to be observed - nsCOMPtr mObserverService; // The Observer Service }; diff --git a/mozilla/extensions/p3p/src/nsP3PObserverHTML.cpp b/mozilla/extensions/p3p/src/nsP3PObserverHTML.cpp index 77ff9a90c2f..6692c1c4e19 100644 --- a/mozilla/extensions/p3p/src/nsP3PObserverHTML.cpp +++ b/mozilla/extensions/p3p/src/nsP3PObserverHTML.cpp @@ -28,7 +28,7 @@ #include "nsP3PLogging.h" #include "nsIServiceManager.h" - +#include "nsObserverService.h" #include "nsIParser.h" #include "nsIDocShell.h" @@ -101,8 +101,7 @@ nsP3PObserverHTML::nsP3PObserverHTML( ) nsP3PObserverHTML::~nsP3PObserverHTML( ) { if (mObserverService) { - mObserverService->RemoveObserver( this, - mObserverTopic.get() ); + mObserverService->RemoveObserver( this, kHTMLTextContentType); } } @@ -122,17 +121,13 @@ nsP3PObserverHTML::Init( ) { PR_LOG_NOTICE, ("P3PObserverHTML: Init, initializing.\n") ); - // Set the topic to be observed - mObserverTopic.AssignWithConversion( kHTMLTextContentType ); - // Get the Observer service mObserverService = do_GetService( NS_OBSERVERSERVICE_CONTRACTID, &rv ); if (NS_SUCCEEDED( rv )) { // Register to observe HTML tags - rv = mObserverService->AddObserver( this, - mObserverTopic.get() ); + rv = mObserverService->AddObserver( this, kHTMLTextContentType, PR_FALSE); if (NS_FAILED( rv )) { #ifdef DEBUG_P3P diff --git a/mozilla/extensions/p3p/src/nsP3PObserverHTML.h b/mozilla/extensions/p3p/src/nsP3PObserverHTML.h index 50b27cd5def..7a4e13737fb 100644 --- a/mozilla/extensions/p3p/src/nsP3PObserverHTML.h +++ b/mozilla/extensions/p3p/src/nsP3PObserverHTML.h @@ -80,8 +80,6 @@ protected: PRBool mP3PIsEnabled; // An indicator as to whether the P3P Service is enabled - nsString mObserverTopic; // The topic to be observed - nsCOMPtr mObserverService; // The Observer Service }; diff --git a/mozilla/extensions/p3p/src/nsP3PObserverLayout.cpp b/mozilla/extensions/p3p/src/nsP3PObserverLayout.cpp index cfa3042f75b..405a39a1113 100644 --- a/mozilla/extensions/p3p/src/nsP3PObserverLayout.cpp +++ b/mozilla/extensions/p3p/src/nsP3PObserverLayout.cpp @@ -28,7 +28,7 @@ #include "nsCOMPtr.h" #include "nsIServiceManager.h" - +#include "nsObserverService.h" #include "nsIPresShell.h" #include "nsIDocShellTreeItem.h" @@ -104,8 +104,7 @@ nsP3PObserverLayout::nsP3PObserverLayout( ) nsP3PObserverLayout::~nsP3PObserverLayout( ) { if (mObserverService) { - mObserverService->RemoveObserver( this, - mObserverTopic.get() ); + mObserverService->RemoveObserver( this, NS_PRESSHELL_REFLOW_TOPIC); } } @@ -125,17 +124,13 @@ nsP3PObserverLayout::Init( ) { PR_LOG_NOTICE, ("P3PObserverLayout: Init, initializing.\n") ); - // Set the topic to be observed - mObserverTopic.AssignWithConversion( NS_PRESSHELL_REFLOW_TOPIC ); - // Get the Observer service mObserverService = do_GetService( NS_OBSERVERSERVICE_CONTRACTID, &rv ); if (NS_SUCCEEDED( rv )) { // Register to observe Reflows - rv = mObserverService->AddObserver( this, - mObserverTopic.get() ); + rv = mObserverService->AddObserver( this, NS_PRESSHELL_REFLOW_TOPIC, PR_FALSE) if (NS_FAILED( rv )) { #ifdef DEBUG_P3P diff --git a/mozilla/extensions/p3p/src/nsP3PObserverLayout.h b/mozilla/extensions/p3p/src/nsP3PObserverLayout.h index 49d8e00b168..68c03caa5c9 100644 --- a/mozilla/extensions/p3p/src/nsP3PObserverLayout.h +++ b/mozilla/extensions/p3p/src/nsP3PObserverLayout.h @@ -65,8 +65,6 @@ protected: PRBool mP3PIsEnabled; // An indicator as to whether the P3P Service is enabled - nsString mObserverTopic; // The topic to be observed - nsCOMPtr mObserverService; // The Observer Service nsCOMPtr mURILoader; // The URI Loader service diff --git a/mozilla/extensions/p3p/src/nsP3PObserverXML.cpp b/mozilla/extensions/p3p/src/nsP3PObserverXML.cpp index 39ced983143..12ce6df7694 100644 --- a/mozilla/extensions/p3p/src/nsP3PObserverXML.cpp +++ b/mozilla/extensions/p3p/src/nsP3PObserverXML.cpp @@ -28,7 +28,7 @@ #include "nsP3PLogging.h" #include "nsIServiceManager.h" - +#include "nsObserverService.h" #include "nsIParser.h" #include "nsIDocShell.h" @@ -132,14 +132,11 @@ nsP3PObserverXML::Init( ) { if (NS_SUCCEEDED( rv )) { // Register to observer XML tags - rv = mObserverService->AddObserver( this, - NS_LITERAL_STRING("text/xml").get() ); + rv = mObserverService->AddObserver( this, "text/xml", PR_FALSE ); if (NS_SUCCEEDED(rv)) { - rv = mObserverService->AddObserver( this, - NS_LITERAL_STRING("application/xml").get() ); + rv = mObserverService->AddObserver( this, "application/xml",PR_FALSE ); if (NS_SUCCEEDED(rv)) { - rv = mObserverService->AddObserver( this, - NS_LITERAL_STRING("application/xhtml+xml").get() ); + rv = mObserverService->AddObserver( this, "application/xhtml" PR_FALSE ); } } diff --git a/mozilla/extensions/pics/src/nsPICS.cpp b/mozilla/extensions/pics/src/nsPICS.cpp index b3dc9937ddd..ddee4a36403 100644 --- a/mozilla/extensions/pics/src/nsPICS.cpp +++ b/mozilla/extensions/pics/src/nsPICS.cpp @@ -53,6 +53,7 @@ #include "nsParserCIID.h" #include "nsIHTMLContentSink.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsPICSElementObserver.h" #include "nsFileSpec.h" #include "nsIDocumentViewer.h" @@ -428,7 +429,6 @@ nsPICS::Init() nsresult rv; nsresult res; nsIPref* aPrefs; - nsString aTopic("htmlparser"); nsIObserverService *anObserverService = nsnull; // nsFileSpec mySpec("C:\\Program Files\\Netscape\\Users\\neeti\\prefs.js"); @@ -482,7 +482,7 @@ nsPICS::Init() (nsISupports **)&anObserverService); if(rv == NS_OK) { - rv = anObserverService->AddObserver(mPICSElementObserver, aTopic.get()); + rv = anObserverService->AddObserver(mPICSElementObserver, "htmlparser", PR_FALSE); nsServiceManager::ReleaseService( NS_OBSERVERSERVICE_CONTRACTID, anObserverService ); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/extensions/pics/tests/TestPICS.cpp b/mozilla/extensions/pics/tests/TestPICS.cpp index 19bf9fd8b7b..6b3120406a0 100644 --- a/mozilla/extensions/pics/tests/TestPICS.cpp +++ b/mozilla/extensions/pics/tests/TestPICS.cpp @@ -10,6 +10,7 @@ #include "nsIIOService.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsString.h" #include "prmem.h" #include "plstr.h" diff --git a/mozilla/extensions/python/xpcom/components.py b/mozilla/extensions/python/xpcom/components.py index e8492536f89..a266b59674c 100644 --- a/mozilla/extensions/python/xpcom/components.py +++ b/mozilla/extensions/python/xpcom/components.py @@ -197,5 +197,5 @@ svc = _xpcom.GetGlobalServiceManager().GetService("@mozilla.org/observer-service # observer alive ourself, and must keep the COM object alive, # _not_ just the Python instance!!! _shutdownObserver = xpcom.server.WrapObject(_ShutdownObserver(), interfaces.nsIObserver) -svc.AddObserver(_shutdownObserver, "xpcom-shutdown") +svc.addObserver(_shutdownObserver, "xpcom-shutdown", false) del svc, _ShutdownObserver diff --git a/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp b/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp index d15dfa0f4f8..20fa078a875 100644 --- a/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp +++ b/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp @@ -54,6 +54,7 @@ #include "txAtom.h" #ifndef TX_EXE #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIURL.h" #include "nsIServiceManager.h" #include "nsIIOService.h" @@ -2153,8 +2154,6 @@ XSLTProcessor::TransformDocument(nsIDOMNode* aSourceDOM, if (aObserver) { nsresult res = NS_OK; - nsAutoString topic; topic.Assign(NS_LITERAL_STRING("xslt-done")); - nsCOMPtr anObserverService = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &res); if (NS_SUCCEEDED(res)) { Node* docElement = resultDocument->getDocumentElement(); @@ -2166,8 +2165,8 @@ XSLTProcessor::TransformDocument(nsIDOMNode* aSourceDOM, nsDocElement = nsnull; } - anObserverService->AddObserver(aObserver, topic.get()); - anObserverService->Notify(nsDocElement, topic.get(), nsnull); + anObserverService->AddObserver(aObserver, "xslt-done", PR_FALSE); + anObserverService->NotifyObservers(nsDocElement, "xslt-done", nsnull); } } diff --git a/mozilla/extensions/vixen/resources/content/history/history.js b/mozilla/extensions/vixen/resources/content/history/history.js index 7d1c5565ca6..83392e792a5 100644 --- a/mozilla/extensions/vixen/resources/content/history/history.js +++ b/mozilla/extensions/vixen/resources/content/history/history.js @@ -32,7 +32,7 @@ var vxHistory = // document is at front var rootShell = vxUtils.getRootShell(); if (rootShell && "observerService" in rootShell) - rootShell.observerService.AddObserver(vfdFocusObserver, "vfd-focus"); + rootShell.observerService.addObserver(vfdFocusObserver, "vfd-focus", false); this.mBundle = document.getElementById("historyBundle"); } diff --git a/mozilla/extensions/vixen/resources/content/vfd/vfd.js b/mozilla/extensions/vixen/resources/content/vfd/vfd.js index 804f132bde6..3f2ad1b8e98 100644 --- a/mozilla/extensions/vixen/resources/content/vfd/vfd.js +++ b/mozilla/extensions/vixen/resources/content/vfd/vfd.js @@ -57,7 +57,7 @@ var vxVFD = if (this.mTxMgrShell) { var rootShell = vxUtils.getRootShell(); try { - rootShell.observerService.Notify(this.mTxMgrShell.mDataSource.mDataSource, + rootShell.observerService.notifyObservers(this.mTxMgrShell.mDataSource.mDataSource, "vfd-focus", this); } catch (e) { @@ -75,7 +75,7 @@ var vxVFD = if (this.mTxMgrShell) { try { - rootShell.observerService.Notify(this.mTxMgrShell.mDataSource.mDataSource, "vfd-focus", this); + rootShell.observerService.notifyObservers(this.mTxMgrShell.mDataSource.mDataSource, "vfd-focus", this); } catch (e) { // No big deal, no observers. diff --git a/mozilla/extensions/wallet/resources/content/walletNavigatorOverlay.xul b/mozilla/extensions/wallet/resources/content/walletNavigatorOverlay.xul index 5a9a585bd4e..5e3b241eb6f 100644 --- a/mozilla/extensions/wallet/resources/content/walletNavigatorOverlay.xul +++ b/mozilla/extensions/wallet/resources/content/walletNavigatorOverlay.xul @@ -77,7 +77,7 @@ observerService = observerService.QueryInterface(Components.interfaces.nsIObserverService); var observer = new navObserver(); if (observerService && observer) { - observerService.AddObserver(observer, "EndDocumentLoad"); + observerService.addObserver(observer, "EndDocumentLoad", PR_FALSE); } else { dump("FAILURE to get observer service\n"); } diff --git a/mozilla/extensions/wallet/src/nsWalletService.cpp b/mozilla/extensions/wallet/src/nsWalletService.cpp index cbaa643a897..a690506c3fe 100644 --- a/mozilla/extensions/wallet/src/nsWalletService.cpp +++ b/mozilla/extensions/wallet/src/nsWalletService.cpp @@ -44,6 +44,7 @@ #include "singsign.h" #include "nsPassword.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIDOMHTMLDocument.h" #include "nsIDOMHTMLCollection.h" #include "nsIDOMHTMLFormElement.h" @@ -211,11 +212,11 @@ NS_IMETHODIMP nsWalletlibService::SI_SignonViewerReturn(nsAutoString results){ return NS_OK; } -NS_IMETHODIMP nsWalletlibService::Observe(nsISupports*, const PRUnichar *aTopic, const PRUnichar *someData) +NS_IMETHODIMP nsWalletlibService::Observe(nsISupports*, const char *aTopic, const PRUnichar *someData) { - if (!nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-before-change").get())) { + if (!nsCRT::strcmp(aTopic, "profile-before-change")) { WLLT_ClearUserData(); - if (!nsCRT::strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get())) { + if (!nsCRT::strcmp(someData, "shutdown-cleanse")) { WLLT_DeletePersistentUserData(); } } @@ -298,10 +299,9 @@ nsresult nsWalletlibService::Init() do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv) && svc) { // Register as an observer of form submission - nsAutoString topic; topic.AssignWithConversion(NS_FORMSUBMIT_SUBJECT); - svc->AddObserver(this, topic.get()); + svc->AddObserver(this, NS_FORMSUBMIT_SUBJECT, PR_TRUE); // Register as an observer of profile changes - svc->AddObserver(this, NS_LITERAL_STRING("profile-before-change").get()); + svc->AddObserver(this, "profile-before-change", PR_TRUE); } else NS_ASSERTION(PR_FALSE, "Could not get nsIObserverService"); @@ -559,11 +559,11 @@ public: NS_DECL_ISUPPORTS - NS_IMETHODIMP Observe(nsISupports*, const PRUnichar *aTopic, const PRUnichar *someData) + NS_IMETHODIMP Observe(nsISupports*, const char *aTopic, const PRUnichar *someData) { - if (!nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-before-change").get())) { + if (!nsCRT::strcmp(aTopic, "profile-before-change")) { SI_ClearUserData(); - if (!nsCRT::strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get())) + if (!nsCRT::strcmp(someData, "shutdown-cleanse")) SI_DeletePersistentUserData(); } return NS_OK; @@ -591,7 +591,7 @@ nsSingleSignOnPrompt::Init() if (!svc) return NS_ERROR_FAILURE; // The observer service holds the only ref to the observer // It thus has the lifespan of the observer service - svc->AddObserver(observer, NS_LITERAL_STRING("profile-before-change").get()); + svc->AddObserver(observer, "profile-before-change", PR_TRUE); mgRegisteredObserver = PR_TRUE; } return NS_OK; diff --git a/mozilla/gfx/src/windows/nsFontMetricsWin.cpp b/mozilla/gfx/src/windows/nsFontMetricsWin.cpp index 04ef3d562ec..df1e97becce 100644 --- a/mozilla/gfx/src/windows/nsFontMetricsWin.cpp +++ b/mozilla/gfx/src/windows/nsFontMetricsWin.cpp @@ -47,6 +47,7 @@ #include "nsISaveAsCharset.h" #include "nsIObserver.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsFontMetricsWin.h" #include "nsQuickSort.h" #include "nsTextFormatter.h" @@ -235,10 +236,9 @@ public: NS_IMPL_ISUPPORTS1(nsFontCleanupObserver, nsIObserver); -NS_IMETHODIMP nsFontCleanupObserver::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +NS_IMETHODIMP nsFontCleanupObserver::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { - nsDependentString aTopicString(aTopic); - if (aTopicString.Equals(NS_LITERAL_STRING(NS_XPCOM_SHUTDOWN_OBSERVER_ID))) { + if (!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) { FreeGlobals(); } return NS_OK; @@ -332,7 +332,7 @@ InitGlobals(void) nsresult rv; nsCOMPtr observerService(do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv)); if (NS_SUCCEEDED(rv)) { - rv = observerService->AddObserver(gFontCleanupObserver, NS_LITERAL_STRING(NS_XPCOM_SHUTDOWN_OBSERVER_ID).get()); + rv = observerService->AddObserver(gFontCleanupObserver, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE); } } diff --git a/mozilla/intl/chardet/src/nsMetaCharsetObserver.cpp b/mozilla/intl/chardet/src/nsMetaCharsetObserver.cpp index 4489bd3b678..b601edfcfce 100644 --- a/mozilla/intl/chardet/src/nsMetaCharsetObserver.cpp +++ b/mozilla/intl/chardet/src/nsMetaCharsetObserver.cpp @@ -389,18 +389,11 @@ NS_IMETHODIMP nsMetaCharsetObserver::GetCharsetFromCompatibilityTag( //------------------------------------------------------------------------- NS_IMETHODIMP nsMetaCharsetObserver::Observe(nsISupports *aSubject, - const PRUnichar *aTopic, + const char *aTopic, const PRUnichar *aData) { nsresult rv = NS_OK; - nsDependentString aTopicString(aTopic); - /* - Warning! |NS_LITERAL_STRING(APPSTARTUP_CATEGORY)| relies on the order of - evaluation of the two |#defines|. This is known _not_ to work on platforms - that support wide characters directly. Better to define |APPSTARTUP_CATEGORY| - in terms of |NS_LITERAL_STRING| directly. - */ - if (aTopicString.Equals(NS_LITERAL_STRING(APPSTARTUP_CATEGORY))) //"app_startup" + if (!nsCRT::strcmp(aTopic, APPSTARTUP_CATEGORY)) rv = Start(); return rv; } diff --git a/mozilla/intl/chardet/src/nsXMLEncodingObserver.cpp b/mozilla/intl/chardet/src/nsXMLEncodingObserver.cpp index e570384b6a2..c9b587d5a29 100644 --- a/mozilla/intl/chardet/src/nsXMLEncodingObserver.cpp +++ b/mozilla/intl/chardet/src/nsXMLEncodingObserver.cpp @@ -42,6 +42,8 @@ #include "nsIElementObserver.h" #include "nsIObserver.h" #include "nsIObserverService.h" +#include "nsObserverService.h" +#include "nsObserverService.h" #include "nsISupports.h" #include "nsCRT.h" #include "nsIParser.h" @@ -198,7 +200,7 @@ NS_IMETHODIMP nsXMLEncodingObserver::Notify( } //------------------------------------------------------------------------- -NS_IMETHODIMP nsXMLEncodingObserver::Observe(nsISupports*, const PRUnichar*, const PRUnichar*) +NS_IMETHODIMP nsXMLEncodingObserver::Observe(nsISupports*, const char*, const PRUnichar*) { return NS_ERROR_NOT_IMPLEMENTED; } @@ -210,13 +212,12 @@ NS_IMETHODIMP nsXMLEncodingObserver::Start() if (bXMLEncodingObserverStarted == PR_TRUE) return res; - nsAutoString xmlTopic; xmlTopic.AssignWithConversion("xmlparser"); - nsCOMPtr anObserverService = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &res); + if(NS_FAILED(res)) goto done; - res = anObserverService->AddObserver(this, xmlTopic.get()); + res = anObserverService->AddObserver(this, "xmlparser", PR_TRUE); bXMLEncodingObserverStarted = PR_TRUE; done: @@ -230,12 +231,12 @@ NS_IMETHODIMP nsXMLEncodingObserver::End() if (bXMLEncodingObserverStarted == PR_FALSE) return res; - nsAutoString xmlTopic; xmlTopic.AssignWithConversion("xmlparser"); + nsCAutoString xmlTopic; xmlTopic.Assign("xmlparser"); nsCOMPtr anObserverService = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &res); if(NS_FAILED(res)) goto done; - res = anObserverService->RemoveObserver(this, xmlTopic.get()); + res = anObserverService->RemoveObserver(this, xmlTopic); bXMLEncodingObserverStarted = PR_FALSE; done: diff --git a/mozilla/intl/strres/public/nsIStringBundle.idl b/mozilla/intl/strres/public/nsIStringBundle.idl index 11eec6b3425..dd455681bbc 100644 --- a/mozilla/intl/strres/public/nsIStringBundle.idl +++ b/mozilla/intl/strres/public/nsIStringBundle.idl @@ -52,7 +52,7 @@ /** * observer needs to check if the bundle handle matches */ -#define NS_STRBUNDLE_LOADED_TOPIC (NS_LITERAL_STRING("strbundle-loaded").get()) +#define NS_STRBUNDLE_LOADED_TOPIC "strbundle-loaded" %} diff --git a/mozilla/intl/strres/src/nsStringBundle.cpp b/mozilla/intl/strres/src/nsStringBundle.cpp index c8675612015..a37e78c6cc4 100644 --- a/mozilla/intl/strres/src/nsStringBundle.cpp +++ b/mozilla/intl/strres/src/nsStringBundle.cpp @@ -54,6 +54,7 @@ #include "nsIMemory.h" #include "nsIObserver.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsWeakReference.h" #include "nsCOMPtr.h" #include "pratom.h" @@ -282,8 +283,9 @@ nsStringBundle::OnStreamComplete(nsIStreamLoader* aLoader, // observer notification nsCOMPtr os = do_GetService(NS_OBSERVERSERVICE_CONTRACTID); if (os) - (void) os->Notify((nsIStringBundle *) this, - NS_STRBUNDLE_LOADED_TOPIC, nsnull); + (void) os->NotifyObservers((nsIStringBundle *) this, + NS_STRBUNDLE_LOADED_TOPIC, + nsnull); #if defined(DEBUG_tao) printf("\n --> nsStringBundle::OnStreamComplete: end sending NOTIFICATIONS!!\n"); @@ -796,14 +798,14 @@ nsStringBundleService::Init() { nsCOMPtr os = do_GetService(NS_OBSERVERSERVICE_CONTRACTID); if (os) - os->AddObserver(this, NS_MEMORY_PRESSURE_TOPIC); + os->AddObserver(this, NS_MEMORY_PRESSURE_TOPIC, PR_TRUE); return NS_OK; } NS_IMETHODIMP nsStringBundleService::Observe(nsISupports* aSubject, - const PRUnichar* aTopic, + const char* aTopic, const PRUnichar* aSomeData) { if (nsCRT::strcmp(NS_MEMORY_PRESSURE_TOPIC, aTopic) == 0) diff --git a/mozilla/js/src/xpconnect/loader/mozJSComponentLoader.cpp b/mozilla/js/src/xpconnect/loader/mozJSComponentLoader.cpp index 75305c97dd1..0f803a3dd5b 100644 --- a/mozilla/js/src/xpconnect/loader/mozJSComponentLoader.cpp +++ b/mozilla/js/src/xpconnect/loader/mozJSComponentLoader.cpp @@ -45,6 +45,7 @@ #include "nsIRegistry.h" #include "nsXPIDLString.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIXPCScriptable.h" #ifndef XPCONNECT_STANDALONE #include "nsIScriptSecurityManager.h" @@ -853,9 +854,9 @@ mozJSComponentLoader::AttemptRegistration(nsIFile *component, } statusMsg.Append(fileName); - (void) observerService->Notify(mgr, - NS_ConvertASCIItoUCS2(NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID).get(), - statusMsg.get()); + (void) observerService->NotifyObservers(mgr, + NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID, + statusMsg.get()); } } } @@ -904,9 +905,9 @@ mozJSComponentLoader::UnregisterComponent(nsIFile *component) rv = NS_GetServiceManager(getter_AddRefs(mgr)); if (NS_SUCCEEDED(rv)) { - (void) observerService->Notify(mgr, - NS_ConvertASCIItoUCS2(NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID).get(), - NS_ConvertASCIItoUCS2("Unregistering JS component").get()); + (void) observerService->NotifyObservers(mgr, + NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID, + NS_ConvertASCIItoUCS2("Unregistering JS component").get()); } } } diff --git a/mozilla/js/src/xpconnect/tests/js/old/xpctest_observer.js b/mozilla/js/src/xpconnect/tests/js/old/xpctest_observer.js index 9f1f213dacf..e8ef21da8ef 100644 --- a/mozilla/js/src/xpconnect/tests/js/old/xpctest_observer.js +++ b/mozilla/js/src/xpconnect/tests/js/old/xpctest_observer.js @@ -22,13 +22,13 @@ var observer2 = { } const topic = "xpctest_observer_topic"; -observerService.AddObserver(observer1, topic); -observerService.AddObserver(observer2, topic); +observerService.addObserver(observer1, topic, false); +observerService.addObserver(observer2, topic, false); -observerService.Notify(null, topic, "notification 1"); +observerService.notifyObservers(null, topic, "notification 1"); gc(); observer1 = null; observer2 = null; -observerService.Notify(null, topic, "notification 2"); +observerService.notifyObservers(null, topic, "notification 2"); gc(); -observerService.Notify(null, topic, "notification 3"); +observerService.notifyObservers(null, topic, "notification 3"); diff --git a/mozilla/layout/base/nsPresContext.cpp b/mozilla/layout/base/nsPresContext.cpp index b137f730552..c734d0f7f7d 100644 --- a/mozilla/layout/base/nsPresContext.cpp +++ b/mozilla/layout/base/nsPresContext.cpp @@ -734,18 +734,17 @@ nsPresContext::UpdateCharSet(const PRUnichar* aCharSet) } NS_IMETHODIMP -nsPresContext::Observe(nsISupports* aSubject, const PRUnichar* aTopic, +nsPresContext::Observe(nsISupports* aSubject, + const char* aTopic, const PRUnichar* aData) { - if (nsAutoString(aTopic).EqualsWithConversion("charset")) { + if (!nsCRT::strcmp(aTopic, "charset")) { UpdateCharSet(aData); - } - else { - NS_WARNING("unrecognized topic in nsPresContext::Observe"); - return NS_ERROR_FAILURE; + return NS_OK; } - return NS_OK; + NS_WARNING("unrecognized topic in nsPresContext::Observe"); + return NS_ERROR_FAILURE; } NS_IMETHODIMP diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 9c1bc0671b8..d35a4f2dac0 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -103,6 +103,7 @@ #include "plarena.h" #include "nsCSSAtoms.h" #include "nsIObserverService.h" // for reflow observation +#include "nsObserverService.h" #include "nsIDocShell.h" // for reflow observation #include "nsIDOMRange.h" #ifdef MOZ_PERF_METRICS @@ -2507,9 +2508,6 @@ PresShell::NotifyReflowObservers(const char *aData) nsresult result = NS_OK; nsCOMPtr pContainer; nsCOMPtr pDocShell; - nsAutoString sTopic, - sData; - result = mPresContext->GetContainer( getter_AddRefs( pContainer ) ); @@ -2518,11 +2516,9 @@ PresShell::NotifyReflowObservers(const char *aData) &result ); if (NS_SUCCEEDED( result ) && pDocShell && mObserverService) { - sTopic.AssignWithConversion( NS_PRESSHELL_REFLOW_TOPIC ); - sData.AssignWithConversion( aData ); - result = mObserverService->Notify( pDocShell, - sTopic.get(), - sData.get() ); + result = mObserverService->NotifyObservers( pDocShell, + NS_PRESSHELL_REFLOW_TOPIC, + NS_ConvertASCIItoUCS2(aData).get() ); // notice that we don't really care what the observer service returns } } diff --git a/mozilla/layout/base/src/nsPresContext.cpp b/mozilla/layout/base/src/nsPresContext.cpp index b137f730552..c734d0f7f7d 100644 --- a/mozilla/layout/base/src/nsPresContext.cpp +++ b/mozilla/layout/base/src/nsPresContext.cpp @@ -734,18 +734,17 @@ nsPresContext::UpdateCharSet(const PRUnichar* aCharSet) } NS_IMETHODIMP -nsPresContext::Observe(nsISupports* aSubject, const PRUnichar* aTopic, +nsPresContext::Observe(nsISupports* aSubject, + const char* aTopic, const PRUnichar* aData) { - if (nsAutoString(aTopic).EqualsWithConversion("charset")) { + if (!nsCRT::strcmp(aTopic, "charset")) { UpdateCharSet(aData); - } - else { - NS_WARNING("unrecognized topic in nsPresContext::Observe"); - return NS_ERROR_FAILURE; + return NS_OK; } - return NS_OK; + NS_WARNING("unrecognized topic in nsPresContext::Observe"); + return NS_ERROR_FAILURE; } NS_IMETHODIMP diff --git a/mozilla/layout/base/src/nsPresContext.h b/mozilla/layout/base/src/nsPresContext.h index ab3933e1c92..4985943626d 100644 --- a/mozilla/layout/base/src/nsPresContext.h +++ b/mozilla/layout/base/src/nsPresContext.h @@ -166,7 +166,8 @@ public: #endif // nsIObserver method - NS_IMETHOD Observe(nsISupports* aSubject, const PRUnichar* aTopic, + NS_IMETHOD Observe(nsISupports* aSubject, + const char* aTopic, const PRUnichar* aData); #ifdef IBMBIDI diff --git a/mozilla/layout/build/nsContentHTTPStartup.cpp b/mozilla/layout/build/nsContentHTTPStartup.cpp index 2560f6717ac..9f00ce77054 100644 --- a/mozilla/layout/build/nsContentHTTPStartup.cpp +++ b/mozilla/layout/build/nsContentHTTPStartup.cpp @@ -54,7 +54,7 @@ NS_IMPL_ISUPPORTS1(nsContentHTTPStartup,nsIObserver) nsresult nsContentHTTPStartup::Observe( nsISupports *aSubject, - const PRUnichar *aTopic, + const char *aTopic, const PRUnichar *aData) { if (nsCRT::strcmp(aTopic, NS_HTTP_STARTUP_TOPIC) != 0) diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index 9c1bc0671b8..d35a4f2dac0 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -103,6 +103,7 @@ #include "plarena.h" #include "nsCSSAtoms.h" #include "nsIObserverService.h" // for reflow observation +#include "nsObserverService.h" #include "nsIDocShell.h" // for reflow observation #include "nsIDOMRange.h" #ifdef MOZ_PERF_METRICS @@ -2507,9 +2508,6 @@ PresShell::NotifyReflowObservers(const char *aData) nsresult result = NS_OK; nsCOMPtr pContainer; nsCOMPtr pDocShell; - nsAutoString sTopic, - sData; - result = mPresContext->GetContainer( getter_AddRefs( pContainer ) ); @@ -2518,11 +2516,9 @@ PresShell::NotifyReflowObservers(const char *aData) &result ); if (NS_SUCCEEDED( result ) && pDocShell && mObserverService) { - sTopic.AssignWithConversion( NS_PRESSHELL_REFLOW_TOPIC ); - sData.AssignWithConversion( aData ); - result = mObserverService->Notify( pDocShell, - sTopic.get(), - sData.get() ); + result = mObserverService->NotifyObservers( pDocShell, + NS_PRESSHELL_REFLOW_TOPIC, + NS_ConvertASCIItoUCS2(aData).get() ); // notice that we don't really care what the observer service returns } } diff --git a/mozilla/layout/html/forms/src/nsFormFrame.cpp b/mozilla/layout/html/forms/src/nsFormFrame.cpp index 3f827926a15..7deeaec0e0c 100644 --- a/mozilla/layout/html/forms/src/nsFormFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFormFrame.cpp @@ -99,6 +99,7 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); // FormSubmit observer notification #include "nsIFormSubmitObserver.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIServiceManager.h" #include "nsICategoryManager.h" @@ -473,7 +474,7 @@ void nsFormFrame::AddFormControlFrame(nsIPresContext* aPresContext, nsIFormContr gInitPasswordManager = PR_TRUE; NS_CreateServicesFromCategory(NS_PASSWORDMANAGER_CATEGORY, NS_STATIC_CAST(nsISupports*,NS_STATIC_CAST(void*,this)), - NS_ConvertASCIItoUCS2(NS_PASSWORDMANAGER_CATEGORY).get()); + NS_PASSWORDMANAGER_CATEGORY); } // Add this control to the list @@ -881,7 +882,7 @@ nsFormFrame::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame) gFirstFormSubmitted = PR_TRUE; NS_CreateServicesFromCategory(NS_FIRST_FORMSUBMIT_CATEGORY, NS_STATIC_CAST(nsISupports*,NS_STATIC_CAST(void*,this)), - NS_ConvertASCIItoUCS2(NS_FIRST_FORMSUBMIT_CATEGORY).get()); + NS_FIRST_FORMSUBMIT_CATEGORY); } // Notify observers that the form is being submitted. @@ -890,9 +891,9 @@ nsFormFrame::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame) do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &result); if (NS_FAILED(result)) return result; - nsString theTopic; theTopic.AssignWithConversion(NS_FORMSUBMIT_SUBJECT); - nsCOMPtr theEnum; - result = service->EnumerateObserverList(theTopic.get(), getter_AddRefs(theEnum)); + nsCOMPtr theEnum; + result = service->EnumerateObservers(NS_FORMSUBMIT_SUBJECT, getter_AddRefs(theEnum)); + if (NS_SUCCEEDED(result) && theEnum){ nsCOMPtr inst; PRBool cancelSubmit = PR_FALSE; @@ -900,11 +901,11 @@ nsFormFrame::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame) nsCOMPtr globalObject; document->GetScriptGlobalObject(getter_AddRefs(globalObject)); nsCOMPtr window = do_QueryInterface(globalObject); + PRBool loop = PR_TRUE; + while(NS_SUCCEEDED(theEnum->HasMoreElements(&loop)) && loop) { - for (theEnum->First(); theEnum->IsDone() != NS_OK; theEnum->Next()) { - nsresult gotObserver = NS_OK; - gotObserver = theEnum->CurrentItem(getter_AddRefs(inst)); - if (NS_SUCCEEDED(gotObserver) && inst) { + theEnum->GetNext(getter_AddRefs(inst)); + if (inst) { nsCOMPtr formSubmitObserver = do_QueryInterface(inst, &result); if (NS_SUCCEEDED(result) && formSubmitObserver) { nsresult notifyStatus = formSubmitObserver->Notify(mContent, window, actionURL, &cancelSubmit); diff --git a/mozilla/layout/mathml/base/src/nsMathMLChar.cpp b/mozilla/layout/mathml/base/src/nsMathMLChar.cpp index eb0d9d40bd2..d53899f04ff 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLChar.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLChar.cpp @@ -41,6 +41,7 @@ #include "nsIPersistentProperties2.h" #include "nsIServiceManager.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIObserver.h" #include "nsNetUtil.h" #include "nsIURI.h" @@ -724,8 +725,7 @@ nsGlyphTableList::Initialize() nsCOMPtr obs = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { - nsAutoString topic; topic.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); - rv = obs->AddObserver(this, topic.get()); + rv = obs->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE); } return rv; } diff --git a/mozilla/mailnews/base/resources/content/commandglue.js b/mozilla/mailnews/base/resources/content/commandglue.js index 93dcd01a6e1..cb594432c09 100644 --- a/mozilla/mailnews/base/resources/content/commandglue.js +++ b/mozilla/mailnews/base/resources/content/commandglue.js @@ -789,12 +789,12 @@ var mailOfflineObserver = { function AddMailOfflineObserver() { var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService); - observerService.AddObserver(mailOfflineObserver, "network:offline-status-changed"); + observerService.addObserver(mailOfflineObserver, "network:offline-status-changed", false); } function RemoveMailOfflineObserver() { var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService); - observerService.RemoveObserver(mailOfflineObserver,"network:offline-status-changed"); + observerService.removeObserver(mailOfflineObserver,"network:offline-status-changed"); } diff --git a/mozilla/mailnews/base/resources/content/widgetglue.js b/mozilla/mailnews/base/resources/content/widgetglue.js index ccdc2504757..b348037a609 100644 --- a/mozilla/mailnews/base/resources/content/widgetglue.js +++ b/mozilla/mailnews/base/resources/content/widgetglue.js @@ -223,7 +223,7 @@ function NotifyQuitApplication() { try { - ObserverService.Notify(null, "quit-application", null); + ObserverService.notifyObservers(null, "quit-application", null); } catch (ex) { diff --git a/mozilla/mailnews/base/src/nsMessengerMigrator.cpp b/mozilla/mailnews/base/src/nsMessengerMigrator.cpp index 6c3b8f6e671..243666c7228 100644 --- a/mozilla/mailnews/base/src/nsMessengerMigrator.cpp +++ b/mozilla/mailnews/base/src/nsMessengerMigrator.cpp @@ -67,6 +67,7 @@ #include "nsMsgUtils.h" #include "nsISmtpService.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIMsgAccount.h" #include "nsIMsgAccountManager.h" @@ -366,8 +367,7 @@ nsMessengerMigrator::~nsMessengerMigrator() do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { - nsAutoString topic; topic.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); - observerService->RemoveObserver(this, topic.get()); + observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID); } } } @@ -380,8 +380,7 @@ nsresult nsMessengerMigrator::Init() do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { - nsAutoString topic; topic.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); - observerService->AddObserver(this, topic.get()); + observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE); } initializeStrings(); @@ -448,12 +447,9 @@ nsMessengerMigrator::initializeStrings() -NS_IMETHODIMP nsMessengerMigrator::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +NS_IMETHODIMP nsMessengerMigrator::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { - nsAutoString topicString(aTopic); - nsAutoString shutdownString; shutdownString.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); - - if(topicString == shutdownString) + if(!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) { Shutdown(); } diff --git a/mozilla/mailnews/base/src/nsMsgAccountManager.cpp b/mozilla/mailnews/base/src/nsMsgAccountManager.cpp index 693a02e0407..d6a3adeba75 100644 --- a/mozilla/mailnews/base/src/nsMsgAccountManager.cpp +++ b/mozilla/mailnews/base/src/nsMsgAccountManager.cpp @@ -67,6 +67,7 @@ #include "nsISmtpService.h" #include "nsIMsgBiffManager.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIMsgMailSession.h" #include "nsIEventQueueService.h" #include "nsIDirectoryService.h" @@ -163,10 +164,8 @@ nsMsgAccountManager::~nsMsgAccountManager() do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { - nsAutoString topic; topic.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); - observerService->RemoveObserver(this, topic.get()); - topic.Assign(NS_LITERAL_STRING("network:offline-status-changed")); - observerService->RemoveObserver(this, topic.get()); + observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID); + observerService->RemoveObserver(this, "network:offline-status-changed"); } } } @@ -187,12 +186,11 @@ nsresult nsMsgAccountManager::Init() do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { - nsAutoString topic; topic.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); - observerService->AddObserver(this, topic.get()); - observerService->AddObserver(this, NS_LITERAL_STRING("quit-application").get()); - observerService->AddObserver(this, NS_LITERAL_STRING("network:offline-status-changed").get()); - observerService->AddObserver(this, NS_LITERAL_STRING("session-logout").get()); - observerService->AddObserver(this, NS_LITERAL_STRING("profile-before-change").get()); + observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE); + observerService->AddObserver(this, "quit-application" , PR_TRUE); + observerService->AddObserver(this, "network:offline-status-changed", PR_TRUE); + observerService->AddObserver(this, "session-logout", PR_TRUE); + observerService->AddObserver(this, "profile-before-change", PR_TRUE); } return NS_OK; @@ -232,25 +230,21 @@ nsMsgAccountManager::GetShutdownInProgress(PRBool *_retval) return NS_OK; } -NS_IMETHODIMP nsMsgAccountManager::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +NS_IMETHODIMP nsMsgAccountManager::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { - nsAutoString topicString(aTopic); - nsAutoString shutdownString; - shutdownString.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); - nsAutoString quitApplicationString; - quitApplicationString.Assign(NS_LITERAL_STRING("quit-application")); - nsAutoString offlineStatusChangedString(NS_LITERAL_STRING("network:offline-status-changed")); - NS_NAMED_LITERAL_STRING(sessionLogoutString, "session-logout"); - NS_NAMED_LITERAL_STRING(beforeProfileChangeString, "profile-before-change"); - if(topicString == shutdownString) + if(!nsCRT::strcmp(aTopic,NS_XPCOM_SHUTDOWN_OBSERVER_ID)) { Shutdown(); + return NS_OK; } - else if (topicString == quitApplicationString) + + if (!nsCRT::strcmp(aTopic,"quit-application")) { m_shutdownInProgress = PR_TRUE; + return NS_OK; } - else if (topicString == offlineStatusChangedString) + + if (!nsCRT::strcmp(aTopic,"network:offline-status-changed")) { nsAutoString dataString(NS_LITERAL_STRING("offline")); if (someData) @@ -259,14 +253,19 @@ NS_IMETHODIMP nsMsgAccountManager::Observe(nsISupports *aSubject, const PRUnicha if (dataString == someDataString) CloseCachedConnections(); } + return NS_OK; } - else if (sessionLogoutString.Equals(topicString)) + + if (!nsCRT::strcmp(aTopic, "session-logout")) { m_incomingServers.Enumerate(hashLogoutOfServer, nsnull); + return NS_OK; } - else if (beforeProfileChangeString.Equals(topicString)) + + if (!nsCRT::strcmp(aTopic, "profile-before-change")) { Shutdown(); + return NS_OK; } return NS_OK; diff --git a/mozilla/mailnews/base/src/nsMsgBiffManager.cpp b/mozilla/mailnews/base/src/nsMsgBiffManager.cpp index 469778d48a2..fcdfc92e21c 100644 --- a/mozilla/mailnews/base/src/nsMsgBiffManager.cpp +++ b/mozilla/mailnews/base/src/nsMsgBiffManager.cpp @@ -41,6 +41,7 @@ #include "nsIMsgAccountManager.h" #include "nsMsgBaseCID.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsStatusBarBiffManager.h" static NS_DEFINE_CID(kStatusBarBiffManagerCID, NS_STATUSBARBIFFMANAGER_CID); @@ -87,8 +88,7 @@ nsMsgBiffManager::~nsMsgBiffManager() do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { - nsAutoString topic; topic.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); - observerService->RemoveObserver(this, topic.get()); + observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID); } } } @@ -112,8 +112,7 @@ nsresult nsMsgBiffManager::Init() do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { - nsAutoString topic; topic.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); - observerService->AddObserver(this, topic.get()); + observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE); } @@ -227,12 +226,9 @@ NS_IMETHODIMP nsMsgBiffManager::OnServerChanged(nsIMsgIncomingServer *server) return NS_OK; } -NS_IMETHODIMP nsMsgBiffManager::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +NS_IMETHODIMP nsMsgBiffManager::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { - nsAutoString topicString(aTopic); - nsAutoString shutdownString; shutdownString.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); - - if(topicString == shutdownString) + if(!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) { Shutdown(); } diff --git a/mozilla/mailnews/base/src/nsMsgOfflineManager.cpp b/mozilla/mailnews/base/src/nsMsgOfflineManager.cpp index d2d964f4ceb..1868b3a6df5 100644 --- a/mozilla/mailnews/base/src/nsMsgOfflineManager.cpp +++ b/mozilla/mailnews/base/src/nsMsgOfflineManager.cpp @@ -383,7 +383,7 @@ nsMsgOfflineManager::OnStopRunningUrl(nsIURI * aUrl, nsresult aExitCode) return NS_OK; } -NS_IMETHODIMP nsMsgOfflineManager::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +NS_IMETHODIMP nsMsgOfflineManager::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { return NS_OK; } diff --git a/mozilla/mailnews/base/src/nsMsgRDFDataSource.cpp b/mozilla/mailnews/base/src/nsMsgRDFDataSource.cpp index 85cd6131545..7d2b166acdc 100644 --- a/mozilla/mailnews/base/src/nsMsgRDFDataSource.cpp +++ b/mozilla/mailnews/base/src/nsMsgRDFDataSource.cpp @@ -43,6 +43,7 @@ #include "nsMsgRDFUtils.h" #include "nsEnumeratorUtils.h" #include "nsIObserverService.h" +#include "nsObserverService.h" static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); @@ -80,8 +81,7 @@ nsMsgRDFDataSource::Init() nsCOMPtr obs = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; - nsAutoString topic; topic.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); - rv = obs->AddObserver(NS_STATIC_CAST(nsIObserver*, this), topic.get()); + rv = obs->AddObserver(NS_STATIC_CAST(nsIObserver*, this), NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE); if (NS_FAILED(rv)) return rv; /* Get and keep the rdf service. Will be released by the observer */ @@ -101,9 +101,8 @@ void nsMsgRDFDataSource::Cleanup() nsCOMPtr obs = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { - nsAutoString topic; topic.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); rv = obs->RemoveObserver(NS_STATIC_CAST(nsIObserver*, this), - topic.get()); + NS_XPCOM_SHUTDOWN_OBSERVER_ID); } // release the window @@ -323,7 +322,7 @@ nsMsgRDFDataSource::DoCommand(nsISupportsArray *aSources, nsIRDFResource *aComma /* XPCOM Shutdown observer */ NS_IMETHODIMP -nsMsgRDFDataSource::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData ) +nsMsgRDFDataSource::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData ) { m_shuttingDown = PR_TRUE; Cleanup(); diff --git a/mozilla/mailnews/compose/resources/content/MsgComposeCommands.js b/mozilla/mailnews/compose/resources/content/MsgComposeCommands.js index 8b3cbc112ab..f70b797a1a3 100644 --- a/mozilla/mailnews/compose/resources/content/MsgComposeCommands.js +++ b/mozilla/mailnews/compose/resources/content/MsgComposeCommands.js @@ -562,7 +562,7 @@ var messageComposeOfflineObserver = { function AddMessageComposeOfflineObserver() { var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService); - observerService.AddObserver(messageComposeOfflineObserver, "network:offline-status-changed"); + observerService.addObserver(messageComposeOfflineObserver, "network:offline-status-changed", false); isOffline = ioService.offline; // set the initial state of the send button @@ -572,7 +572,7 @@ function AddMessageComposeOfflineObserver() function RemoveMessageComposeOfflineObserver() { var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService); - observerService.RemoveObserver(messageComposeOfflineObserver,"network:offline-status-changed"); + observerService.removeObserver(messageComposeOfflineObserver,"network:offline-status-changed"); } function MessageComposeOfflineStateChanged(goingOffline) @@ -619,15 +619,15 @@ var directoryServerObserver = { function AddDirectoryServerObserver(flag) { if (flag) { - prefs.addObserver("ldap_2.autoComplete.useDirectory", directoryServerObserver); - prefs.addObserver("ldap_2.autoComplete.directoryServer", directoryServerObserver); + prefs.addObserver("ldap_2.autoComplete.useDirectory", directoryServerObserver, false); + prefs.addObserver("ldap_2.autoComplete.directoryServer", directoryServerObserver, false); } else { var prefstring = "mail.identity." + gCurrentIdentity.key + ".overrideGlobal_Pref"; - prefs.addObserver(prefstring, directoryServerObserver); + prefs.addObserver(prefstring, directoryServerObserver, false); prefstring = "mail.identity." + gCurrentIdentity.key + ".directoryServer"; - prefs.addObserver(prefstring, directoryServerObserver); + prefs.addObserver(prefstring, directoryServerObserver, false); } } @@ -648,7 +648,7 @@ function RemoveDirectoryServerObserver(prefstring) function AddDirectorySettingsObserver() { - prefs.addObserver(currentAutocompleteDirectory, directoryServerObserver); + prefs.addObserver(currentAutocompleteDirectory, directoryServerObserver, false); } function RemoveDirectorySettingsObserver(prefstring) diff --git a/mozilla/mailnews/db/msgdb/src/nsDBFolderInfo.cpp b/mozilla/mailnews/db/msgdb/src/nsDBFolderInfo.cpp index bfd12ec1e29..1326e59afb4 100644 --- a/mozilla/mailnews/db/msgdb/src/nsDBFolderInfo.cpp +++ b/mozilla/mailnews/db/msgdb/src/nsDBFolderInfo.cpp @@ -43,6 +43,7 @@ #include "nsIPref.h" #include "nsIObserver.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIMsgDBView.h" #include "nsReadableUtils.h" @@ -94,15 +95,14 @@ public: NS_IMPL_ISUPPORTS1(nsFolderCharsetObserver, nsIObserver); -NS_IMETHODIMP nsFolderCharsetObserver::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +NS_IMETHODIMP nsFolderCharsetObserver::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { nsresult rv; nsCOMPtr prefs = do_GetService(NS_PREF_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); - nsDependentString aTopicString(aTopic); - if (aTopicString.Equals(NS_LITERAL_STRING("nsPref:changed"))) + if (!nsCRT::strcmp(aTopic, "nsPref:changed")) { nsDependentString prefName(someData); @@ -121,7 +121,7 @@ NS_IMETHODIMP nsFolderCharsetObserver::Observe(nsISupports *aSubject, const PRUn rv = prefs->GetBoolPref(kMAILNEWS_DEFAULT_CHARSET_OVERRIDE, &gDefaultCharacterOverride); } } - else if (aTopicString.Equals(NS_LITERAL_STRING(NS_XPCOM_SHUTDOWN_OBSERVER_ID))) + else if (!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) { rv = prefs->RemoveObserver(kMAILNEWS_VIEW_DEFAULT_CHARSET, this); rv = prefs->RemoveObserver(kMAILNEWS_DEFAULT_CHARSET_OVERRIDE, this); @@ -211,7 +211,7 @@ nsDBFolderInfo::nsDBFolderInfo(nsMsgDatabase *mdb) nsCOMPtr observerService = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { - rv = observerService->AddObserver(gFolderCharsetObserver, NS_LITERAL_STRING(NS_XPCOM_SHUTDOWN_OBSERVER_ID).get()); + rv = observerService->AddObserver(gFolderCharsetObserver, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE); } } } diff --git a/mozilla/modules/libjar/nsJAR.cpp b/mozilla/modules/libjar/nsJAR.cpp index f7a7d6f05a9..aa180700a53 100644 --- a/mozilla/modules/libjar/nsJAR.cpp +++ b/mozilla/modules/libjar/nsJAR.cpp @@ -31,6 +31,7 @@ #include "nsXPIDLString.h" #include "nsReadableUtils.h" #include "nsIServiceManager.h" +#include "nsObserverService.h" #include "plbase64.h" #include "nsIConsoleService.h" #include "nscore.h" @@ -1146,7 +1147,7 @@ nsZipReaderCache::Init(PRUint32 cacheSize) do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { - rv = os->AddObserver(this, NS_MEMORY_PRESSURE_TOPIC); + rv = os->AddObserver(this, NS_MEMORY_PRESSURE_TOPIC, PR_TRUE); } // ignore failure of the observer registration. @@ -1356,7 +1357,7 @@ FindFlushableZip(nsHashKey *aKey, void *aData, void* closure) NS_IMETHODIMP nsZipReaderCache::Observe(nsISupports *aSubject, - const PRUnichar *aTopic, + const char *aTopic, const PRUnichar *aSomeData) { if (nsCRT::strcmp(aTopic, NS_MEMORY_PRESSURE_TOPIC) == 0) { diff --git a/mozilla/modules/libjar/nsJAR.h b/mozilla/modules/libjar/nsJAR.h index 043f2f82f80..ba4b71ced37 100644 --- a/mozilla/modules/libjar/nsJAR.h +++ b/mozilla/modules/libjar/nsJAR.h @@ -53,6 +53,7 @@ #include "nsISignatureVerifier.h" #include "nsIObserverService.h" #include "nsWeakReference.h" +#include "nsIObserver.h" class nsIInputStream; class nsJARManifestItem; diff --git a/mozilla/modules/libpref/src/nsAutoConfig.cpp b/mozilla/modules/libpref/src/nsAutoConfig.cpp index 5b0d868465f..cb2f0bb0597 100644 --- a/mozilla/modules/libpref/src/nsAutoConfig.cpp +++ b/mozilla/modules/libpref/src/nsAutoConfig.cpp @@ -46,6 +46,7 @@ #include "prefapi.h" #include "nsIProfile.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIEventQueueService.h" #include "nsLiteralString.h" #include "nsReadableUtils.h" @@ -72,7 +73,7 @@ nsresult nsAutoConfig::Init() if (NS_FAILED(rv)) return rv; - rv = observerService->AddObserver(this,NS_LITERAL_STRING("profile-after-change").get()); + rv = observerService->AddObserver(this,"profile-after-change", PR_FALSE); return rv; } @@ -189,12 +190,11 @@ NS_IMETHODIMP_(void) nsAutoConfig::Notify(nsITimer *timer) */ NS_IMETHODIMP nsAutoConfig::Observe(nsISupports *aSubject, - const PRUnichar *aTopic, + const char *aTopic, const PRUnichar *someData) { nsresult rv=NS_OK; - if (!nsCRT::strcmp(aTopic, - NS_LITERAL_STRING("profile-after-change").get())) { + if (!nsCRT::strcmp(aTopic, "profile-after-change")) { // Getting the current profile name since we already have the // pointer to the object. diff --git a/mozilla/modules/libpref/src/nsPref.cpp b/mozilla/modules/libpref/src/nsPref.cpp index f6b5aaba3a7..eb962f12ad3 100644 --- a/mozilla/modules/libpref/src/nsPref.cpp +++ b/mozilla/modules/libpref/src/nsPref.cpp @@ -366,7 +366,7 @@ NS_IMETHODIMP nsPref::RemoveObserver(const char *aDomain, nsIObserver *aObserver return rv; } -NS_IMETHODIMP nsPref::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +NS_IMETHODIMP nsPref::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { nsresult rv; diff --git a/mozilla/modules/libpref/src/nsPrefBranch.cpp b/mozilla/modules/libpref/src/nsPrefBranch.cpp index 092aa2f2dce..93bdbe24f4f 100644 --- a/mozilla/modules/libpref/src/nsPrefBranch.cpp +++ b/mozilla/modules/libpref/src/nsPrefBranch.cpp @@ -659,7 +659,7 @@ static int PR_CALLBACK NotifyObserver(const char *newpref, void *data) nsCOMPtr observer = NS_STATIC_CAST(nsIObserver *, pData->pObserver); observer->Observe(pData->pBranch, - NS_LITERAL_STRING(NS_PREFBRANCH_PREFCHANGE_OBSERVER_ID).get(), + NS_PREFBRANCH_PREFCHANGE_OBSERVER_ID, NS_ConvertASCIItoUCS2(newpref).get()); return 0; diff --git a/mozilla/modules/libpref/src/nsPrefService.cpp b/mozilla/modules/libpref/src/nsPrefService.cpp index 56e6fbe715e..fbf005224a0 100644 --- a/mozilla/modules/libpref/src/nsPrefService.cpp +++ b/mozilla/modules/libpref/src/nsPrefService.cpp @@ -41,6 +41,7 @@ #include "nsAppDirectoryServiceDefs.h" #include "nsDirectoryServiceDefs.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsPrefBranch.h" #include "nsXPIDLString.h" #include "nsIAutoConfig.h" @@ -139,21 +140,21 @@ nsresult nsPrefService::Init() if (observerService) { // Our refcnt must be > 0 when we call this, or we'll get deleted! ++mRefCnt; - rv = observerService->AddObserver(this, NS_LITERAL_STRING("profile-before-change").get()); + rv = observerService->AddObserver(this, "profile-before-change", PR_TRUE); if (NS_SUCCEEDED(rv)) { - rv = observerService->AddObserver(this, NS_LITERAL_STRING("profile-do-change").get()); + rv = observerService->AddObserver(this, "profile-do-change", PR_TRUE); } --mRefCnt; } return(rv); } -NS_IMETHODIMP nsPrefService::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +NS_IMETHODIMP nsPrefService::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { nsresult rv = NS_OK; - if (!nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-before-change").get())) { - if (!nsCRT::strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get())) { + if (!nsCRT::strcmp(aTopic, "profile-before-change")) { + if (!nsCRT::strcmp(someData, "shutdown-cleanse")) { if (mCurrentFile) { mCurrentFile->Remove(PR_FALSE); NS_RELEASE(mCurrentFile); @@ -161,7 +162,7 @@ NS_IMETHODIMP nsPrefService::Observe(nsISupports *aSubject, const PRUnichar *aTo } else { rv = SavePrefFile(nsnull); } - } else if (!nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-do-change").get())) { + } else if (!nsCRT::strcmp(aTopic, "profile-do-change")) { ResetUserPrefs(); rv = ReadUserPrefs(nsnull); } diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index cbd293bef79..c1e50651d15 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -57,6 +57,7 @@ #include "nsIPluginStreamListener.h" #include "nsIHTTPHeaderListener.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIHttpProtocolHandler.h" #include "nsIHttpChannel.h" #include "nsIUploadChannel.h" @@ -2398,8 +2399,8 @@ nsPluginHostImpl::nsPluginHostImpl() nsCOMPtr obsService = do_GetService(NS_OBSERVERSERVICE_CONTRACTID); if (obsService) { - obsService->AddObserver(this, NS_LITERAL_STRING("quit-application").get()); - obsService->AddObserver(this, NS_ConvertASCIItoUCS2(NS_XPCOM_SHUTDOWN_OBSERVER_ID).get()); + obsService->AddObserver(this, "quit-application", PR_FALSE); + obsService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE); } #ifdef PLUGIN_LOGGING @@ -2430,8 +2431,8 @@ nsPluginHostImpl::~nsPluginHostImpl() nsCOMPtr obsService = do_GetService(NS_OBSERVERSERVICE_CONTRACTID); if (obsService) { - obsService->RemoveObserver(this, NS_LITERAL_STRING("quit-application").get()); - obsService->RemoveObserver(this, NS_ConvertASCIItoUCS2(NS_XPCOM_SHUTDOWN_OBSERVER_ID).get()); + obsService->RemoveObserver(this, "quit-application"); + obsService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID); } Destroy(); } @@ -5709,18 +5710,14 @@ NS_IMETHODIMP nsPluginHostImpl::SetCookie(const char* inCookieURL, const void* i //////////////////////////////////////////////////////////////////////// NS_IMETHODIMP nsPluginHostImpl::Observe(nsISupports *aSubject, - const PRUnichar *aTopic, + const char *aTopic, const PRUnichar *someData) { #ifdef NS_DEBUG - nsAutoString topic(aTopic); - char * newString = ToNewCString(topic); - printf("nsPluginHostImpl::Observe \"%s\"\n", newString ? newString : ""); - if (newString) - nsCRT::free(newString); + printf("nsPluginHostImpl::Observe \"%s\"\n", aTopic ? aTopic : ""); #endif - if (NS_ConvertASCIItoUCS2(NS_XPCOM_SHUTDOWN_OBSERVER_ID).Equals(aTopic) || - NS_LITERAL_STRING("quit-application").Equals(aTopic)) + if (!nsCRT::strcmp(NS_XPCOM_SHUTDOWN_OBSERVER_ID, aTopic) || + !nsCRT::strcmp("quit-application", aTopic)) { Destroy(); } diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.h b/mozilla/modules/plugin/base/src/nsPluginHostImpl.h index e5fdcca778e..5313502eb2f 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.h +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.h @@ -355,7 +355,7 @@ public: // Methods from nsIObserver NS_IMETHOD - Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData); + Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData); // Methods from nsPIPluginHost NS_IMETHOD diff --git a/mozilla/netwerk/base/src/nsIOService.cpp b/mozilla/netwerk/base/src/nsIOService.cpp index 0d4932b73e3..72b0bc806e2 100644 --- a/mozilla/netwerk/base/src/nsIOService.cpp +++ b/mozilla/netwerk/base/src/nsIOService.cpp @@ -51,6 +51,7 @@ #include "nsIErrorService.h" #include "netCore.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIHttpProtocolHandler.h" #include "nsIPrefService.h" #include "nsIPrefBranchInternal.h" @@ -224,7 +225,7 @@ nsIOService::Init() nsCOMPtr observerService = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (observerService) - observerService->AddObserver(this, NS_LITERAL_STRING(NS_XPCOM_SHUTDOWN_OBSERVER_ID).get()); + observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE); return NS_OK; } @@ -798,9 +799,9 @@ nsIOService::SetOffline(PRBool offline) if (offline) { // don't care if notification fails if (observerService) - (void)observerService->Notify(NS_STATIC_CAST(nsIIOService *, this), - NS_LITERAL_STRING("network:offline-status-changed").get(), - NS_LITERAL_STRING("offline").get()); + (void)observerService->NotifyObservers(NS_STATIC_CAST(nsIIOService *, this), + "network:offline-status-changed", + NS_LITERAL_STRING("offline").get()); mOffline = PR_TRUE; // indicate we're trying to shutdown // be sure to try and shutdown both (even if the first fails) if (mDNSService) @@ -824,9 +825,9 @@ nsIOService::SetOffline(PRBool offline) // brought up the services // don't care if notification fails if (observerService) - (void)observerService->Notify(NS_STATIC_CAST(nsIIOService *, this), - NS_LITERAL_STRING("network:offline-status-changed").get(), - NS_LITERAL_STRING("online").get()); + (void)observerService->NotifyObservers(NS_STATIC_CAST(nsIIOService *, this), + "network:offline-status-changed", + NS_LITERAL_STRING("online").get()); } return NS_OK; } @@ -994,15 +995,15 @@ nsIOService::GetPrefBranch(nsIPrefBranch **result) // nsIObserver interface NS_IMETHODIMP nsIOService::Observe(nsISupports *subject, - const PRUnichar *topic, + const char *topic, const PRUnichar *data) { - if (!nsCRT::strcmp(topic, NS_LITERAL_STRING("nsPref:changed").get())) { + if (!nsCRT::strcmp(topic, "nsPref:changed")) { nsCOMPtr prefBranch = do_QueryInterface(subject); if (prefBranch) PrefsChanged(prefBranch, NS_ConvertUCS2toUTF8(data).get()); } - else if (!nsCRT::strcmp(topic, NS_LITERAL_STRING(NS_XPCOM_SHUTDOWN_OBSERVER_ID).get())) { + else if (!nsCRT::strcmp(topic,NS_XPCOM_SHUTDOWN_OBSERVER_ID)) { // Clean up the prefs observer to break the reference cycle nsCOMPtr prefBranch; GetPrefBranch(getter_AddRefs(prefBranch)); diff --git a/mozilla/netwerk/cache/src/nsCacheService.cpp b/mozilla/netwerk/cache/src/nsCacheService.cpp index 0cb02b3e361..0f6e9250206 100644 --- a/mozilla/netwerk/cache/src/nsCacheService.cpp +++ b/mozilla/netwerk/cache/src/nsCacheService.cpp @@ -35,6 +35,7 @@ #include "nsAutoLock.h" #include "nsIEventQueue.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIPrefService.h" #include "nsIPrefBranch.h" #include "nsIPrefBranchInternal.h" @@ -113,15 +114,15 @@ nsCacheProfilePrefObserver::Install() if (NS_FAILED(rv)) return rv; NS_ENSURE_ARG(observerService); - rv = observerService->AddObserver(this, NS_LITERAL_STRING("profile-before-change").get()); + rv = observerService->AddObserver(this, "profile-before-change", PR_FALSE); if (NS_FAILED(rv)) rv2 = rv; - rv = observerService->AddObserver(this, NS_LITERAL_STRING("profile-after-change").get()); + rv = observerService->AddObserver(this, "profile-after-change", PR_FALSE); if (NS_FAILED(rv)) rv2 = rv; // install xpcom shutdown observer - rv = observerService->AddObserver(this, NS_LITERAL_STRING(NS_XPCOM_SHUTDOWN_OBSERVER_ID).get()); + rv = observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE); if (NS_FAILED(rv)) rv2 = rv; @@ -163,13 +164,13 @@ nsCacheProfilePrefObserver::Remove() if (NS_FAILED(rv)) return rv; NS_ENSURE_ARG(observerService); - rv = observerService->RemoveObserver(this, NS_LITERAL_STRING("profile-before-change").get()); + rv = observerService->RemoveObserver(this, "profile-before-change"); if (NS_FAILED(rv)) rv2 = rv; - rv = observerService->RemoveObserver(this, NS_LITERAL_STRING("profile-after-change").get()); + rv = observerService->RemoveObserver(this, "profile-after-change"); if (NS_FAILED(rv)) rv2 = rv; - rv = observerService->RemoveObserver(this, NS_LITERAL_STRING(NS_XPCOM_SHUTDOWN_OBSERVER_ID).get()); + rv = observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID); if (NS_FAILED(rv)) rv2 = rv; @@ -203,49 +204,48 @@ nsCacheProfilePrefObserver::Remove() NS_IMETHODIMP nsCacheProfilePrefObserver::Observe(nsISupports * subject, - const PRUnichar * topic, + const char * topic, const PRUnichar * data) { #ifdef DEBUG - printf("### nsCacheProfilePrefObserver::Observe [topic=%s data=%s]\n", - NS_ConvertUCS2toUTF8(topic).get(), - NS_ConvertUCS2toUTF8(data).get()); + printf("### nsCacheProfilePrefObserver::Observe [topic=%s data=%s]\n", topic, + NS_ConvertUCS2toUTF8(data).get()); #endif nsresult rv; - if (NS_LITERAL_STRING(NS_XPCOM_SHUTDOWN_OBSERVER_ID).Equals(topic)) { + if (nsCRT::strcmp(NS_XPCOM_SHUTDOWN_OBSERVER_ID, topic)) { // xpcom going away, shutdown cache service if (nsCacheService::GlobalInstance()) nsCacheService::GlobalInstance()->Shutdown(); - } else if (NS_LITERAL_STRING("profile-before-change").Equals(topic)) { + } else if (!nsCRT::strcmp("profile-before-change", topic)) { // profile before change mHaveProfile = PR_FALSE; // XXX shutdown devices - nsCacheService::OnProfileShutdown(NS_LITERAL_STRING("shutdown-cleanse").Equals(data)); + nsCacheService::OnProfileShutdown(!nsCRT::strcmp("shutdown-cleanse", NS_ConvertUCS2toUTF8(data).get())); - } else if (NS_LITERAL_STRING("profile-after-change").Equals(topic)) { + } else if (!nsCRT::strcmp("profile-after-change", topic)) { // profile after change mHaveProfile = PR_TRUE; ReadPrefs(); nsCacheService::OnProfileChanged(); - } else if (NS_LITERAL_STRING("nsPref:changed").Equals(topic)) { + } else if (!nsCRT::strcmp("nsPref:changed", topic)) { if (!mHaveProfile) return NS_OK; nsCOMPtr prefBranch = do_QueryInterface(subject, &rv); if (NS_FAILED(rv)) return rv; // which preference changed? - if (NS_LITERAL_STRING(DISK_CACHE_ENABLE_PREF).Equals(data)) { + if (!nsCRT::strcmp(DISK_CACHE_ENABLE_PREF, NS_ConvertUCS2toUTF8(data).get())) { rv = prefBranch->GetBoolPref(DISK_CACHE_ENABLE_PREF, &mDiskCacheEnabled); if (NS_FAILED(rv)) return rv; nsCacheService::SetDiskCacheEnabled(DiskCacheEnabled()); - } else if (NS_LITERAL_STRING(DISK_CACHE_CAPACITY_PREF).Equals(data)) { + } else if (!nsCRT::strcmp(DISK_CACHE_CAPACITY_PREF, NS_ConvertUCS2toUTF8(data).get())) { PRInt32 capacity = 0; rv = prefBranch->GetIntPref(DISK_CACHE_CAPACITY_PREF, &capacity); @@ -253,18 +253,18 @@ nsCacheProfilePrefObserver::Observe(nsISupports * subject, mDiskCacheCapacity = (PRUint32) PR_MAX(0, capacity); nsCacheService::SetDiskCacheCapacity(mDiskCacheCapacity); #if 0 - } else if (NS_LITERAL_STRING(DISK_CACHE_DIR_PREF).Equals(data)) { + } else if (!nsCRT::strcmp(DISK_CACHE_DIR_PREF, NS_ConvertUCS2toUTF8(data).get())) { // XXX we probaby don't want to respond to this pref except after profile changes // XXX ideally, there should be somekind of user notification that the pref change // XXX won't take effect until the next time the profile changes (browser launch) #endif - } else if (NS_LITERAL_STRING(MEMORY_CACHE_ENABLE_PREF).Equals(data)) { + } else if (!nsCRT::strcmp(MEMORY_CACHE_ENABLE_PREF, NS_ConvertUCS2toUTF8(data).get())) { rv = prefBranch->GetBoolPref(MEMORY_CACHE_ENABLE_PREF, &mMemoryCacheEnabled); if (NS_FAILED(rv)) return rv; nsCacheService::SetMemoryCacheEnabled(MemoryCacheEnabled()); - } else if (NS_LITERAL_STRING(MEMORY_CACHE_CAPACITY_PREF).Equals(data)) { + } else if (!nsCRT::strcmp(MEMORY_CACHE_CAPACITY_PREF, NS_ConvertUCS2toUTF8(data).get())) { PRInt32 capacity = 0; rv = prefBranch->GetIntPref(MEMORY_CACHE_CAPACITY_PREF, &capacity); diff --git a/mozilla/netwerk/dns/src/nsDnsService.cpp b/mozilla/netwerk/dns/src/nsDnsService.cpp index 1e172ced32b..04d833c4fa3 100644 --- a/mozilla/netwerk/dns/src/nsDnsService.cpp +++ b/mozilla/netwerk/dns/src/nsDnsService.cpp @@ -1193,28 +1193,29 @@ nsDNSService::RemovePrefObserver() NS_IMETHODIMP nsDNSService::Observe(nsISupports * subject, - const PRUnichar * topic, + const char * topic, const PRUnichar * data) { nsresult rv = NS_OK; - if (!NS_LITERAL_STRING("nsPref:changed").Equals(topic)) return NS_OK; + if (nsCRT::strcmp("nsPref:changed", topic)) + return NS_OK; nsCOMPtr prefs = do_QueryInterface(subject, &rv); if (NS_FAILED(rv)) return rv; // which preference changed? - if (NS_LITERAL_STRING(NETWORK_DNS_CACHE_ENTRIES).Equals(data)) { + if (!nsCRT::strcmp(NETWORK_DNS_CACHE_ENTRIES, NS_ConvertUCS2toUTF8(data).get())) { rv = prefs->GetIntPref(NETWORK_DNS_CACHE_ENTRIES, &mMaxCachedLookups); if (mMaxCachedLookups < 0) mMaxCachedLookups = 0; - } else if (NS_LITERAL_STRING(NETWORK_DNS_CACHE_EXPIRATION).Equals(data)) { + } else if (!nsCRT::strcmp(NETWORK_DNS_CACHE_EXPIRATION, NS_ConvertUCS2toUTF8(data).get())) { rv = prefs->GetIntPref(NETWORK_DNS_CACHE_EXPIRATION, &mExpirationInterval); if (mExpirationInterval < 0) mExpirationInterval = 0; } - else if (NS_LITERAL_STRING(NETWORK_ENABLEIDN).Equals(data)) { + else if (!nsCRT::strcmp(NETWORK_ENABLEIDN, NS_ConvertUCS2toUTF8(data).get())) { PRBool enableIDN = PR_FALSE; rv = prefs->GetBoolPref(NETWORK_ENABLEIDN, &enableIDN); diff --git a/mozilla/netwerk/protocol/http/public/nsIHttpProtocolHandler.idl b/mozilla/netwerk/protocol/http/public/nsIHttpProtocolHandler.idl index f6d8551c1dc..d0e061623cd 100644 --- a/mozilla/netwerk/protocol/http/public/nsIHttpProtocolHandler.idl +++ b/mozilla/netwerk/protocol/http/public/nsIHttpProtocolHandler.idl @@ -110,5 +110,5 @@ interface nsIHttpProtocolHandler : nsIProxiedProtocolHandler #define NS_HTTP_STARTUP_CATEGORY "http-startup-category" // If the resulting service implements nsIObserver, then its Observer // method will be invoked with the following topic. -#define NS_HTTP_STARTUP_TOPIC (NS_LITERAL_STRING("http-startup").get()) +#define NS_HTTP_STARTUP_TOPIC "http-startup" %} diff --git a/mozilla/netwerk/protocol/http/src/nsHttpHandler.cpp b/mozilla/netwerk/protocol/http/src/nsHttpHandler.cpp index f255924e099..826d5316811 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpHandler.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHttpHandler.cpp @@ -40,6 +40,7 @@ #include "nsICacheService.h" #include "nsICategoryManager.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsISupportsPrimitives.h" #include "nsINetModRegEntry.h" #include "nsICacheService.h" @@ -244,14 +245,14 @@ nsHttpHandler::Init() // Bring alive the objects in the http-protocol-startup category NS_CreateServicesFromCategory(NS_HTTP_STARTUP_CATEGORY, NS_STATIC_CAST(nsISupports*,NS_STATIC_CAST(void*,this)), - NS_HTTP_STARTUP_TOPIC); + NS_HTTP_STARTUP_TOPIC); nsCOMPtr observerSvc = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (observerSvc) { - observerSvc->AddObserver(this, NS_LITERAL_STRING("profile-before-change").get()); - observerSvc->AddObserver(this, NS_LITERAL_STRING("session-logout").get()); - observerSvc->AddObserver(this, NS_LITERAL_STRING(NS_XPCOM_SHUTDOWN_OBSERVER_ID).get()); + observerSvc->AddObserver(this, "profile-before-change", PR_TRUE); + observerSvc->AddObserver(this, "session-logout", PR_TRUE); + observerSvc->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE); } return NS_OK; } @@ -1807,16 +1808,16 @@ nsHttpHandler::SetMisc(const char *aMisc) NS_IMETHODIMP nsHttpHandler::Observe(nsISupports *subject, - const PRUnichar *topic, + const char *topic, const PRUnichar *data) { - if (!nsCRT::strcmp(topic, NS_LITERAL_STRING("nsPref:changed").get())) { + if (!nsCRT::strcmp(topic, "nsPref:changed")) { nsCOMPtr prefBranch = do_QueryInterface(subject); if (prefBranch) PrefsChanged(prefBranch, NS_ConvertUCS2toUTF8(data).get()); } - else if (!nsCRT::strcmp(topic, NS_LITERAL_STRING("profile-before-change").get()) || - !nsCRT::strcmp(topic, NS_LITERAL_STRING("session-logout").get())) { + else if (!nsCRT::strcmp(topic, "profile-before-change") || + !nsCRT::strcmp(topic, "session-logout")) { // clear cache of all authentication credentials. if (mAuthCache) mAuthCache->ClearAll(); @@ -1825,7 +1826,7 @@ nsHttpHandler::Observe(nsISupports *subject, // depend on this value. mSessionStartTime = NowInSeconds(); } - else if (!nsCRT::strcmp(topic, NS_LITERAL_STRING(NS_XPCOM_SHUTDOWN_OBSERVER_ID).get())) { + else if (!nsCRT::strcmp(topic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) { nsCOMPtr prefBranch; GetPrefBranch(getter_AddRefs(prefBranch)); if (prefBranch) { diff --git a/mozilla/profile/src/nsProfile.cpp b/mozilla/profile/src/nsProfile.cpp index 03fc850a48b..36b113555cf 100644 --- a/mozilla/profile/src/nsProfile.cpp +++ b/mozilla/profile/src/nsProfile.cpp @@ -79,6 +79,7 @@ #include "nsIChromeRegistry.h" // chromeReg #include "nsIStringBundle.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsISupportsPrimitives.h" #include "nsHashtable.h" @@ -1117,15 +1118,15 @@ nsProfile::SetCurrentProfile(const PRUnichar * aCurrentProfile) { // Phase 1: See if anybody objects to the profile being changed. mProfileChangeVetoed = PR_FALSE; - observerService->Notify(subject, NS_LITERAL_STRING("profile-approve-change").get(), context.get()); + observerService->NotifyObservers(subject, "profile-approve-change", context.get()); if (mProfileChangeVetoed) return NS_OK; // Phase 2: Send the "teardown" notification - observerService->Notify(subject, NS_LITERAL_STRING("profile-change-teardown").get(), context.get()); + observerService->NotifyObservers(subject, "profile-change-teardown", context.get()); // Phase 3: Notify observers of a profile change - observerService->Notify(subject, NS_LITERAL_STRING("profile-before-change").get(), context.get()); + observerService->NotifyObservers(subject, "profile-before-change", context.get()); } // Flush the stringbundle cache @@ -1151,10 +1152,10 @@ nsProfile::SetCurrentProfile(const PRUnichar * aCurrentProfile) } // Phase 4: Notify observers that the profile has changed - Here they respond to new profile - observerService->Notify(subject, NS_LITERAL_STRING("profile-do-change").get(), context.get()); + observerService->NotifyObservers(subject, "profile-do-change", context.get()); // Phase 5: Now observers can respond to something another observer did in phase 4 - observerService->Notify(subject, NS_LITERAL_STRING("profile-after-change").get(), context.get()); + observerService->NotifyObservers(subject, "profile-after-change", context.get()); // Now that a profile is established, set the profile defaults dir for the locale of this profile rv = DefineLocaleDefaultsDir(); @@ -1197,15 +1198,15 @@ NS_IMETHODIMP nsProfile::ShutDownCurrentProfile(PRUint32 shutDownType) // Phase 1: See if anybody objects to the profile being changed. mProfileChangeVetoed = PR_FALSE; - observerService->Notify(subject, NS_LITERAL_STRING("profile-approve-change").get(), context.get()); + observerService->NotifyObservers(subject, "profile-approve-change", context.get()); if (mProfileChangeVetoed) return NS_OK; // Phase 2: Send the "teardown" notification - observerService->Notify(subject, NS_LITERAL_STRING("profile-change-teardown").get(), context.get()); + observerService->NotifyObservers(subject, "profile-change-teardown", context.get()); // Phase 3: Notify observers of a profile change - observerService->Notify(subject, NS_LITERAL_STRING("profile-before-change").get(), context.get()); + observerService->NotifyObservers(subject, "profile-before-change", context.get()); rv = UndefineFileLocations(); NS_ASSERTION(NS_SUCCEEDED(rv), "Could not undefine file locations"); diff --git a/mozilla/rdf/chrome/src/nsChromeRegistry.cpp b/mozilla/rdf/chrome/src/nsChromeRegistry.cpp index f5447b4a9ed..4fd267e1568 100644 --- a/mozilla/rdf/chrome/src/nsChromeRegistry.cpp +++ b/mozilla/rdf/chrome/src/nsChromeRegistry.cpp @@ -102,6 +102,7 @@ #include "nsAppDirectoryServiceDefs.h" #include "nsIPref.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIDOMElement.h" #include "nsIChromeEventHandler.h" #include "nsIContent.h" @@ -355,8 +356,8 @@ nsChromeRegistry::Init() nsCOMPtr observerService = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (observerService) { - observerService->AddObserver(this, NS_LITERAL_STRING("profile-before-change").get()); - observerService->AddObserver(this, NS_LITERAL_STRING("profile-do-change").get()); + observerService->AddObserver(this, "profile-before-change", PR_TRUE); + observerService->AddObserver(this, "profile-do-change", PR_TRUE); } CheckForNewChrome(); @@ -3235,25 +3236,25 @@ nsChromeRegistry::GetProviderCount(const nsCString& aProviderType, nsIRDFDataSou } -NS_IMETHODIMP nsChromeRegistry::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +NS_IMETHODIMP nsChromeRegistry::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { nsresult rv = NS_OK; - if (!nsCRT::strcmp(NS_LITERAL_STRING("profile-before-change").get(), aTopic)) { + if (!nsCRT::strcmp("profile-before-change", aTopic)) { mChromeDataSource = nsnull; mScrollbarSheet = mFormSheet = nsnull; mInstallInitialized = mProfileInitialized = PR_FALSE; (void)FlushCaches(); - if (!nsCRT::strcmp(NS_LITERAL_STRING("shutdown-cleanse").get(), someData)) { + if (!nsCRT::strcmp("shutdown-cleanse", NS_ConvertUCS2toUTF8(someData).get())) { nsCOMPtr userChromeDir; rv = NS_GetSpecialDirectory(NS_APP_USER_CHROME_DIR, getter_AddRefs(userChromeDir)); if (NS_SUCCEEDED(rv) && userChromeDir) rv = userChromeDir->Remove(PR_TRUE); } } - else if (!nsCRT::strcmp(NS_LITERAL_STRING("profile-do-change").get(), aTopic)) { + else if (!nsCRT::strcmp("profile-do-change", aTopic)) { if (!mProfileInitialized) rv = LoadProfileDataSource(); } diff --git a/mozilla/rdf/datasource/src/nsLocalStore.cpp b/mozilla/rdf/datasource/src/nsLocalStore.cpp index 9b0d7bf6e7b..cd29835c9f6 100644 --- a/mozilla/rdf/datasource/src/nsLocalStore.cpp +++ b/mozilla/rdf/datasource/src/nsLocalStore.cpp @@ -57,7 +57,9 @@ #include "nsCOMPtr.h" #include "nsWeakPtr.h" #include "nsAppDirectoryServiceDefs.h" +#include "nsIObserver.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsWeakReference.h" //////////////////////////////////////////////////////////////////////// @@ -379,8 +381,8 @@ LocalStoreImpl::Init() do_GetService(NS_OBSERVERSERVICE_CONTRACTID); if (obs) { - obs->AddObserver(this, NS_LITERAL_STRING("profile-before-change").get()); - obs->AddObserver(this, NS_LITERAL_STRING("profile-do-change").get()); + obs->AddObserver(this, "profile-before-change", PR_TRUE); + obs->AddObserver(this, "profile-do-change", PR_TRUE); } return NS_OK; @@ -492,11 +494,11 @@ LocalStoreImpl::DoCommand(nsISupportsArray* aSources, } NS_IMETHODIMP -LocalStoreImpl::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +LocalStoreImpl::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { nsresult rv = NS_OK; - if (!nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-before-change").get())) { + if (!nsCRT::strcmp(aTopic, "profile-before-change")) { // Write out the old datasource's contents. if (mInner) { nsCOMPtr remote = do_QueryInterface(mInner); @@ -508,14 +510,14 @@ LocalStoreImpl::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PR // profile-less. mInner = do_CreateInstance(NS_RDF_DATASOURCE_CONTRACTID_PREFIX "in-memory-datasource"); - if (!nsCRT::strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get())) { + if (!nsCRT::strcmp(NS_ConvertUCS2toUTF8(someData).get(), "shutdown-cleanse")) { nsCOMPtr aFile; rv = NS_GetSpecialDirectory(NS_APP_LOCALSTORE_50_FILE, getter_AddRefs(aFile)); if (NS_SUCCEEDED(rv)) rv = aFile->Remove(PR_FALSE); } } - else if (!nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-do-change").get())) { + else if (!nsCRT::strcmp(aTopic, "profile-do-change")) { rv = LoadData(); } return rv; diff --git a/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp b/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp index 42058b1aec3..8698b84026c 100644 --- a/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -62,6 +62,7 @@ #include "nsIHttpChannel.h" #include "nsIAtom.h" #include "nsIObserverService.h" // so we can be an xpcom shutdown observer +#include "nsObserverService.h" #ifdef XP_MAC #include "nsILocalFileMac.h" @@ -150,7 +151,7 @@ nsExternalHelperAppService::nsExternalHelperAppService() : mDataSourceInitialize nsresult rv = NS_OK; nsCOMPtr obs = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (obs) - rv = obs->AddObserver(NS_STATIC_CAST(nsIObserver*, this), NS_LITERAL_STRING(NS_XPCOM_SHUTDOWN_OBSERVER_ID).get()); + rv = obs->AddObserver(NS_STATIC_CAST(nsIObserver*, this), NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE); } @@ -580,7 +581,7 @@ nsresult nsExternalHelperAppService::ExpungeTemporaryFiles() /* XPCOM Shutdown observer */ NS_IMETHODIMP -nsExternalHelperAppService::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData ) +nsExternalHelperAppService::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData ) { // we must be shutting down xpcom so remove our temporary files... ExpungeTemporaryFiles(); @@ -588,7 +589,7 @@ nsExternalHelperAppService::Observe(nsISupports *aSubject, const PRUnichar *aTop nsCOMPtr obs = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (obs) - rv = obs->RemoveObserver(NS_STATIC_CAST(nsIObserver*, this), NS_LITERAL_STRING(NS_XPCOM_SHUTDOWN_OBSERVER_ID).get()); + rv = obs->RemoveObserver(NS_STATIC_CAST(nsIObserver*, this), NS_XPCOM_SHUTDOWN_OBSERVER_ID); return NS_OK; } diff --git a/mozilla/xpcom/base/nsExceptionService.cpp b/mozilla/xpcom/base/nsExceptionService.cpp index 9ce47a3b358..e693a9960d5 100644 --- a/mozilla/xpcom/base/nsExceptionService.cpp +++ b/mozilla/xpcom/base/nsExceptionService.cpp @@ -42,7 +42,7 @@ #include "nsCOMPtr.h" #include "prthread.h" #include "prlock.h" - +#include "nsObserverService.h" static const PRUintn BAD_TLS_INDEX = (PRUintn) -1; #define CHECK_SERVICE_USE_OK() if (!lock) return NS_ERROR_NOT_INITIALIZED @@ -182,7 +182,7 @@ nsExceptionService::nsExceptionService() nsCOMPtr observerService = do_GetService(NS_OBSERVERSERVICE_CONTRACTID); NS_WARN_IF_FALSE(observerService, "Could not get observer service!"); if (observerService) - observerService->AddObserver(this, NS_LITERAL_STRING(NS_XPCOM_SHUTDOWN_OBSERVER_ID).get()); + observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE); } nsExceptionService::~nsExceptionService() @@ -291,7 +291,7 @@ NS_IMETHODIMP nsExceptionService::UnregisterExceptionProvider(nsIExceptionProvid } // nsIObserver -NS_IMETHODIMP nsExceptionService::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +NS_IMETHODIMP nsExceptionService::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { Shutdown(); return NS_OK; diff --git a/mozilla/xpcom/base/nsExceptionService.h b/mozilla/xpcom/base/nsExceptionService.h index 1c4e870fd8b..1a752695ab7 100644 --- a/mozilla/xpcom/base/nsExceptionService.h +++ b/mozilla/xpcom/base/nsExceptionService.h @@ -44,6 +44,7 @@ #include "nsIExceptionService.h" #include "nsIObserverService.h" #include "nsHashtable.h" +#include "nsIObserver.h" class nsExceptionManager; diff --git a/mozilla/xpcom/base/nsIMemory.idl b/mozilla/xpcom/base/nsIMemory.idl index 3d6bac70609..b4db044283b 100644 --- a/mozilla/xpcom/base/nsIMemory.idl +++ b/mozilla/xpcom/base/nsIMemory.idl @@ -122,26 +122,26 @@ interface nsIMemory : nsISupports * This is the topic that a memory pressure observer * should use with the observer service. */ -#define NS_MEMORY_PRESSURE_TOPIC (NS_LITERAL_STRING("memory-pressure").get()) +#define NS_MEMORY_PRESSURE_TOPIC "memory-pressure" /** * This will be passed as the extra data when the flusher * is being asked to flush for low-memory conditions. */ -#define NS_MEMORY_PRESSURE_LOW_MEMORY (NS_LITERAL_STRING("low-memory").get()) +#define NS_MEMORY_PRESSURE_LOW_MEMORY "low-memory" /** * This will be passed as the extra data when the flusher * is being asked to flush because of a heap minimize call. */ -#define NS_MEMORY_PRESSURE_HEAP_MINIMIZE (NS_LITERAL_STRING("heap-minimize").get()) +#define NS_MEMORY_PRESSURE_HEAP_MINIMIZE "heap-minimize" /** * This will be passed as the extra data when the flusher * has been asked to flush because a malloc() or realloc() * has failed. */ -#define NS_MEMORY_PRESSURE_ALLOC_FAILURE (NS_LITERAL_STRING("alloc-failure").get()) +#define NS_MEMORY_PRESSURE_ALLOC_FAILURE "alloc-failure" %} %{C++ diff --git a/mozilla/xpcom/base/nsMemoryImpl.cpp b/mozilla/xpcom/base/nsMemoryImpl.cpp index 3b8d89b6af4..7e3a71ed656 100644 --- a/mozilla/xpcom/base/nsMemoryImpl.cpp +++ b/mozilla/xpcom/base/nsMemoryImpl.cpp @@ -40,6 +40,7 @@ #include "nsAlgorithm.h" #include "nsIServiceManager.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsAutoLock.h" #include "nsIThread.h" #include "nsIEventQueueService.h" @@ -189,7 +190,7 @@ MemoryFlusher::Run() #endif if (isLowMemory) { - mMemoryImpl->FlushMemory(NS_MEMORY_PRESSURE_LOW_MEMORY, PR_FALSE); + mMemoryImpl->FlushMemory(NS_LITERAL_STRING(NS_MEMORY_PRESSURE_LOW_MEMORY).get(), PR_FALSE); } } @@ -320,7 +321,7 @@ nsMemoryImpl::Alloc(PRSize size) void* result = MALLOC1(size); if (! result) { // Request an asynchronous flush - FlushMemory(NS_MEMORY_PRESSURE_ALLOC_FAILURE, PR_FALSE); + FlushMemory(NS_LITERAL_STRING(NS_MEMORY_PRESSURE_ALLOC_FAILURE).get(), PR_FALSE); } return result; } @@ -331,7 +332,7 @@ nsMemoryImpl::Realloc(void * ptr, PRSize size) void* result = REALLOC1(ptr, size); if (! result) { // Request an asynchronous flush - FlushMemory(NS_MEMORY_PRESSURE_ALLOC_FAILURE, PR_FALSE); + FlushMemory(NS_LITERAL_STRING(NS_MEMORY_PRESSURE_ALLOC_FAILURE).get(), PR_FALSE); } return result; } @@ -345,7 +346,7 @@ nsMemoryImpl::Free(void * ptr) NS_IMETHODIMP nsMemoryImpl::HeapMinimize(PRBool aImmediate) { - return FlushMemory(NS_MEMORY_PRESSURE_HEAP_MINIMIZE, aImmediate); + return FlushMemory(NS_LITERAL_STRING(NS_MEMORY_PRESSURE_HEAP_MINIMIZE).get(), aImmediate); } NS_IMETHODIMP @@ -457,7 +458,7 @@ nsMemoryImpl::RunFlushers(nsMemoryImpl* aSelf, const PRUnichar* aReason) { nsCOMPtr os = do_GetService(NS_OBSERVERSERVICE_CONTRACTID); if (os) { - os->Notify(aSelf, NS_MEMORY_PRESSURE_TOPIC, aReason); + os->NotifyObservers(aSelf, NS_MEMORY_PRESSURE_TOPIC, aReason); } { diff --git a/mozilla/xpcom/build/nsXPComInit.cpp b/mozilla/xpcom/build/nsXPComInit.cpp index d4155e572e4..5d66d3600b8 100644 --- a/mozilla/xpcom/build/nsXPComInit.cpp +++ b/mozilla/xpcom/build/nsXPComInit.cpp @@ -462,9 +462,9 @@ nsresult NS_COM NS_ShutdownXPCOM(nsIServiceManager* servMgr) rv = NS_GetServiceManager(getter_AddRefs(mgr)); if (NS_SUCCEEDED(rv)) { - nsAutoString topic; - topic.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID); - (void) observerService->Notify(mgr, topic.get(), nsnull); + (void) observerService->NotifyObservers(mgr, + NS_XPCOM_SHUTDOWN_OBSERVER_ID, + nsnull); } } } diff --git a/mozilla/xpcom/components/nsCategoryManager.cpp b/mozilla/xpcom/components/nsCategoryManager.cpp index 4d717228733..c668c0c14ce 100644 --- a/mozilla/xpcom/components/nsCategoryManager.cpp +++ b/mozilla/xpcom/components/nsCategoryManager.cpp @@ -600,7 +600,7 @@ NS_CategoryManagerGetFactory( nsIFactory** aFactory ) nsresult NS_CreateServicesFromCategory(const char *category, nsISupports *origin, - const PRUnichar *observerTopic) + const char *observerTopic) { nsresult rv = NS_OK; diff --git a/mozilla/xpcom/components/nsComponentManager.cpp b/mozilla/xpcom/components/nsComponentManager.cpp index 0a5a8919dd2..eb607a3bd63 100644 --- a/mozilla/xpcom/components/nsComponentManager.cpp +++ b/mozilla/xpcom/components/nsComponentManager.cpp @@ -52,6 +52,7 @@ #include "nsXPIDLString.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsLocalFile.h" #include "nsDirectoryService.h" @@ -2603,9 +2604,9 @@ nsComponentManagerImpl::AutoRegisterImpl(PRInt32 when, nsIFile *inDirSpec) { // NO COMPtr as we dont release the service manager nsIServiceManager *mgr = NS_STATIC_CAST(nsIServiceManager*, this); - (void) observerService->Notify(mgr, - NS_ConvertASCIItoUCS2(NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID).get(), - NS_ConvertASCIItoUCS2("Starting component registration").get()); + (void) observerService->NotifyObservers(mgr, + NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID, + NS_ConvertASCIItoUCS2("Starting component registration").get()); } /* do the native loader first, so we can find other loaders */ @@ -2676,9 +2677,9 @@ nsComponentManagerImpl::AutoRegisterImpl(PRInt32 when, nsIFile *inDirSpec) // NO COMPtr as we dont release the service manager nsIServiceManager *mgr = NS_STATIC_CAST(nsIServiceManager*, this); - (void) observerService->Notify(mgr, - NS_ConvertASCIItoUCS2(NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID).get(), - NS_ConvertASCIItoUCS2("Component registration finished").get()); + (void) observerService->NotifyObservers(mgr, + NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID, + NS_ConvertASCIItoUCS2("Component registration finished").get()); return rv; } @@ -2827,7 +2828,6 @@ nsComponentManagerImpl::EnumerateContractIDs(nsIEnumerator** aEmumerator) nsresult nsComponentManagerImpl::GetInterface(const nsIID & uuid, void **result) { - nsresult rv = NS_OK; if (uuid.Equals(NS_GET_IID(nsIServiceManager))) { *result = NS_STATIC_CAST(nsIServiceManager*, this); diff --git a/mozilla/xpcom/components/nsICategoryManager.idl b/mozilla/xpcom/components/nsICategoryManager.idl index 707e7cf4eee..f36830c5366 100644 --- a/mozilla/xpcom/components/nsICategoryManager.idl +++ b/mozilla/xpcom/components/nsICategoryManager.idl @@ -122,5 +122,5 @@ extern "C" NS_EXPORT nsresult NS_CategoryManagerGetFactory( nsIFactory** ); NS_COM nsresult NS_CreateServicesFromCategory(const char *category, nsISupports *origin, - const PRUnichar *observerTopic); + const char *observerTopic); %} diff --git a/mozilla/xpcom/components/nsNativeComponentLoader.cpp b/mozilla/xpcom/components/nsNativeComponentLoader.cpp index ebd859ceae0..95dbae7370a 100644 --- a/mozilla/xpcom/components/nsNativeComponentLoader.cpp +++ b/mozilla/xpcom/components/nsNativeComponentLoader.cpp @@ -43,6 +43,8 @@ #include "nsCRT.h" #include "nsIObserverService.h" +#include "nsObserverService.h" + #include "nsITimelineService.h" #ifdef XP_MAC // sdagley dougt fix @@ -687,9 +689,9 @@ nsNativeComponentLoader::AutoUnregisterComponent(PRInt32 when, rv = NS_GetServiceManager(getter_AddRefs(mgr)); if (NS_SUCCEEDED(rv)) { - (void) observerService->Notify(mgr, - NS_ConvertASCIItoUCS2(NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID).get(), - NS_ConvertASCIItoUCS2("Unregistering native component").get()); + (void) observerService->NotifyObservers(mgr, + NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID, + NS_ConvertASCIItoUCS2("Unregistering native component").get()); } } @@ -859,9 +861,9 @@ nsNativeComponentLoader::AutoRegisterComponent(PRInt32 when, } statusMsg.Append(fileName); - (void) observerService->Notify(mgr, - NS_ConvertASCIItoUCS2(NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID).get(), - statusMsg.get()); + (void) observerService->NotifyObservers(mgr, + NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID, + statusMsg.get()); } } diff --git a/mozilla/xpcom/ds/MANIFEST b/mozilla/xpcom/ds/MANIFEST index 24b97ea9992..021b354be68 100644 --- a/mozilla/xpcom/ds/MANIFEST +++ b/mozilla/xpcom/ds/MANIFEST @@ -9,11 +9,11 @@ nsHashtable.h nsHashtableEnumerator.h nsIArena.h nsIByteBuffer.h -nsIObserverList.h nsISimpleEnumerator.h nsISizeOfHandler.h nsIUnicharBuffer.h nsInt64.h +nsIObserverService.h nsQuickSort.h nsStaticNameTable.h nsStatistics.h diff --git a/mozilla/xpcom/ds/Makefile.in b/mozilla/xpcom/ds/Makefile.in index 00eb26785ef..eaa2e480a59 100644 --- a/mozilla/xpcom/ds/Makefile.in +++ b/mozilla/xpcom/ds/Makefile.in @@ -83,11 +83,11 @@ EXPORTS = \ nsHashtableEnumerator.h \ nsIArena.h \ nsIByteBuffer.h \ - nsIObserverList.h \ nsISimpleEnumerator.h \ nsISizeOfHandler.h \ nsIUnicharBuffer.h \ nsInt64.h \ + nsObserverService.h \ nsQuickSort.h \ nsStaticNameTable.h \ nsStatistics.h \ diff --git a/mozilla/xpcom/ds/makefile.win b/mozilla/xpcom/ds/makefile.win index 302683fc3a9..f360a803d87 100644 --- a/mozilla/xpcom/ds/makefile.win +++ b/mozilla/xpcom/ds/makefile.win @@ -41,11 +41,11 @@ EXPORTS = \ nsHashtableEnumerator.h \ nsIArena.h \ nsIByteBuffer.h \ - nsIObserverList.h \ nsISimpleEnumerator.h \ nsISizeOfHandler.h \ nsIUnicharBuffer.h \ nsInt64.h \ + nsObserverService.h \ nsQuickSort.h \ nsStaticNameTable.h \ nsStatistics.h \ diff --git a/mozilla/xpcom/ds/nsEnumeratorUtils.cpp b/mozilla/xpcom/ds/nsEnumeratorUtils.cpp index fa69ea8ce6d..f03bf30dfc8 100644 --- a/mozilla/xpcom/ds/nsEnumeratorUtils.cpp +++ b/mozilla/xpcom/ds/nsEnumeratorUtils.cpp @@ -60,6 +60,11 @@ nsArrayEnumerator::HasMoreElements(PRBool* aResult) if (! aResult) return NS_ERROR_NULL_POINTER; + if (!mValueArray) { + *aResult = PR_FALSE; + return NS_OK; + } + PRUint32 cnt; nsresult rv = mValueArray->Count(&cnt); if (NS_FAILED(rv)) return rv; @@ -74,6 +79,11 @@ nsArrayEnumerator::GetNext(nsISupports** aResult) if (! aResult) return NS_ERROR_NULL_POINTER; + if (!mValueArray) { + *aResult = nsnull; + return NS_OK; + } + PRUint32 cnt; nsresult rv = mValueArray->Count(&cnt); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/xpcom/ds/nsIEnumerator.idl b/mozilla/xpcom/ds/nsIEnumerator.idl index 3d21adfeb6e..2b73b4071ae 100644 --- a/mozilla/xpcom/ds/nsIEnumerator.idl +++ b/mozilla/xpcom/ds/nsIEnumerator.idl @@ -94,7 +94,6 @@ interface nsISimpleEnumerator : nsISupports { */ [scriptable, uuid(ad385286-cbc4-11d2-8cca-0060b0fc14a3)] interface nsIEnumerator : nsISupports { - /** First will reset the list. will return NS_FAILED if no items */ void first(); diff --git a/mozilla/xpcom/ds/nsIObserver.idl b/mozilla/xpcom/ds/nsIObserver.idl index 8a52184a714..5f67a64b6aa 100644 --- a/mozilla/xpcom/ds/nsIObserver.idl +++ b/mozilla/xpcom/ds/nsIObserver.idl @@ -38,33 +38,32 @@ #include "nsISupports.idl" /** - * This interface is implemented by an object that needs - * to observe an event corresponding to a change in a - * topic for a subject. + * This interface is implemented by an object that wants + * to observe an event corresponding to a topic. + * + * @status FROZEN */ [scriptable, uuid(DB242E01-E4D9-11d2-9DDE-000064657374)] interface nsIObserver : nsISupports { /** - * Called if the topic changes for the subject. If you expect - * multiple topics/subjects, the impl is responsible for filtering. + * Observe will be called when there is a notification for the + * topic |aTopic|. This assumes that the object implementing + * this interface has been registered with an observer service + * such as the nsIObserverService. * - * @param aSubject - the event specific data that has changed. - * @param aTopic - indicates the event that has changed. - * @param aData - out of band data specific to the topic/ - * subject event. + * If you expect multiple topics/subjects, the impl is + * responsible for filtering. + * + * @param aSubject : Notification specific interface pointer. + * @param aTopic : The notification topic or subject. + * @param aData : Notification specific wide string. + * subject event. */ - void Observe( in nsISupports aSubject, - in wstring aTopic, + void observe( in nsISupports aSubject, + in string aTopic, in wstring aData ); }; -%{C++ - -#define NS_OBSERVER_CONTRACTID "@mozilla.org/xpcom/observer;1" - -#define NS_OBSERVER_CLASSNAME "Observer" - -%} diff --git a/mozilla/xpcom/ds/nsIObserverList.h b/mozilla/xpcom/ds/nsIObserverList.h deleted file mode 100644 index eb32e8fa6c5..00000000000 --- a/mozilla/xpcom/ds/nsIObserverList.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsIObserverList_h__ -#define nsIObserverList_h__ - -#include "nsISupports.h" -#include "nsIObserver.h" -#include "nsIEnumerator.h" -#include "nscore.h" - - -// {E777D482-E6E3-11d2-8ACD-00105A1B8860} -#define NS_IOBSERVERLIST_IID \ -{ 0xe777d482, 0xe6e3, 0x11d2, { 0x8a, 0xcd, 0x0, 0x10, 0x5a, 0x1b, 0x88, 0x60 } } - -class nsIObserverList : public nsISupports { -public: - static const nsIID& GetIID() { static nsIID iid = NS_IOBSERVERLIST_IID; return iid; } - - NS_IMETHOD AddObserver(nsIObserver* anObserver) = 0; - NS_IMETHOD RemoveObserver(nsIObserver* anObserver) = 0; - NS_IMETHOD EnumerateObserverList(nsIEnumerator** anEnumerator) = 0; - -}; - -extern NS_COM nsresult NS_NewObserverList(nsIObserverList** anObserverList); - -#define NS_OBSERVERLIST_CONTRACTID "@mozilla.org/xpcom/observer-list;1" -#define NS_OBSERVERLIST_CLASSNAME "Observer List" - -#endif /* nsIObserverList_h__ */ diff --git a/mozilla/xpcom/ds/nsIObserverService.idl b/mozilla/xpcom/ds/nsIObserverService.idl index 8ba9f9b0eee..9f9408f053b 100644 --- a/mozilla/xpcom/ds/nsIObserverService.idl +++ b/mozilla/xpcom/ds/nsIObserverService.idl @@ -36,25 +36,76 @@ * ***** END LICENSE BLOCK ***** */ #include "nsISupports.idl" -#include "nsIObserver.idl" -#include "nsIEnumerator.idl" + +interface nsIObserver; +interface nsISimpleEnumerator; + +/** + * nsIObserverService + * + * Service allows a client listener (nsIObserver) to register and unregister for + * notifications of specific string referenced topic. Service also provides a + * way to notify registered listeners and a way to enumerate registered client + * listeners. + * + * @status FROZEN + */ [scriptable, uuid(D07F5192-E3D1-11d2-8ACD-00105A1B8860)] -interface nsIObserverService : nsISupports { +interface nsIObserverService : nsISupports +{ + + /** + * AddObserver + * + * Registers a given listener for a notifications regarding the specified + * topic. + * + * @param anObserve : The interface pointer which will receive notifications. + * @param aTopic : The notification topic or subject. + * @param ownsWeak : If set to false, the nsIObserverService will hold a + * strong reference to |anObserver|. If set to false and + * |anObserver| supports the nsIWeakReference interface, + * a weak reference will be held. Otherwise an error will be + * returned. + */ + void addObserver( in nsIObserver anObserver, in string aTopic, in boolean ownsWeak); + + /** + * removeObserver + * + * Unregisters a given listener from notifications regarding the specified + * topic. + * + * @param anObserver : The interface pointer which will stop recieving + * notifications. + * @param aTopic : The notification topic or subject. + */ + void removeObserver( in nsIObserver anObserver, in string aTopic ); + + /** + * notifyObservers + * + * Notifies all registered listeners of the given topic. + * + * @param aSubject : Notification specific interface pointer. + * @param aTopic : The notification topic or subject. + * @param someData : Notification specific wide string. + */ + void notifyObservers( in nsISupports aSubject, + in string aTopic, + in wstring someData ); + + /** + * enumerateObservers + * + * Returns an enumeration of all registered listeners. + * + * @param aTopic : The notification topic or subject. + */ + nsISimpleEnumerator enumerateObservers( in string aTopic ); - void AddObserver( in nsIObserver anObserver, in wstring aTopic ); - void RemoveObserver( in nsIObserver anObserver, in wstring nsString ); - nsIEnumerator EnumerateObserverList( in wstring aTopic ); - void Notify( in nsISupports aSubject, - in wstring aTopic, - in wstring someData ); }; -%{C++ -#define NS_OBSERVERSERVICE_CONTRACTID "@mozilla.org/observer-service;1" - -#define NS_OBSERVERSERVICE_CLASSNAME "Observer Service" - -%} diff --git a/mozilla/xpcom/ds/nsObserver.cpp b/mozilla/xpcom/ds/nsObserver.cpp index e1a20a9f6f7..9360d177262 100644 --- a/mozilla/xpcom/ds/nsObserver.cpp +++ b/mozilla/xpcom/ds/nsObserver.cpp @@ -103,7 +103,7 @@ nsObserver::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr) } NS_IMETHODIMP -nsObserver::Observe( nsISupports *, const PRUnichar *, const PRUnichar * ) { +nsObserver::Observe( nsISupports *, const char *, const PRUnichar * ) { nsresult rv = NS_OK; return rv; } diff --git a/mozilla/xpcom/ds/nsObserver.h b/mozilla/xpcom/ds/nsObserver.h index 5e197d13d52..28227dd6f40 100644 --- a/mozilla/xpcom/ds/nsObserver.h +++ b/mozilla/xpcom/ds/nsObserver.h @@ -45,6 +45,10 @@ #define NS_OBSERVER_CID \ { 0xdb242e03, 0xe4d9, 0x11d2, { 0x9d, 0xde, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } } + +#define NS_OBSERVER_CONTRACTID "@mozilla.org/xpcom/observer;1" +#define NS_OBSERVER_CLASSNAME "Observer" + class nsObserver : public nsIObserver { public: diff --git a/mozilla/xpcom/ds/nsObserverList.cpp b/mozilla/xpcom/ds/nsObserverList.cpp index c7f2530ab09..2bbab651167 100644 --- a/mozilla/xpcom/ds/nsObserverList.cpp +++ b/mozilla/xpcom/ds/nsObserverList.cpp @@ -39,158 +39,15 @@ #define NS_IMPL_IDS #include "pratom.h" -#include "nsIObserverList.h" #include "nsString.h" #include "nsAutoLock.h" #include "nsCOMPtr.h" #include "nsIWeakReference.h" - +#include "nsEnumeratorUtils.h" #include "nsObserverList.h" -#define NS_AUTOLOCK(__monitor) nsAutoLock __lock(__monitor) - -static NS_DEFINE_CID(kObserverListCID, NS_OBSERVERLIST_CID); - - -class nsObserverListEnumerator : public nsIBidirectionalEnumerator - { - public: - nsObserverListEnumerator( nsISupportsArray* ); - virtual ~nsObserverListEnumerator() {}; - NS_DECL_ISUPPORTS - NS_DECL_NSIENUMERATOR - NS_DECL_NSIBIDIRECTIONALENUMERATOR - - private: - PRUint32 GetTargetArraySize() const; - nsresult MoveToIndex( PRUint32 ); - - private: - nsCOMPtr mTargetArray; - PRUint32 mCurrentItemIndex; - }; - -NS_IMPL_ISUPPORTS2(nsObserverListEnumerator, - nsIBidirectionalEnumerator, - nsIEnumerator) - -nsObserverListEnumerator::nsObserverListEnumerator( nsISupportsArray* anArray ) - : mRefCnt(0), - mTargetArray(anArray), - mCurrentItemIndex(0) - { - NS_INIT_REFCNT(); - } - -PRUint32 -nsObserverListEnumerator::GetTargetArraySize() const - { - PRUint32 array_size = 0; - mTargetArray->Count(&array_size); - return array_size; - } - -nsresult -nsObserverListEnumerator::MoveToIndex( PRUint32 aNewIndex ) - { - mCurrentItemIndex = aNewIndex; - return (aNewIndex < GetTargetArraySize()) ? NS_OK : NS_ERROR_FAILURE; - } - - -NS_IMETHODIMP -nsObserverListEnumerator::First() - { - NS_ASSERTION(mTargetArray, "must enumerate over an non-null list"); - - return MoveToIndex(0); - } - -NS_IMETHODIMP -nsObserverListEnumerator::Last() - { - NS_ASSERTION(mTargetArray, "must enumerate over an non-null list"); - - return MoveToIndex(GetTargetArraySize()-1); - } - -NS_IMETHODIMP -nsObserverListEnumerator::Prev() - { - NS_ASSERTION(mTargetArray, "must enumerate over an non-null list"); - - return MoveToIndex(mCurrentItemIndex-1); - } - -NS_IMETHODIMP -nsObserverListEnumerator::Next() - { - NS_ASSERTION(mTargetArray, "must enumerate over an non-null list"); - - return MoveToIndex(mCurrentItemIndex+1); - } - -NS_IMETHODIMP -nsObserverListEnumerator::CurrentItem( nsISupports** aItemPtr ) - { - NS_ASSERTION(mTargetArray, "must enumerate over an non-null list"); - NS_ASSERTION(aItemPtr, "must supply a place to put the result"); - - if ( mCurrentItemIndex >= GetTargetArraySize() ) - return NS_ERROR_FAILURE; - - nsCOMPtr elementPtr = getter_AddRefs(mTargetArray->ElementAt(mCurrentItemIndex)); - - if ( !aItemPtr || !elementPtr ) - return NS_ERROR_NULL_POINTER; - - nsCOMPtr weakRef = do_QueryInterface(elementPtr); - - nsresult status; - if ( weakRef ) - status = weakRef->QueryReferent(NS_GET_IID(nsIObserver), NS_REINTERPRET_CAST(void**, aItemPtr)); - else - status = elementPtr->QueryInterface(NS_GET_IID(nsIObserver), NS_REINTERPRET_CAST(void**, aItemPtr)); - - return status; - } - -NS_IMETHODIMP -nsObserverListEnumerator::IsDone() - { - NS_ASSERTION(mTargetArray, "must enumerate over an non-null list"); - - return (mCurrentItemIndex >= GetTargetArraySize()) ? NS_OK : NS_ENUMERATOR_FALSE; - } - - - -//////////////////////////////////////////////////////////////////////////////// -// nsObserverList Implementation - - -NS_IMPL_ISUPPORTS1(nsObserverList, nsIObserverList) - -NS_COM nsresult NS_NewObserverList(nsIObserverList** anObserverList) -{ - - if (anObserverList == NULL) - { - return NS_ERROR_NULL_POINTER; - } - nsObserverList* it = new nsObserverList(); - - if (it == 0) { - return NS_ERROR_OUT_OF_MEMORY; - } - - return it->QueryInterface(NS_GET_IID(nsIObserverList), (void **) anObserverList); -} - nsObserverList::nsObserverList() - : mLock(nsnull) { - NS_INIT_REFCNT(); mLock = PR_NewLock(); } @@ -199,109 +56,80 @@ nsObserverList::~nsObserverList(void) PR_DestroyLock(mLock); } - -NS_IMETHODIMP nsObserverList::AddObserver(nsIObserver* anObserver) +nsresult +nsObserverList::AddObserver(nsIObserver* anObserver, PRBool ownsWeak) { nsresult rv; PRBool inserted; - NS_ENSURE_ARG(anObserver); - - NS_AUTOLOCK(mLock); + NS_ENSURE_ARG(anObserver); + + nsAutoLock lock(mLock); if (!mObserverList) { - rv = NS_NewISupportsArray(getter_AddRefs(mObserverList)); + rv = NS_NewISupportsArray(getter_AddRefs(mObserverList)); if (NS_FAILED(rv)) return rv; } #ifdef NS_WEAK_OBSERVERS - nsCOMPtr weakRefFactory = do_QueryInterface(anObserver); - nsCOMPtr observerRef; - if ( weakRefFactory ) - observerRef = getter_AddRefs(NS_STATIC_CAST(nsISupports*, NS_GetWeakReference(weakRefFactory))); - else - observerRef = anObserver; + nsCOMPtr observerRef; + if (ownsWeak) { + nsCOMPtr weakRefFactory = do_QueryInterface(anObserver); + NS_ASSERTION(weakRefFactory, "AddObserver: trying weak object that doesnt support nsIWeakReference"); + if ( weakRefFactory ) + observerRef = getter_AddRefs(NS_STATIC_CAST(nsISupports*, NS_GetWeakReference(weakRefFactory))); + } else { +#if DEBUG + // if you are hitting this assertion, contact dougt@netscape.com. There may be a ownership problem caused by his checkin to freeze nsIObserver + nsCOMPtr weakRefFactory = do_QueryInterface(anObserver); + NS_ASSERTION(!weakRefFactory, "Your object supports weak references, but is being added with a strong reference"); +#endif + observerRef = anObserver; + } + if (!observerRef) + return NS_ERROR_FAILURE; - if(observerRef) { - inserted = mObserverList->AppendElement(observerRef); + inserted = mObserverList->AppendElement(observerRef); #else - if(*anObserver) { + if(*anObserver) inserted = mObserverList->AppendElement(*anObserver); #endif - return inserted ? NS_OK : NS_ERROR_FAILURE; - } - - return NS_ERROR_FAILURE; + return inserted ? NS_OK : NS_ERROR_FAILURE; } -NS_IMETHODIMP nsObserverList::RemoveObserver(nsIObserver* anObserver) +nsresult +nsObserverList::RemoveObserver(nsIObserver* anObserver) { PRBool removed; + + NS_ENSURE_ARG(anObserver); - NS_ENSURE_ARG(anObserver); + nsAutoLock lock(mLock); - NS_AUTOLOCK(mLock); - - if (!mObserverList) + if (!mObserverList) return NS_ERROR_FAILURE; - + #ifdef NS_WEAK_OBSERVERS - nsCOMPtr weakRefFactory = do_QueryInterface(anObserver); - nsCOMPtr observerRef; - if ( weakRefFactory ) - observerRef = getter_AddRefs(NS_STATIC_CAST(nsISupports*, NS_GetWeakReference(weakRefFactory))); - else - observerRef = anObserver; - - if(observerRef) { + nsCOMPtr weakRefFactory = do_QueryInterface(anObserver); + nsCOMPtr observerRef; + if ( weakRefFactory ) + observerRef = getter_AddRefs(NS_STATIC_CAST(nsISupports*, NS_GetWeakReference(weakRefFactory))); + else + observerRef = anObserver; + + if(observerRef) removed = mObserverList->RemoveElement(observerRef); #else - if(*anObserver) { - removed = mObserverList->RemoveElement(*anObserver); + if(*anObserver) + removed = mObserverList->RemoveElement(*anObserver); #endif - return removed ? NS_OK : NS_ERROR_FAILURE; - } - - return NS_ERROR_FAILURE; + return removed ? NS_OK : NS_ERROR_FAILURE; } -NS_IMETHODIMP nsObserverList::EnumerateObserverList(nsIEnumerator** anEnumerator) +nsresult +nsObserverList::GetObserverList(nsISimpleEnumerator** anEnumerator) { - NS_AUTOLOCK(mLock); + nsAutoLock lock(mLock); - NS_ENSURE_ARG(anEnumerator); - - if (!mObserverList) - return NS_ERROR_FAILURE; - -#ifdef NS_WEAK_OBSERVERS - nsCOMPtr enumerator = new nsObserverListEnumerator(mObserverList); - if ( !enumerator ) - return NS_ERROR_OUT_OF_MEMORY; - - return CallQueryInterface(enumerator, anEnumerator); -#else - return mObserverList->Enumerate(anEnumerator); -#endif -} - - -//---------------------------------------------------------------------------------------- -NS_METHOD nsObserverList::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr) -//---------------------------------------------------------------------------------------- -{ - if (aInstancePtr == NULL) - return NS_ERROR_NULL_POINTER; - - nsObserverList* it = new nsObserverList; - if (!it) - return NS_ERROR_OUT_OF_MEMORY; - - nsresult rv = it->QueryInterface(aIID, aInstancePtr); - if (NS_FAILED(rv)) - { - delete it; - return rv; - } - return rv; + return NS_NewArrayEnumerator(anEnumerator, mObserverList); } diff --git a/mozilla/xpcom/ds/nsObserverList.h b/mozilla/xpcom/ds/nsObserverList.h index ae64597f52e..ee3d7c577f8 100644 --- a/mozilla/xpcom/ds/nsObserverList.h +++ b/mozilla/xpcom/ds/nsObserverList.h @@ -38,43 +38,23 @@ #ifndef nsObserverList_h___ #define nsObserverList_h___ -#include "nsIObserverList.h" +#include "nsIObserver.h" #include "nsIEnumerator.h" #include "nsISupportsArray.h" -// {E777D484-E6E3-11d2-8ACD-00105A1B8860} -#define NS_OBSERVERLIST_CID \ -{ 0xe777d484, 0xe6e3, 0x11d2, { 0x8a, 0xcd, 0x0, 0x10, 0x5a, 0x1b, 0x88, 0x60 } } - -class nsObserverList : public nsIObserverList +class nsObserverList { public: + nsObserverList(); + virtual ~nsObserverList(); - nsObserverList(); - virtual ~nsObserverList(); - - NS_DEFINE_STATIC_CID_ACCESSOR(NS_OBSERVERLIST_CID); - - NS_DECL_ISUPPORTS - - NS_IMETHOD AddObserver(nsIObserver* anObserver); - NS_IMETHOD RemoveObserver(nsIObserver* anObserver); - - NS_IMETHOD EnumerateObserverList(nsIEnumerator** anEnumerator); - -public: - - static NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr); + nsresult AddObserver(nsIObserver* anObserver, PRBool ownsWeak); + nsresult RemoveObserver(nsIObserver* anObserver); + nsresult GetObserverList(nsISimpleEnumerator** anEnumerator); protected: - - // This is ObserverList monitor object. - PRLock* mLock; - -private: - - nsCOMPtr mObserverList; - + PRLock* mLock; + nsCOMPtr mObserverList; }; diff --git a/mozilla/xpcom/ds/nsObserverService.cpp b/mozilla/xpcom/ds/nsObserverService.cpp index 83590eaefa9..dac9adf977e 100644 --- a/mozilla/xpcom/ds/nsObserverService.cpp +++ b/mozilla/xpcom/ds/nsObserverService.cpp @@ -43,7 +43,6 @@ #include "nsIComponentManager.h" #include "nsIObserverService.h" #include "nsObserverService.h" -#include "nsIObserverList.h" #include "nsObserverList.h" #include "nsHashtable.h" @@ -65,7 +64,7 @@ NS_COM nsresult NS_NewObserverService(nsIObserverService** anObserverService) } nsObserverService::nsObserverService() - : mObserverTopicTable(NULL) + : mObserverTopicTable(nsnull) { NS_INIT_REFCNT(); mObserverTopicTable = nsnull; @@ -83,7 +82,7 @@ nsObserverService::Create(nsISupports* outer, const nsIID& aIID, void* *aInstanc { nsresult rv; nsObserverService* os = new nsObserverService(); - if (os == NULL) + if (os == nsnull) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(os); rv = os->QueryInterface(aIID, aInstancePtr); @@ -108,166 +107,112 @@ nsresult nsObserverService::GetObserverService(nsIObserverService** anObserverSe static PRBool PR_CALLBACK ReleaseObserverList(nsHashKey *aKey, void *aData, void* closure) { - nsIObserverList* observerList = NS_STATIC_CAST(nsIObserverList*, aData); - NS_RELEASE(observerList); + nsObserverList* observerList = NS_STATIC_CAST(nsObserverList*, aData); + delete(observerList); return PR_TRUE; } -nsresult nsObserverService::GetObserverList(const PRUnichar* aTopic, nsIObserverList** anObserverList) +nsresult nsObserverService::GetObserverList(const char* aTopic, nsObserverList** anObserverList) { - if (anObserverList == NULL) - { + if (anObserverList == nsnull) return NS_ERROR_NULL_POINTER; - } - if(mObserverTopicTable == NULL) { - mObserverTopicTable = new nsObjectHashtable(nsnull, nsnull, // should never be cloned - ReleaseObserverList, nsnull, - 256, PR_TRUE); - if (mObserverTopicTable == NULL) + if(mObserverTopicTable == nsnull) + { + mObserverTopicTable = new nsObjectHashtable(nsnull, + nsnull, // should never be cloned + ReleaseObserverList, + nsnull, + 256, + PR_TRUE); + if (mObserverTopicTable == nsnull) return NS_ERROR_OUT_OF_MEMORY; } + + nsCStringKey key(aTopic); - nsStringKey key(aTopic); - - nsIObserverList *topicObservers = nsnull; - if (mObserverTopicTable->Exists(&key)) { - topicObservers = (nsIObserverList *) mObserverTopicTable->Get(&key); - if (topicObservers != NULL) { - *anObserverList = topicObservers; - } else { - NS_NewObserverList(&topicObservers); - mObserverTopicTable->Put(&key, topicObservers); - } - } else { - NS_NewObserverList(&topicObservers); - *anObserverList = topicObservers; - mObserverTopicTable->Put(&key, topicObservers); + nsObserverList *topicObservers; + topicObservers = (nsObserverList *) mObserverTopicTable->Get(&key); + if (topicObservers) + { + *anObserverList = topicObservers; + return NS_OK; } + topicObservers = new nsObserverList(); + if (!topicObservers) + return NS_ERROR_OUT_OF_MEMORY; + + *anObserverList = topicObservers; + mObserverTopicTable->Put(&key, topicObservers); + return NS_OK; } -NS_IMETHODIMP nsObserverService::AddObserver(nsIObserver* anObserver, const PRUnichar* aTopic) +NS_IMETHODIMP nsObserverService::AddObserver(nsIObserver* anObserver, const char* aTopic, PRBool ownsWeak) { - nsIObserverList* anObserverList; + nsObserverList* anObserverList; nsresult rv; - if (anObserver == NULL) - { + if (anObserver == nsnull || aTopic == nsnull) return NS_ERROR_NULL_POINTER; - } - - if (aTopic == NULL) - { - return NS_ERROR_NULL_POINTER; - } rv = GetObserverList(aTopic, &anObserverList); if (NS_FAILED(rv)) return rv; - if (anObserverList) { - return anObserverList->AddObserver(anObserver); - } - - return NS_ERROR_FAILURE; + return anObserverList->AddObserver(anObserver, ownsWeak); } -NS_IMETHODIMP nsObserverService::RemoveObserver(nsIObserver* anObserver, const PRUnichar* aTopic) +NS_IMETHODIMP nsObserverService::RemoveObserver(nsIObserver* anObserver, const char* aTopic) { - nsIObserverList* anObserverList; + nsObserverList* anObserverList; nsresult rv; - if (anObserver == NULL) - { + if (anObserver == nsnull || aTopic == nsnull) return NS_ERROR_NULL_POINTER; - } - - if (aTopic == NULL) - { - return NS_ERROR_NULL_POINTER; - } rv = GetObserverList(aTopic, &anObserverList); if (NS_FAILED(rv)) return rv; - if (anObserverList) { - return anObserverList->RemoveObserver(anObserver); - } - - return NS_ERROR_FAILURE; + return anObserverList->RemoveObserver(anObserver); } -NS_IMETHODIMP nsObserverService::EnumerateObserverList(const PRUnichar* aTopic, nsIEnumerator** anEnumerator) +NS_IMETHODIMP nsObserverService::EnumerateObservers(const char* aTopic, nsISimpleEnumerator** anEnumerator) { - nsIObserverList* anObserverList; + nsObserverList* anObserverList; nsresult rv; - if (anEnumerator == NULL) - { + if (anEnumerator == nsnull || aTopic == nsnull) return NS_ERROR_NULL_POINTER; - } - - if (aTopic == NULL) - { - return NS_ERROR_NULL_POINTER; - } rv = GetObserverList(aTopic, &anObserverList); if (NS_FAILED(rv)) return rv; - if (anObserverList) { - return anObserverList->EnumerateObserverList(anEnumerator); - } - - return NS_ERROR_FAILURE; + return anObserverList->GetObserverList(anEnumerator); } // Enumerate observers of aTopic and call Observe on each. -NS_IMETHODIMP nsObserverService::Notify( nsISupports *aSubject, - const PRUnichar *aTopic, - const PRUnichar *someData ) { +NS_IMETHODIMP nsObserverService::NotifyObservers( nsISupports *aSubject, + const char *aTopic, + const PRUnichar *someData ) { nsresult rv = NS_OK; - nsIEnumerator *observers; - // Get observer list enumerator. - rv = this->EnumerateObserverList( aTopic, &observers ); - if ( NS_SUCCEEDED( rv ) ) { - // Go to start of observer list. - rv = observers->First(); - // Continue until error or end of list. - while ( observers->IsDone() != NS_OK && NS_SUCCEEDED(rv) ) { - PRBool advanceToNext = PR_TRUE; - // Get current item (observer). - nsISupports *base; - rv = observers->CurrentItem( &base ); - if ( NS_SUCCEEDED( rv ) ) { - // Convert item to nsIObserver. - nsIObserver *observer; - rv = base->QueryInterface( NS_GET_IID(nsIObserver), (void**)&observer ); - if ( NS_SUCCEEDED( rv ) && observer ) { - // Tell the observer what's up. - observer->Observe( aSubject, aTopic, someData ); - nsCOMPtr currentItem; - observers->CurrentItem(getter_AddRefs(currentItem)); - // check if the current item has changed, because the - // observer removed the old current item. - advanceToNext = (currentItem == base); - // Release the observer. - observer->Release(); - } - NS_IF_RELEASE(base); - } - // Go on to next observer in list. - if (advanceToNext) - rv = observers->Next(); - } - // Release the observer list. - observers->Release(); - rv = NS_OK; + nsCOMPtr observers; + nsCOMPtr observerRef; + + rv = EnumerateObservers( aTopic, getter_AddRefs(observers) ); + if ( NS_FAILED( rv ) ) + return rv; + PRBool loop = PR_TRUE; + while( NS_SUCCEEDED(observers->HasMoreElements(&loop)) && loop) + { + observers->GetNext(getter_AddRefs(observerRef)); + nsCOMPtr observer = do_QueryInterface(observerRef); + if ( observer ) + observer->Observe( aSubject, aTopic, someData ); } - return rv; + return NS_OK; } //////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/xpcom/ds/nsObserverService.h b/mozilla/xpcom/ds/nsObserverService.h index 5619dc86488..8661281cc38 100644 --- a/mozilla/xpcom/ds/nsObserverService.h +++ b/mozilla/xpcom/ds/nsObserverService.h @@ -39,8 +39,11 @@ #define nsObserverService_h___ #include "nsIObserverService.h" -#include "nsIObserverList.h" +#define NS_OBSERVERSERVICE_CONTRACTID "@mozilla.org/observer-service;1" +#define NS_OBSERVERSERVICE_CLASSNAME "Observer Service" + +class nsObserverList; class nsObjectHashtable; // {D07F5195-E3D1-11d2-8ACD-00105A1B8860} @@ -49,26 +52,26 @@ class nsObjectHashtable; class nsObserverService : public nsIObserverService { public: - NS_DEFINE_STATIC_CID_ACCESSOR( NS_OBSERVERSERVICE_CID ) + NS_DEFINE_STATIC_CID_ACCESSOR( NS_OBSERVERSERVICE_CID ) static nsresult GetObserverService(nsIObserverService** anObserverService); - NS_DECL_NSIOBSERVERSERVICE - nsObserverService(); virtual ~nsObserverService(void); NS_DECL_ISUPPORTS + NS_DECL_NSIOBSERVERSERVICE + static NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr); private: - - NS_IMETHOD GetObserverList(const PRUnichar* aTopic, nsIObserverList** anObserverList); - nsObjectHashtable* mObserverTopicTable; + nsresult GetObserverList(const char* aTopic, nsObserverList** anObserverList); + + }; #endif /* nsObserverService_h___ */ diff --git a/mozilla/xpcom/tests/TestObserverService.cpp b/mozilla/xpcom/tests/TestObserverService.cpp index 82eee6b2e80..6ca78d048de 100644 --- a/mozilla/xpcom/tests/TestObserverService.cpp +++ b/mozilla/xpcom/tests/TestObserverService.cpp @@ -40,7 +40,9 @@ #include "nsISupports.h" #include "nsIComponentManager.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIObserver.h" +#include "nsIEnumerator.h" #include "nsString.h" #include "nsReadableUtils.h" #include "prprf.h" @@ -82,9 +84,9 @@ NS_IMPL_ISUPPORTS2( TestObserver, nsIObserver, nsISupportsWeakReference ); NS_IMETHODIMP TestObserver::Observe( nsISupports *aSubject, - const PRUnichar *aTopic, + const char *aTopic, const PRUnichar *someData ) { - nsString topic( aTopic ); + nsCString topic( aTopic ); nsString data( someData ); /* The annoying double-cast below is to work around an annoying bug in @@ -99,8 +101,8 @@ TestObserver::Observe( nsISupports *aSubject, int main(int argc, char *argv[]) { - nsString topicA; topicA.AssignWithConversion( "topic-A" ); - nsString topicB; topicB.AssignWithConversion( "topic-B" ); + nsCString topicA; topicA.Assign( "topic-A" ); + nsCString topicB; topicB.Assign( "topic-B" ); nsresult rv; nsresult res = nsComponentManager::CreateInstance(NS_OBSERVERSERVICE_CONTRACTID, @@ -110,55 +112,55 @@ int main(int argc, char *argv[]) if (res == NS_OK) { - nsIObserver *anObserver; nsIObserver *aObserver = new TestObserver(NS_ConvertASCIItoUCS2("Observer-A")); aObserver->AddRef(); nsIObserver *bObserver = new TestObserver(NS_ConvertASCIItoUCS2("Observer-B")); bObserver->AddRef(); cout << "Adding Observer-A as observer of topic-A..." << endl; - rv = anObserverService->AddObserver(aObserver, topicA.get()); + rv = anObserverService->AddObserver(aObserver, topicA.get(), PR_FALSE); testResult(rv); cout << "Adding Observer-B as observer of topic-A..." << endl; - rv = anObserverService->AddObserver(bObserver, topicA.get()); + rv = anObserverService->AddObserver(bObserver, topicA.get(), PR_FALSE); testResult(rv); cout << "Adding Observer-B as observer of topic-B..." << endl; - rv = anObserverService->AddObserver(bObserver, topicB.get()); + rv = anObserverService->AddObserver(bObserver, topicB.get(), PR_FALSE); testResult(rv); cout << "Testing Notify(observer-A, topic-A)..." << endl; - rv = anObserverService->Notify( aObserver, + rv = anObserverService->NotifyObservers( aObserver, topicA.get(), NS_ConvertASCIItoUCS2("Testing Notify(observer-A, topic-A)").get() ); testResult(rv); cout << "Testing Notify(observer-B, topic-B)..." << endl; - rv = anObserverService->Notify( bObserver, + rv = anObserverService->NotifyObservers( bObserver, topicB.get(), NS_ConvertASCIItoUCS2("Testing Notify(observer-B, topic-B)").get() ); testResult(rv); cout << "Testing EnumerateObserverList (for topic-A)..." << endl; - nsIEnumerator* e; - rv = anObserverService->EnumerateObserverList(topicA.get(), &e); + nsCOMPtr e; + rv = anObserverService->EnumerateObservers(topicA.get(), getter_AddRefs(e)); + testResult(rv); cout << "Enumerating observers of topic-A..." << endl; - if ( NS_SUCCEEDED( rv ) ) { - nsISupports *inst; - - for (e->First(); e->IsDone() != NS_OK; e->Next()) { - rv = e->CurrentItem(&inst); - if (NS_SUCCEEDED(rv)) { - rv = inst->QueryInterface(NS_GET_IID(nsIObserver),(void**)&anObserver); - cout << "Calling observe on enumerated observer " - << NS_REINTERPRET_CAST(TestObserver*, NS_REINTERPRET_CAST(void*, inst))->mName << "..." << endl; - rv = anObserver->Observe( inst, topicA.get(), NS_ConvertASCIItoUCS2("during enumeration").get() ); - testResult(rv); - } - } + if ( e ) { + nsCOMPtr observer; + PRBool loop = PR_TRUE; + while( NS_SUCCEEDED(e->HasMoreElements(&loop)) && loop) + { + e->GetNext(getter_AddRefs(observer)); + cout << "Calling observe on enumerated observer " + << NS_REINTERPRET_CAST(TestObserver*, NS_REINTERPRET_CAST(void*, observer.get()))->mName << "..." << endl; + rv = observer->Observe( observer, + topicA.get(), + NS_ConvertASCIItoUCS2("during enumeration").get() ); + testResult(rv); + } } cout << "...done enumerating observers of topic-A" << endl; diff --git a/mozilla/xpcom/threads/nsEventQueue.cpp b/mozilla/xpcom/threads/nsEventQueue.cpp index d182139a7fa..507b301e037 100644 --- a/mozilla/xpcom/threads/nsEventQueue.cpp +++ b/mozilla/xpcom/threads/nsEventQueue.cpp @@ -42,6 +42,8 @@ #include "nsIServiceManager.h" #include "nsIObserverService.h" +#include "nsObserverService.h" + #include "nsString.h" #include "prlog.h" @@ -218,11 +220,9 @@ nsEventQueueImpl::NotifyObservers(const char *aTopic) nsCOMPtr os = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { - nsAutoString topic; - topic.AssignWithConversion(aTopic); nsCOMPtr kungFuDeathGrip(this); nsCOMPtr us(do_QueryInterface(kungFuDeathGrip)); - os->Notify(us, topic.get(), NULL); + os->NotifyObservers(us, aTopic, NULL); } } diff --git a/mozilla/xpfe/appshell/src/nsAppShellService.cpp b/mozilla/xpfe/appshell/src/nsAppShellService.cpp index 8a93b8a78cc..1510eecc480 100644 --- a/mozilla/xpfe/appshell/src/nsAppShellService.cpp +++ b/mozilla/xpfe/appshell/src/nsAppShellService.cpp @@ -46,6 +46,7 @@ #include "nsIServiceManager.h" #include "nsIEventQueueService.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIObserver.h" #include "nsWeakReference.h" #include "nsXPComFactory.h" /* template implementation of a XPCOM factory */ @@ -83,15 +84,13 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID); static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID); static NS_DEFINE_CID(kXPConnectCID, NS_XPCONNECT_CID); -static char *sWindowWatcherContractID = "@mozilla.org/embedcomp/window-watcher;1"; -// copied from nsEventQueue.cpp -static char *gEQActivatedNotification = "nsIEventQueueActivated"; -static char *gEQDestroyedNotification = "nsIEventQueueDestroyed"; - -NS_NAMED_LITERAL_STRING(gSkinSelectedTopic, "skin-selected"); -NS_NAMED_LITERAL_STRING(gLocaleSelectedTopic, "locale-selected"); -NS_NAMED_LITERAL_STRING(gInstallRestartTopic, "xpinstall-restart"); +#define sWindowWatcherContractID "@mozilla.org/embedcomp/window-watcher;1" +#define gEQActivatedNotification "nsIEventQueueActivated" +#define gEQDestroyedNotification "nsIEventQueueDestroyed" +#define gSkinSelectedTopic "skin-selected" +#define gLocaleSelectedTopic "locale-selected" +#define gInstallRestartTopic "xpinstall-restart" nsAppShellService::nsAppShellService() : mAppShell( nsnull ), @@ -760,13 +759,11 @@ nsAppShellService::SetQuitOnLastWindowClosing(PRBool aQuitOnLastWindowClosing) //------------------------------------------------------------------------- NS_IMETHODIMP nsAppShellService::Observe(nsISupports *aSubject, - const PRUnichar *aTopic, + const char *aTopic, const PRUnichar *) { - nsAutoString topic(aTopic); - NS_ASSERTION(mAppShell, "appshell service notified before appshell built"); - if (topic.EqualsWithConversion(gEQActivatedNotification)) { + if (!nsCRT::strcmp(aTopic, gEQActivatedNotification) ) { nsCOMPtr eq(do_QueryInterface(aSubject)); if (eq) { PRBool isNative = PR_TRUE; @@ -775,7 +772,7 @@ NS_IMETHODIMP nsAppShellService::Observe(nsISupports *aSubject, if (isNative) mAppShell->ListenToEventQueue(eq, PR_TRUE); } - } else if (topic.EqualsWithConversion(gEQDestroyedNotification)) { + } else if (!nsCRT::strcmp(aTopic, gEQDestroyedNotification)) { nsCOMPtr eq(do_QueryInterface(aSubject)); if (eq) { PRBool isNative = PR_TRUE; @@ -784,9 +781,9 @@ NS_IMETHODIMP nsAppShellService::Observe(nsISupports *aSubject, if (isNative) mAppShell->ListenToEventQueue(eq, PR_FALSE); } - } else if (topic.Equals(gSkinSelectedTopic) || - topic.Equals(gLocaleSelectedTopic) || - topic.Equals(gInstallRestartTopic)) { + } else if (!nsCRT::strcmp(aTopic, gSkinSelectedTopic) || + !nsCRT::strcmp(aTopic, gLocaleSelectedTopic) || + !nsCRT::strcmp(aTopic, gInstallRestartTopic)) { if (mNativeAppSupport) mNativeAppSupport->SetIsServerMode(PR_FALSE); } @@ -799,9 +796,6 @@ void nsAppShellService::RegisterObserver(PRBool aRegister) nsresult rv; nsISupports *glop; - nsAutoString topicA; topicA.AssignWithConversion(gEQActivatedNotification); - nsAutoString topicB; topicB.AssignWithConversion(gEQDestroyedNotification); - // here's a silly dance. seems better to do it than not, though... nsCOMPtr weObserve(do_QueryInterface(NS_STATIC_CAST(nsIObserver *, this))); @@ -812,19 +806,19 @@ void nsAppShellService::RegisterObserver(PRBool aRegister) if (NS_SUCCEEDED(rv)) { nsIObserverService *os = NS_STATIC_CAST(nsIObserverService*,glop); if (aRegister) { - os->AddObserver(weObserve, topicA.get()); - os->AddObserver(weObserve, topicB.get()); - os->AddObserver(weObserve, gSkinSelectedTopic.get()); - os->AddObserver(weObserve, gLocaleSelectedTopic.get()); - os->AddObserver(weObserve, gInstallRestartTopic.get()); + os->AddObserver(weObserve, gEQActivatedNotification, PR_TRUE); + os->AddObserver(weObserve, gEQDestroyedNotification, PR_TRUE); + os->AddObserver(weObserve, gSkinSelectedTopic, PR_TRUE); + os->AddObserver(weObserve, gLocaleSelectedTopic, PR_TRUE); + os->AddObserver(weObserve, gInstallRestartTopic, PR_TRUE); } else { - os->RemoveObserver(weObserve, topicA.get()); - os->RemoveObserver(weObserve, topicB.get()); - os->RemoveObserver(weObserve, gSkinSelectedTopic.get()); - os->RemoveObserver(weObserve, gLocaleSelectedTopic.get()); - os->RemoveObserver(weObserve, gInstallRestartTopic.get()); + os->RemoveObserver(weObserve, gEQActivatedNotification); + os->RemoveObserver(weObserve, gEQDestroyedNotification); + os->RemoveObserver(weObserve, gSkinSelectedTopic); + os->RemoveObserver(weObserve, gLocaleSelectedTopic); + os->RemoveObserver(weObserve, gInstallRestartTopic); } - nsServiceManager::ReleaseService(NS_OBSERVERSERVICE_CONTRACTID, glop); + NS_RELEASE(glop); } } diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index 1c1f58e2bb2..659b17202c0 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -110,6 +110,7 @@ #include "nsIDocumentLoader.h" #include "nsIDocumentLoaderFactory.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "prprf.h" //#include "nsIDOMHTMLInputElement.h" //#include "nsIDOMHTMLImageElement.h" @@ -1667,10 +1668,10 @@ nsWebShellWindow::NotifyObservers( const nsString &aTopic, const nsString &someD (nsISupports**)&svc ); if ( NS_SUCCEEDED( rv ) && svc ) { // Notify observers as instructed; the subject is "this" web shell window. - nsAutoString topic; topic.AssignWithConversion(prefix); - topic.AppendWithConversion(";"); - topic += aTopic; - rv = svc->Notify( (nsIWebShellWindow*)this, topic.get(), someData.get() ); + nsCAutoString topic; topic.Assign(prefix); + topic.Append(";"); + topic.AppendWithConversion(aTopic); + rv = svc->NotifyObservers( (nsIWebShellWindow*)this, topic.get(), someData.get() ); // Release the service. nsServiceManager::ReleaseService( NS_OBSERVERSERVICE_CONTRACTID, svc ); } else { diff --git a/mozilla/xpfe/appshell/src/nsXULWindow.cpp b/mozilla/xpfe/appshell/src/nsXULWindow.cpp index 489247cb4b7..c74bcd4def2 100644 --- a/mozilla/xpfe/appshell/src/nsXULWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsXULWindow.cpp @@ -49,6 +49,7 @@ #include "nsIJSContextStack.h" #include "nsIMarkupDocumentViewer.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIWindowMediator.h" #include "nsIScreenManager.h" #include "nsIScreen.h" @@ -1437,11 +1438,11 @@ NS_IMETHODIMP nsXULWindow::NotifyObservers(const PRUnichar* aTopic, nsCOMPtr removeme(do_QueryInterface(NS_STATIC_CAST(nsIXULWindow*, this))); - nsAutoString topic; topic.AssignWithConversion(prefix); - topic.AppendWithConversion(";"); - topic += aTopic; - - NS_ENSURE_SUCCESS(service->Notify(removeme, topic.get(), aData), + nsCAutoString topic; topic.Assign(prefix); + topic.Append(";"); + topic.AppendWithConversion(aTopic); + + NS_ENSURE_SUCCESS(service->NotifyObservers(removeme, topic.get(), aData), NS_ERROR_FAILURE); return NS_OK; } diff --git a/mozilla/xpfe/bootstrap/nsAppRunner.cpp b/mozilla/xpfe/bootstrap/nsAppRunner.cpp index 9134f6cd812..79b77765eb4 100644 --- a/mozilla/xpfe/bootstrap/nsAppRunner.cpp +++ b/mozilla/xpfe/bootstrap/nsAppRunner.cpp @@ -52,6 +52,7 @@ #include "nsIAppShellService.h" #include "nsIAppStartupNotifier.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsAppShellCIDs.h" #include "prprf.h" #include "nsCRT.h" @@ -1100,7 +1101,7 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp ) nsCOMPtr splashScreenObserver(do_QueryInterface(nativeApp)); if (splashScreenObserver) { - obsService->AddObserver(splashScreenObserver, NS_ConvertASCIItoUCS2(NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID).get()); + obsService->AddObserver(splashScreenObserver, NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID, PR_FALSE); } } NS_TIMELINE_LEAVE("init observer service"); @@ -1135,7 +1136,7 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp ) nsCOMPtr splashScreenObserver(do_QueryInterface(nativeApp)); if (splashScreenObserver) { - obsService->RemoveObserver(splashScreenObserver, NS_ConvertASCIItoUCS2(NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID).get()); + obsService->RemoveObserver(splashScreenObserver, NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID); } } diff --git a/mozilla/xpfe/bootstrap/nsDocLoadObserver.cpp b/mozilla/xpfe/bootstrap/nsDocLoadObserver.cpp index a2507eda808..fac901f370f 100644 --- a/mozilla/xpfe/bootstrap/nsDocLoadObserver.cpp +++ b/mozilla/xpfe/bootstrap/nsDocLoadObserver.cpp @@ -39,6 +39,7 @@ #include "nsCOMPtr.h" #include "nsError.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIServiceManager.h" #include "nsString.h" #include "nsReadableUtils.h" @@ -68,8 +69,7 @@ void nsDocLoadObserver::Register() nsCOMPtr anObserverService = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { - if (NS_SUCCEEDED(anObserverService->AddObserver(this, - NS_ConvertASCIItoUCS2("EndDocumentLoad").get()))) + if (NS_SUCCEEDED(anObserverService->AddObserver(this, "EndDocumentLoad", PR_FALSE))) { mRegistered = PR_TRUE; } diff --git a/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp b/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp index 68d598441a8..d5c7526d237 100644 --- a/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp +++ b/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp @@ -67,6 +67,7 @@ #include "nsIPromptService.h" #include "nsNetCID.h" #include "nsIObserverService.h" +#include "nsObserverService.h" // These are needed to load a URL in a browser window. #include "nsIDOMLocation.h" @@ -2080,7 +2081,7 @@ nsNativeAppSupportWin::OnLastWindowClosing( nsIXULWindow *aWindow ) { nsCOMPtr observerService(do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; - observerService->Notify(nsnull, NS_LITERAL_STRING("session-logout").get(), nsnull); + observerService->NotifyObservers(nsnull, "session-logout", nsnull); mDidProfileStartup = PR_FALSE; diff --git a/mozilla/xpfe/browser/resources/content/navigator.js b/mozilla/xpfe/browser/resources/content/navigator.js index ef6a14e2f8d..52de564a9eb 100644 --- a/mozilla/xpfe/browser/resources/content/navigator.js +++ b/mozilla/xpfe/browser/resources/content/navigator.js @@ -1377,7 +1377,7 @@ function applyTheme(themeName) pref.SetUnicharPref("general.skins.selectedSkin", themeName.getAttribute("name")); var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService); - observerService.Notify(null, "skin-selected", null); + observerService.notifyObservers(null, "skin-selected", null); if (promptService) { var dialogTitle = gNavigatorBundle.getString("switchskinstitle"); diff --git a/mozilla/xpfe/browser/resources/content/nsBrowserStatusHandler.js b/mozilla/xpfe/browser/resources/content/nsBrowserStatusHandler.js index 3c72a515aee..e05bdd3cd99 100644 --- a/mozilla/xpfe/browser/resources/content/nsBrowserStatusHandler.js +++ b/mozilla/xpfe/browser/resources/content/nsBrowserStatusHandler.js @@ -299,7 +299,7 @@ nsBrowserStatusHandler.prototype = var observerService = Components.classes["@mozilla.org/observer-service;1"] .getService(Components.interfaces.nsIObserverService); try { - observerService.Notify(_content, "StartDocumentLoad", urlStr); + observerService.notifyObservers(_content, "StartDocumentLoad", urlStr); } catch (e) { } }, @@ -327,7 +327,7 @@ nsBrowserStatusHandler.prototype = var notification = Components.isSuccessCode(aStatus) ? "EndDocumentLoad" : "FailDocumentLoad"; try { - observerService.Notify(_content, notification, urlStr); + observerService.notifyObservers(_content, notification, urlStr); } catch (e) { } } diff --git a/mozilla/xpfe/browser/src/nsBrowserInstance.cpp b/mozilla/xpfe/browser/src/nsBrowserInstance.cpp index f94532e686c..fe5396171b1 100644 --- a/mozilla/xpfe/browser/src/nsBrowserInstance.cpp +++ b/mozilla/xpfe/browser/src/nsBrowserInstance.cpp @@ -109,6 +109,7 @@ #include "nsIDocumentLoader.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIFileSpec.h" @@ -237,7 +238,7 @@ public: nsCOMPtr obsServ = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; - rv = obsServ->AddObserver(this, NS_LITERAL_STRING("EndDocumentLoad").get()); + rv = obsServ->AddObserver(this, "EndDocumentLoad", PR_TRUE ); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to add self to observer service"); return rv; } @@ -279,7 +280,7 @@ public: } NS_IMETHOD Observe(nsISupports* aSubject, - const PRUnichar* aTopic, + const char* aTopic, const PRUnichar* someData) { nsresult rv = NS_OK; nsString data(someData); diff --git a/mozilla/xpfe/communicator/resources/content/utilityOverlay.js b/mozilla/xpfe/communicator/resources/content/utilityOverlay.js index 6a40cc8d845..a9df48964a3 100644 --- a/mozilla/xpfe/communicator/resources/content/utilityOverlay.js +++ b/mozilla/xpfe/communicator/resources/content/utilityOverlay.js @@ -413,11 +413,11 @@ function utilityOnLoad(aEvent) // crude way to prevent registering twice. try { - observerService.RemoveObserver(offlineObserver, "network:offline-status-changed"); + observerService.removeObserver(offlineObserver, "network:offline-status-changed"); } catch (ex) { } - observerService.AddObserver(offlineObserver, "network:offline-status-changed"); + observerService.addObserver(offlineObserver, "network:offline-status-changed", false); // make sure we remove this observer later addEventListener("unload",utilityOnUnload,false); @@ -431,7 +431,7 @@ function utilityOnUnload(aEvent) { var observerService = Components.classes[kObserverServiceProgID] .getService(Components.interfaces.nsIObserverService); - observerService.RemoveObserver(offlineObserver, "network:offline-status-changed"); + observerService.removeObserver(offlineObserver, "network:offline-status-changed"); } addEventListener("load",utilityOnLoad,true); diff --git a/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp b/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp index 8c4f5c166af..e386ded7af4 100644 --- a/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp +++ b/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp @@ -51,6 +51,7 @@ #include "nsIComponentManager.h" #include "nsIDOMWindow.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIRDFContainer.h" #include "nsIRDFContainerUtils.h" #include "nsIRDFService.h" @@ -1699,8 +1700,8 @@ nsBookmarksService::Init() do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); NS_ASSERTION(observerService, "Could not get observer service."); if (observerService) { - observerService->AddObserver(this, NS_LITERAL_STRING("profile-before-change").get()); - observerService->AddObserver(this, NS_LITERAL_STRING("profile-do-change").get()); + observerService->AddObserver(this, "profile-before-change", PR_TRUE); + observerService->AddObserver(this, "profile-do-change", PR_TRUE); } // read in bookmarks AFTER trying to get string bundle @@ -2433,11 +2434,11 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt, // nsIObserver methods -NS_IMETHODIMP nsBookmarksService::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +NS_IMETHODIMP nsBookmarksService::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { nsresult rv = NS_OK; - if (!nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-before-change").get())) + if (!nsCRT::strcmp(aTopic, "profile-before-change")) { // The profile has not changed yet. rv = Flush(); @@ -2449,7 +2450,7 @@ NS_IMETHODIMP nsBookmarksService::Observe(nsISupports *aSubject, const PRUnichar bookmarksFile.Delete(PR_FALSE); } } - else if (!nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-do-change").get())) + else if (!nsCRT::strcmp(aTopic, "profile-do-change")) { // The profile has aleady changed. rv = ReadBookmarks(); diff --git a/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp b/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp index dc5d37cbc4e..34dfc9479a5 100644 --- a/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp +++ b/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp @@ -79,6 +79,7 @@ #include "nsIPref.h" #include "nsIObserverService.h" +#include "nsObserverService.h" PRInt32 nsGlobalHistory::gRefCnt; nsIRDFService* nsGlobalHistory::gRDFService; @@ -2116,8 +2117,8 @@ nsGlobalHistory::Init() do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); NS_ASSERTION(observerService, "failed to get observer service"); if (observerService) { - observerService->AddObserver(this, NS_LITERAL_STRING("profile-before-change").get()); - observerService->AddObserver(this, NS_LITERAL_STRING("profile-do-change").get()); + observerService->AddObserver(this, "profile-before-change", PR_TRUE); + observerService->AddObserver(this, "profile-do-change", PR_TRUE); } return NS_OK; @@ -3157,26 +3158,24 @@ nsGlobalHistory::GetFindUriName(const char *aURL, nsIRDFNode **aResult) } NS_IMETHODIMP -nsGlobalHistory::Observe(nsISupports *aSubject, const PRUnichar *aTopic, +nsGlobalHistory::Observe(nsISupports *aSubject, + const char *aTopic, const PRUnichar *aSomeData) { nsresult rv; - nsDependentString aTopicString(aTopic); - // pref changing - update member vars - if (aTopicString.Equals(NS_LITERAL_STRING("nsPref:changed"))) { + if (!nsCRT::strcmp(aTopic, "nsPref:changed")) { // expiration date - nsCAutoString pref; pref.AssignWithConversion(aSomeData); - if (pref.Equals(PREF_BROWSER_HISTORY_EXPIRE_DAYS)) { + if (!nsCRT::strcmp(aSomeData, NS_LITERAL_STRING(PREF_BROWSER_HISTORY_EXPIRE_DAYS).get())) { nsCOMPtr prefs = do_GetService(kPrefCID, &rv); if (NS_SUCCEEDED(rv)) prefs->GetIntPref(PREF_BROWSER_HISTORY_EXPIRE_DAYS, &mExpireDays); } } - else if (aTopicString.Equals(NS_LITERAL_STRING("profile-before-change"))) { + else if (!nsCRT::strcmp(aTopic, "profile-before-change")) { rv = CloseDB(); if (!nsCRT::strcmp(aSomeData, NS_LITERAL_STRING("shutdown-cleanse").get())) { nsCOMPtr historyFile; @@ -3185,7 +3184,7 @@ nsGlobalHistory::Observe(nsISupports *aSubject, const PRUnichar *aTopic, rv = historyFile->Remove(PR_FALSE); } } - else if (aTopicString.Equals(NS_LITERAL_STRING("profile-do-change"))) + else if (!nsCRT::strcmp(aTopic, "profile-do-change")) rv = OpenDB(); return NS_OK; diff --git a/mozilla/xpfe/components/intl/nsCharsetMenu.cpp b/mozilla/xpfe/components/intl/nsCharsetMenu.cpp index 6a0ae31abaa..41ad3a703f4 100644 --- a/mozilla/xpfe/components/intl/nsCharsetMenu.cpp +++ b/mozilla/xpfe/components/intl/nsCharsetMenu.cpp @@ -339,12 +339,11 @@ private: NS_IMPL_ISUPPORTS1(nsCharsetMenuObserver, nsIObserver); -NS_IMETHODIMP nsCharsetMenuObserver::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +NS_IMETHODIMP nsCharsetMenuObserver::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { nsresult rv; - nsDependentString aTopicString(aTopic); - if (aTopicString.Equals(NS_LITERAL_STRING("nsPref:changed"))) { + if (!nsCRT::strcmp(aTopic, "nsPref:changed")) { nsDependentString prefName(someData); if (prefName.Equals(NS_LITERAL_STRING(kBrowserStaticPrefKey))) { diff --git a/mozilla/xpfe/components/prefwindow/resources/content/pref-appearance.xul b/mozilla/xpfe/components/prefwindow/resources/content/pref-appearance.xul index a527c397897..e32c5235fbf 100644 --- a/mozilla/xpfe/components/prefwindow/resources/content/pref-appearance.xul +++ b/mozilla/xpfe/components/prefwindow/resources/content/pref-appearance.xul @@ -67,7 +67,7 @@ var chromeRegistry = Components.classes["@mozilla.org/chrome/chrome-registry;1"].getService(Components.interfaces.nsIChromeRegistry); var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService); chromeRegistry.selectLocale(newLangCode, true); - observerService.Notify(null, "locale-selected", null); + observerService.notifyObservers(null, "locale-selected", null); } catch(e) { return false; diff --git a/mozilla/xpfe/components/prefwindow/resources/content/pref-themes.js b/mozilla/xpfe/components/prefwindow/resources/content/pref-themes.js index 280c9e9aadb..da43d87fa7c 100644 --- a/mozilla/xpfe/components/prefwindow/resources/content/pref-themes.js +++ b/mozilla/xpfe/components/prefwindow/resources/content/pref-themes.js @@ -54,7 +54,7 @@ function applySkin() tree.selectItem(selectedSkinItem); var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService); - observerService.Notify(null, "skin-selected", null); + observerService.notifyObservers(null, "skin-selected", null); var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService); try { diff --git a/mozilla/xpfe/components/related/resources/related-panel.js b/mozilla/xpfe/components/related/resources/related-panel.js index 2b3ab642415..9ceefd8f91c 100644 --- a/mozilla/xpfe/components/related/resources/related-panel.js +++ b/mozilla/xpfe/components/related/resources/related-panel.js @@ -202,9 +202,9 @@ function Init() oNavObserver.TrackContext(''+oContentWindow.location); if (oObserverService && oNavObserver) { - oObserverService.AddObserver(oNavObserver, "StartDocumentLoad"); - oObserverService.AddObserver(oNavObserver, "EndDocumentLoad"); - oObserverService.AddObserver(oNavObserver, "FailDocumentLoad"); + oObserverService.addObserver(oNavObserver, "StartDocumentLoad", false); + oObserverService.addObserver(oNavObserver, "EndDocumentLoad", false); + oObserverService.addObserver(oNavObserver, "FailDocumentLoad", false); } else { oNavObserver = null; dump("FAILURE to get observer service\n"); @@ -218,9 +218,9 @@ function Destruct() var oObserverService = Components.classes["@mozilla.org/observer-service;1"].getService(); oObserverService = oObserverService.QueryInterface(Components.interfaces.nsIObserverService); if (oObserverService && oNavObserver) { - oObserverService.RemoveObserver(oNavObserver, "StartDocumentLoad"); - oObserverService.RemoveObserver(oNavObserver, "EndDocumentLoad"); - oObserverService.RemoveObserver(oNavObserver, "FailDocumentLoad"); + oObserverService.removeObserver(oNavObserver, "StartDocumentLoad"); + oObserverService.removeObserver(oNavObserver, "EndDocumentLoad"); + oObserverService.removeObserver(oNavObserver, "FailDocumentLoad"); oNavObserver = null; } else { dump("FAILURE to get observer service\n"); diff --git a/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp b/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp index e7c9e2fa78b..c6cfe756133 100755 --- a/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp +++ b/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp @@ -76,6 +76,7 @@ #include "nsIBookmarksService.h" #include "nsIStringBundle.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nsIURL.h" #include "nsReadableUtils.h" @@ -898,8 +899,8 @@ InternetSearchDataSource::Init() nsCOMPtr observerService = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (observerService) { - observerService->AddObserver(this, NS_LITERAL_STRING("profile-before-change").get()); - observerService->AddObserver(this, NS_LITERAL_STRING("profile-do-change").get()); + observerService->AddObserver(this, "profile-before-change", PR_TRUE); + observerService->AddObserver(this, "profile-do-change", PR_TRUE); } return(rv); @@ -5744,11 +5745,11 @@ InternetSearchDataSource::ConvertEntities(nsString &nameStr, PRBool removeHTMLFl } NS_IMETHODIMP -InternetSearchDataSource::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData) +InternetSearchDataSource::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { nsresult rv = NS_OK; - if (!nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-before-change").get())) + if (!nsCRT::strcmp(aTopic, "profile-before-change")) { // The profile is about to change. categoryDataSource = nsnull; @@ -5762,7 +5763,7 @@ InternetSearchDataSource::Observe(nsISupports *aSubject, const PRUnichar *aTopic rv = searchFile->Remove(PR_FALSE); } } - else if (!nsCRT::strcmp(aTopic, NS_LITERAL_STRING("profile-do-change").get())) + else if (!nsCRT::strcmp(aTopic, "profile-do-change")) { // The profile has aleady changed. if (!categoryDataSource) diff --git a/mozilla/xpfe/components/xfer/src/nsStreamXferOp.cpp b/mozilla/xpfe/components/xfer/src/nsStreamXferOp.cpp index 6f27a738ba8..9f3c90998d8 100644 --- a/mozilla/xpfe/components/xfer/src/nsStreamXferOp.cpp +++ b/mozilla/xpfe/components/xfer/src/nsStreamXferOp.cpp @@ -143,7 +143,7 @@ nsStreamXferOp::OnError( int operation, nsresult errorCode ) { char buf[64]; PR_snprintf( buf, sizeof( buf ), "%d %X %u", operation, (int)errorCode, reason ); rv = mObserver->Observe( (nsIStreamTransferOperation*)this, - NS_ConvertASCIItoUCS2( NS_ISTREAMTRANSFER_CONTRACTID ";onError" ).get(), + NS_ISTREAMTRANSFER_CONTRACTID ";onError", NS_ConvertASCIItoUCS2( buf ).get() ); if ( NS_FAILED( rv ) ) { DEBUG_PRINTF( PR_STDOUT, "%s %d: Observe failed, rv=0x%08X\n", @@ -405,7 +405,7 @@ nsStreamXferOp::OnProgress(nsIRequest *request, nsISupports* aContext, char buf[32]; PR_snprintf( buf, sizeof buf, "%lu %ld", (unsigned long)aProgress, (long)mContentLength ); rv = mObserver->Observe( (nsIStreamTransferOperation*)this, - NS_ConvertASCIItoUCS2( NS_ISTREAMTRANSFER_CONTRACTID ";onProgress" ).get(), + NS_ISTREAMTRANSFER_CONTRACTID ";onProgress", NS_ConvertASCIItoUCS2( buf ).get() ); if ( NS_FAILED( rv ) ) { DEBUG_PRINTF( PR_STDOUT, "%s %d: Observe failed, rv=0x%08X\n", @@ -434,7 +434,7 @@ nsStreamXferOp::OnStatus( nsIRequest *request, if (NS_FAILED(rv)) return rv; nsAutoString msg(NS_STATIC_CAST(const PRUnichar*, str)); rv = mObserver->Observe( (nsIStreamTransferOperation*)this, - NS_ConvertASCIItoUCS2( NS_ISTREAMTRANSFER_CONTRACTID ";onStatus" ).get(), + NS_ISTREAMTRANSFER_CONTRACTID ";onStatus", msg.get() ); if ( NS_FAILED( rv ) ) { DEBUG_PRINTF( PR_STDOUT, "%s %d: Observe failed, rv=0x%08X\n", @@ -544,8 +544,8 @@ nsStreamXferOp::OnStopRequest( nsIRequest *request, if ( !mError && mObserver ) { nsCOMPtr kungFuDeathGrip(mObserver); rv = kungFuDeathGrip->Observe( (nsIStreamTransferOperation*)this, - NS_ConvertASCIItoUCS2( NS_ISTREAMTRANSFER_CONTRACTID ";onCompletion" ).get(), - nsnull ); + NS_ISTREAMTRANSFER_CONTRACTID ";onCompletion", + nsnull ); if ( NS_FAILED( rv ) ) { DEBUG_PRINTF( PR_STDOUT, "%s %d: Observe failed, rv=0x%08X\n", (char*)__FILE__, (int)__LINE__, (int)rv ); diff --git a/mozilla/xpfe/global/resources/content/globalOverlay.js b/mozilla/xpfe/global/resources/content/globalOverlay.js index f9de52e4eff..b8fd2b7f090 100644 --- a/mozilla/xpfe/global/resources/content/globalOverlay.js +++ b/mozilla/xpfe/global/resources/content/globalOverlay.js @@ -6,7 +6,7 @@ function goQuitApplication() { try { - ObserverService.Notify(null, "quit-application", null); + ObserverService.notifyObservers(null, "quit-application", null); } catch (ex) { diff --git a/mozilla/xpfe/global/resources/content/strres.js b/mozilla/xpfe/global/resources/content/strres.js index 0dfdeafebbb..7fbc2e7b93c 100644 --- a/mozilla/xpfe/global/resources/content/strres.js +++ b/mozilla/xpfe/global/resources/content/strres.js @@ -33,7 +33,7 @@ function selectLocale(event) var chromeRegistry = Components.classes["@mozilla.org/chrome/chrome-registry;1"].getService(Components.interfaces.nsIChromeRegistry); chromeRegistry.selectLocale(langcode, true); var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService); - observerService.Notify(null, "locale-selected", null); + observerService.notifyObservers(null, "locale-selected", null); var prefUtilBundle = srGetStrBundle("chrome://communicator/locale/pref/prefutilities.properties"); var brandBundle = srGetStrBundle("chrome://global/locale/brand.properties"); var alertText = prefUtilBundle.GetStringFromName("languageAlert"); diff --git a/mozilla/xpinstall/src/nsSoftwareUpdate.cpp b/mozilla/xpinstall/src/nsSoftwareUpdate.cpp index 9ded2903e2c..39896c885a3 100644 --- a/mozilla/xpinstall/src/nsSoftwareUpdate.cpp +++ b/mozilla/xpinstall/src/nsSoftwareUpdate.cpp @@ -33,6 +33,7 @@ #include "nsCOMPtr.h" #include "nsCRT.h" #include "nsIObserverService.h" +#include "nsObserverService.h" #include "nspr.h" #include "prlock.h" @@ -149,7 +150,7 @@ nsSoftwareUpdate::nsSoftwareUpdate() do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) - observerService->AddObserver(this, NS_LITERAL_STRING(NS_XPCOM_SHUTDOWN_OBSERVER_ID).get()); + observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE); } @@ -218,11 +219,10 @@ nsSoftwareUpdate::Shutdown() } NS_IMETHODIMP nsSoftwareUpdate::Observe(nsISupports *aSubject, - const PRUnichar *aTopic, + const char *aTopic, const PRUnichar *aData) { - nsDependentString topicString(aTopic); - if (topicString.Equals(NS_LITERAL_STRING(NS_XPCOM_SHUTDOWN_OBSERVER_ID))) + if (!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) Shutdown(); return NS_OK; diff --git a/mozilla/xpinstall/src/nsXPIProxy.cpp b/mozilla/xpinstall/src/nsXPIProxy.cpp index b272b882974..90116c425c0 100644 --- a/mozilla/xpinstall/src/nsXPIProxy.cpp +++ b/mozilla/xpinstall/src/nsXPIProxy.cpp @@ -30,6 +30,7 @@ #include "nsIDOMPluginArray.h" #include "nsIServiceManager.h" #include "nsIObserverService.h" +#include "nsObserverService.h" nsXPIProxy::nsXPIProxy() { @@ -71,7 +72,7 @@ nsXPIProxy::NotifyRestartNeeded() { nsCOMPtr obs(do_GetService(NS_OBSERVERSERVICE_CONTRACTID)); if (obs) - obs->Notify( nsnull, NS_LITERAL_STRING("xpinstall-restart").get(), nsnull ); + obs->NotifyObservers( nsnull, "xpinstall-restart", nsnull ); return NS_OK; }