зеркало из https://github.com/mozilla/pjs.git
Bug 560095 - Use mozilla::services::GetObserverService(). r=biesi,dveditz,gavin,josh,jst,mrbkap,roc,sdwilsh,shaver,sicking,smontagu,surkov
This commit is contained in:
Родитель
27830b44c2
Коммит
3d1b2b634a
|
@ -72,6 +72,7 @@
|
|||
#include "nsRootAccessible.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
/* For documentation of the accessibility architecture,
|
||||
* see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
|
||||
|
@ -281,14 +282,15 @@ void nsAccessNode::InitXPAccessibility()
|
|||
void nsAccessNode::NotifyA11yInitOrShutdown(PRBool aIsInit)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> obsService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
NS_ASSERTION(obsService, "No observer service to notify of a11y init/shutdown");
|
||||
if (obsService) {
|
||||
static const PRUnichar kInitIndicator[] = { '1', 0 };
|
||||
static const PRUnichar kShutdownIndicator[] = { '0', 0 };
|
||||
obsService->NotifyObservers(nsnull, "a11y-init-or-shutdown",
|
||||
aIsInit ? kInitIndicator : kShutdownIndicator);
|
||||
}
|
||||
if (!obsService)
|
||||
return;
|
||||
|
||||
static const PRUnichar kInitIndicator[] = { '1', 0 };
|
||||
static const PRUnichar kShutdownIndicator[] = { '0', 0 };
|
||||
obsService->NotifyObservers(nsnull, "a11y-init-or-shutdown",
|
||||
aIsInit ? kInitIndicator : kShutdownIndicator);
|
||||
}
|
||||
|
||||
void nsAccessNode::ShutdownXPAccessibility()
|
||||
|
|
|
@ -85,6 +85,7 @@
|
|||
#include "nsIWebProgress.h"
|
||||
#include "nsNetError.h"
|
||||
#include "nsDocShellLoadTypes.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
#include "nsXULAlertAccessible.h"
|
||||
|
@ -119,8 +120,8 @@ PRBool nsAccessibilityService::gIsShutdown = PR_TRUE;
|
|||
nsAccessibilityService::nsAccessibilityService()
|
||||
{
|
||||
// Add observers.
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return;
|
||||
|
||||
|
@ -155,11 +156,11 @@ nsAccessibilityService::Observe(nsISupports *aSubject, const char *aTopic,
|
|||
if (!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
|
||||
|
||||
// Remove observers.
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
if (observerService) {
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService)
|
||||
observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebProgress> progress(do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID));
|
||||
if (progress)
|
||||
progress->RemoveProgressListener(static_cast<nsIWebProgressListener*>(this));
|
||||
|
|
|
@ -1305,7 +1305,7 @@ nsAccessible::HandleAccEvent(nsAccEvent *aEvent)
|
|||
NS_ENSURE_TRUE(nsAccUtils::IsNodeRelevant(eventNode), NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIObserverService> obsService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
NS_ENSURE_TRUE(obsService, NS_ERROR_FAILURE);
|
||||
|
||||
return obsService->NotifyObservers(aEvent, NS_ACCESSIBLE_EVENT_TOPIC, nsnull);
|
||||
|
|
|
@ -524,7 +524,8 @@ nsChromeRegistry::Init()
|
|||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> obsService (do_GetService("@mozilla.org/observer-service;1"));
|
||||
nsCOMPtr<nsIObserverService> obsService =
|
||||
mozilla::services::GetObserverService();
|
||||
if (obsService) {
|
||||
obsService->AddObserver(this, "command-line-startup", PR_TRUE);
|
||||
obsService->AddObserver(this, "profile-initial-state", PR_TRUE);
|
||||
|
@ -904,7 +905,7 @@ void
|
|||
nsChromeRegistry::FlushSkinCaches()
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> obsSvc =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
NS_ASSERTION(obsSvc, "Couldn't get observer service.");
|
||||
|
||||
obsSvc->NotifyObservers(static_cast<nsIChromeRegistry*>(this),
|
||||
|
@ -1030,7 +1031,7 @@ void
|
|||
nsChromeRegistry::FlushAllCaches()
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> obsSvc =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
NS_ASSERTION(obsSvc, "Couldn't get observer service.");
|
||||
|
||||
obsSvc->NotifyObservers((nsIChromeRegistry*) this,
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "nsISHEntry.h"
|
||||
#include "nsISHContainer.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
static PRBool sInited = 0;
|
||||
PRUint32 nsCCUncollectableMarker::sGeneration = 0;
|
||||
|
@ -67,10 +68,12 @@ nsCCUncollectableMarker::Init()
|
|||
nsCOMPtr<nsIObserver> marker = new nsCCUncollectableMarker;
|
||||
NS_ENSURE_TRUE(marker, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mozilla::services::GetObserverService();
|
||||
if (!obs)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
// This makes the observer service hold an owning reference to the marker
|
||||
rv = obs->AddObserver(marker, "xpcom-shutdown", PR_FALSE);
|
||||
|
@ -186,12 +189,11 @@ nsresult
|
|||
nsCCUncollectableMarker::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
const PRUnichar* aData)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!strcmp(aTopic, "xpcom-shutdown")) {
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mozilla::services::GetObserverService();
|
||||
if (!obs)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// No need for kungFuDeathGrip here, yay observerservice!
|
||||
obs->RemoveObserver(this, "xpcom-shutdown");
|
||||
|
@ -209,6 +211,8 @@ nsCCUncollectableMarker::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
++sGeneration;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
|
||||
// Iterate all toplevel windows
|
||||
nsCOMPtr<nsISimpleEnumerator> windowList;
|
||||
nsCOMPtr<nsIWindowMediator> med =
|
||||
|
|
|
@ -3494,7 +3494,7 @@ void
|
|||
nsContentUtils::RegisterShutdownObserver(nsIObserver* aObserver)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService) {
|
||||
observerService->AddObserver(aObserver,
|
||||
NS_XPCOM_SHUTDOWN_OBSERVER_ID,
|
||||
|
@ -3507,7 +3507,7 @@ void
|
|||
nsContentUtils::UnregisterShutdownObserver(nsIObserver* aObserver)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService) {
|
||||
observerService->RemoveObserver(aObserver, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
|
||||
}
|
||||
|
|
|
@ -153,6 +153,7 @@
|
|||
#endif
|
||||
#include "nsIController.h"
|
||||
#include "nsICommandParams.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
#import <ApplicationServices/ApplicationServices.h>
|
||||
|
@ -272,10 +273,10 @@ NS_IMPL_ISUPPORTS1(nsUITimerCallback, nsITimerCallback)
|
|||
NS_IMETHODIMP
|
||||
nsUITimerCallback::Notify(nsITimer* aTimer)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mozilla::services::GetObserverService();
|
||||
if (!obs)
|
||||
return NS_ERROR_FAILURE;
|
||||
if ((gMouseOrKeyboardEventCounter == mPreviousCount) || !aTimer) {
|
||||
gMouseOrKeyboardEventCounter = 0;
|
||||
obs->NotifyObservers(nsnull, "user-interaction-inactive", nsnull);
|
||||
|
@ -789,10 +790,10 @@ nsEventStateManager::nsEventStateManager()
|
|||
NS_IMETHODIMP
|
||||
nsEventStateManager::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE);
|
||||
|
||||
|
@ -832,7 +833,7 @@ nsEventStateManager::Init()
|
|||
prefBranch->AddObserver("dom.popup_allowed_events", this, PR_TRUE);
|
||||
}
|
||||
|
||||
return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsEventStateManager::~nsEventStateManager()
|
||||
|
@ -861,11 +862,9 @@ nsEventStateManager::~nsEventStateManager()
|
|||
// gets called from xpcom shutdown observer. And we don't want to remove
|
||||
// from the service in that case.
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService) {
|
||||
observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
|
||||
}
|
||||
}
|
||||
|
@ -1047,7 +1046,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
|||
aEvent->eventStructType == NS_KEY_EVENT)) {
|
||||
if (gMouseOrKeyboardEventCounter == 0) {
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (obs) {
|
||||
obs->NotifyObservers(nsnull, "user-interaction-active", nsnull);
|
||||
}
|
||||
|
|
|
@ -295,10 +295,9 @@ nsHTMLDNSPrefetch::nsDeferrals::Activate()
|
|||
progress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_DOCUMENT);
|
||||
|
||||
// Register as an observer for xpcom shutdown events so we can drop any element refs
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService)
|
||||
observerService->AddObserver(this, "xpcom-shutdown", PR_TRUE);
|
||||
}
|
||||
|
||||
|
|
|
@ -906,16 +906,16 @@ nsHTMLFormElement::NotifySubmitObservers(nsIURI* aActionURL,
|
|||
}
|
||||
|
||||
// Notify observers that the form is being submitted.
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIObserverService> service =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mozilla::services::GetObserverService();
|
||||
if (!service)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> theEnum;
|
||||
rv = service->EnumerateObservers(aEarlyNotify ?
|
||||
NS_EARLYFORMSUBMIT_SUBJECT :
|
||||
NS_FORMSUBMIT_SUBJECT,
|
||||
getter_AddRefs(theEnum));
|
||||
nsresult rv = service->EnumerateObservers(aEarlyNotify ?
|
||||
NS_EARLYFORMSUBMIT_SUBJECT :
|
||||
NS_FORMSUBMIT_SUBJECT,
|
||||
getter_AddRefs(theEnum));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (theEnum) {
|
||||
|
|
|
@ -1321,7 +1321,7 @@ NS_NewXBLService(nsIXBLService** aResult)
|
|||
|
||||
// Register the first (and only) nsXBLService as a memory pressure observer
|
||||
// so it can flush the LRU list in low-memory situations.
|
||||
nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os)
|
||||
os->AddObserver(result, "memory-pressure", PR_TRUE);
|
||||
|
||||
|
|
|
@ -642,8 +642,8 @@ nsXULDocument::OnDocumentParserError()
|
|||
if (mCurrentPrototype && mMasterPrototype != mCurrentPrototype) {
|
||||
nsCOMPtr<nsIURI> uri = mCurrentPrototype->GetURI();
|
||||
if (IsChromeURI(uri)) {
|
||||
nsCOMPtr<nsIObserverService> os(
|
||||
do_GetService("@mozilla.org/observer-service;1"));
|
||||
nsCOMPtr<nsIObserverService> os =
|
||||
mozilla::services::GetObserverService();
|
||||
if (os)
|
||||
os->NotifyObservers(uri, "xul-overlay-parsererror",
|
||||
EmptyString().get());
|
||||
|
|
|
@ -140,7 +140,8 @@ NS_NewXULPrototypeCache(nsISupports* aOuter, REFNSIID aIID, void** aResult)
|
|||
|
||||
nsresult rv = result->QueryInterface(aIID, aResult);
|
||||
|
||||
nsCOMPtr<nsIObserverService> obsSvc(do_GetService("@mozilla.org/observer-service;1"));
|
||||
nsCOMPtr<nsIObserverService> obsSvc =
|
||||
mozilla::services::GetObserverService();
|
||||
if (obsSvc && NS_SUCCEEDED(rv)) {
|
||||
nsXULPrototypeCache *p = result;
|
||||
obsSvc->AddObserver(p, "chrome-flush-skin-caches", PR_FALSE);
|
||||
|
|
|
@ -10123,7 +10123,7 @@ nsDocShell::AddToGlobalHistory(nsIURI * aURI, PRBool aRedirect,
|
|||
|
||||
if (!visited) {
|
||||
nsCOMPtr<nsIObserverService> obsService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (obsService) {
|
||||
obsService->NotifyObservers(aURI, NS_LINK_VISITED_EVENT_TOPIC, nsnull);
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include "nsICacheService.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "prclist.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
// For calculating max history entries and max cachable contentviewers
|
||||
#include "nspr.h"
|
||||
|
@ -253,7 +254,7 @@ nsSHistory::Startup()
|
|||
obs, PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsIObserverService> obsSvc =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (obsSvc) {
|
||||
// Observe empty-cache notifications so tahat clearing the disk/memory
|
||||
// cache will also evict all content viewers.
|
||||
|
|
|
@ -75,8 +75,7 @@ nsDOMScriptObjectFactory::nsDOMScriptObjectFactory() :
|
|||
mLoadedAllLanguages(PR_FALSE)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService) {
|
||||
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
|
||||
}
|
||||
|
|
|
@ -680,8 +680,7 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow)
|
|||
mObserver = new nsGlobalWindowObserver(this);
|
||||
if (mObserver) {
|
||||
NS_ADDREF(mObserver);
|
||||
nsCOMPtr<nsIObserverService> os =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os) {
|
||||
// Watch for online/offline status changes so we can fire events. Use
|
||||
// a strong reference.
|
||||
|
@ -773,8 +772,7 @@ nsGlobalWindow::~nsGlobalWindow()
|
|||
#endif
|
||||
|
||||
if (mObserver) {
|
||||
nsCOMPtr<nsIObserverService> os =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os) {
|
||||
os->RemoveObserver(mObserver, NS_IOSERVICE_OFFLINE_STATUS_TOPIC);
|
||||
os->RemoveObserver(mObserver, "dom-storage2-changed");
|
||||
|
@ -2114,7 +2112,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService) {
|
||||
nsAutoString origin;
|
||||
nsIPrincipal* principal = aDocument->NodePrincipal();
|
||||
|
|
|
@ -277,8 +277,7 @@ nsUserActivityObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
sUserIsActive = PR_TRUE;
|
||||
higherProbability = (mUserActivityCounter > NS_CC_SOFT_LIMIT_ACTIVE);
|
||||
} else if (!strcmp(aTopic, "xpcom-shutdown")) {
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (obs) {
|
||||
obs->RemoveObserver(this, "user-interaction-active");
|
||||
obs->RemoveObserver(this, "user-interaction-inactive");
|
||||
|
@ -4020,9 +4019,9 @@ nsJSRuntime::Init()
|
|||
SetMemoryGCFrequencyPrefChangedCallback("javascript.options.mem.gc_frequency",
|
||||
nsnull);
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (!obs)
|
||||
return NS_ERROR_FAILURE;
|
||||
nsIObserver* activityObserver = new nsUserActivityObserver();
|
||||
NS_ENSURE_TRUE(activityObserver, NS_ERROR_OUT_OF_MEMORY);
|
||||
obs->AddObserver(activityObserver, "user-interaction-inactive", PR_FALSE);
|
||||
|
@ -4035,7 +4034,7 @@ nsJSRuntime::Init()
|
|||
|
||||
sIsInitialized = PR_TRUE;
|
||||
|
||||
return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//static
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch2.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
@ -383,7 +384,7 @@ nsresult nsGeolocationService::Init()
|
|||
return NS_ERROR_FAILURE;
|
||||
|
||||
// geolocation service can be enabled -> now register observer
|
||||
nsCOMPtr<nsIObserverService> obs = do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (!obs)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -439,7 +440,7 @@ nsGeolocationService::Observe(nsISupports* aSubject,
|
|||
{
|
||||
if (!strcmp("quit-application", aTopic))
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> obs = do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (obs) {
|
||||
obs->RemoveObserver(this, "quit-application");
|
||||
}
|
||||
|
|
|
@ -193,13 +193,14 @@ nsDOMOfflineResourceList::Init()
|
|||
}
|
||||
|
||||
// watch for new offline cache updates
|
||||
nsCOMPtr<nsIObserverService> observerServ =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = observerServ->AddObserver(this, "offline-cache-update-added", PR_TRUE);
|
||||
rv = observerService->AddObserver(this, "offline-cache-update-added", PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = observerServ->AddObserver(this, "offline-cache-update-completed", PR_TRUE);
|
||||
rv = observerService->AddObserver(this, "offline-cache-update-completed", PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mInitialized = PR_TRUE;
|
||||
|
|
|
@ -255,18 +255,19 @@ nsDOMStorageManager::Initialize()
|
|||
|
||||
NS_ADDREF(gStorageManager);
|
||||
|
||||
nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
|
||||
if (os) {
|
||||
os->AddObserver(gStorageManager, "cookie-changed", PR_FALSE);
|
||||
os->AddObserver(gStorageManager, "offline-app-removed", PR_FALSE);
|
||||
os->AddObserver(gStorageManager, NS_PRIVATE_BROWSING_SWITCH_TOPIC, PR_FALSE);
|
||||
os->AddObserver(gStorageManager, "perm-changed", PR_FALSE);
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (!os)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIPrivateBrowsingService> pbs =
|
||||
do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID);
|
||||
if (pbs)
|
||||
pbs->GetPrivateBrowsingEnabled(&gStorageManager->mInPrivateBrowsing);
|
||||
}
|
||||
os->AddObserver(gStorageManager, "cookie-changed", PR_FALSE);
|
||||
os->AddObserver(gStorageManager, "offline-app-removed", PR_FALSE);
|
||||
os->AddObserver(gStorageManager, NS_PRIVATE_BROWSING_SWITCH_TOPIC, PR_FALSE);
|
||||
os->AddObserver(gStorageManager, "perm-changed", PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsIPrivateBrowsingService> pbs =
|
||||
do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID);
|
||||
if (pbs)
|
||||
pbs->GetPrivateBrowsingEnabled(&gStorageManager->mInPrivateBrowsing);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1273,8 +1274,7 @@ nsDOMStorage::SetDBValue(const nsAString& aKey,
|
|||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> os =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
os->NotifyObservers(window, "dom-storage-warn-quota-exceeded",
|
||||
NS_ConvertUTF8toUTF16(mDomain).get());
|
||||
}
|
||||
|
@ -1423,10 +1423,9 @@ nsDOMStorage::BroadcastChangeNotification(const nsSubstring &aKey,
|
|||
const nsSubstring &aOldValue,
|
||||
const nsSubstring &aNewValue)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1616,8 +1615,8 @@ nsDOMStorage2::BroadcastChangeNotification(const nsSubstring &aKey,
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#include "nsFind.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#if DEBUG
|
||||
#include "nsIWebNavigation.h"
|
||||
|
@ -130,7 +131,7 @@ NS_IMETHODIMP nsWebBrowserFind::FindNext(PRBool *outDidFind)
|
|||
// this is used by nsTypeAheadFind, which controls find again when it was
|
||||
// the last executed find in the current window.
|
||||
nsCOMPtr<nsIObserverService> observerSvc =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerSvc) {
|
||||
nsCOMPtr<nsISupportsInterfacePointer> windowSupportsData =
|
||||
do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
|
||||
|
|
|
@ -839,10 +839,9 @@ nsWindowWatcher::OpenWindowJSInternal(nsIDOMWindow *aParent,
|
|||
// Notify observers that the window is open and ready.
|
||||
// The window has not yet started to load a document.
|
||||
nsCOMPtr<nsIObserverService> obsSvc =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
if (obsSvc) {
|
||||
mozilla::services::GetObserverService();
|
||||
if (obsSvc)
|
||||
obsSvc->NotifyObservers(*_retval, "toplevel-window-ready", nsnull);
|
||||
}
|
||||
}
|
||||
|
||||
// Now we have to set the right opener principal on the new window. Note
|
||||
|
@ -1016,17 +1015,18 @@ NS_IMETHODIMP
|
|||
nsWindowWatcher::RegisterNotification(nsIObserver *aObserver)
|
||||
{
|
||||
// just a convenience method; it delegates to nsIObserverService
|
||||
nsresult rv;
|
||||
|
||||
if (!aObserver)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1", &rv));
|
||||
if (os) {
|
||||
rv = os->AddObserver(aObserver, "domwindowopened", PR_FALSE);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = os->AddObserver(aObserver, "domwindowclosed", PR_FALSE);
|
||||
}
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (!os)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv = os->AddObserver(aObserver, "domwindowopened", PR_FALSE);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = os->AddObserver(aObserver, "domwindowclosed", PR_FALSE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -1034,17 +1034,18 @@ NS_IMETHODIMP
|
|||
nsWindowWatcher::UnregisterNotification(nsIObserver *aObserver)
|
||||
{
|
||||
// just a convenience method; it delegates to nsIObserverService
|
||||
nsresult rv;
|
||||
|
||||
if (!aObserver)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1", &rv));
|
||||
if (os) {
|
||||
os->RemoveObserver(aObserver, "domwindowopened");
|
||||
os->RemoveObserver(aObserver, "domwindowclosed");
|
||||
}
|
||||
return rv;
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (!os)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
os->RemoveObserver(aObserver, "domwindowopened");
|
||||
os->RemoveObserver(aObserver, "domwindowclosed");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1143,8 +1144,6 @@ nsWindowWatcher::SetActiveWindow(nsIDOMWindow *aActiveWindow)
|
|||
NS_IMETHODIMP
|
||||
nsWindowWatcher::AddWindow(nsIDOMWindow *aWindow, nsIWebBrowserChrome *aChrome)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!aWindow)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
|
@ -1188,13 +1187,12 @@ nsWindowWatcher::AddWindow(nsIDOMWindow *aWindow, nsIWebBrowserChrome *aChrome)
|
|||
|
||||
// a window being added to us signifies a newly opened window.
|
||||
// send notifications.
|
||||
nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1", &rv));
|
||||
if (os) {
|
||||
nsCOMPtr<nsISupports> domwin(do_QueryInterface(aWindow));
|
||||
rv = os->NotifyObservers(domwin, "domwindowopened", 0);
|
||||
}
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (!os)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return rv;
|
||||
nsCOMPtr<nsISupports> domwin(do_QueryInterface(aWindow));
|
||||
return os->NotifyObservers(domwin, "domwindowopened", 0);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1257,7 +1255,6 @@ nsresult nsWindowWatcher::RemoveWindow(nsWatcherWindowEntry *inInfo)
|
|||
{
|
||||
PRUint32 ctr,
|
||||
count = mEnumeratorList.Length();
|
||||
nsresult rv;
|
||||
|
||||
{
|
||||
// notify the enumerators
|
||||
|
@ -1273,16 +1270,16 @@ nsresult nsWindowWatcher::RemoveWindow(nsWatcherWindowEntry *inInfo)
|
|||
|
||||
// a window being removed from us signifies a newly closed window.
|
||||
// send notifications.
|
||||
nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1", &rv));
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os) {
|
||||
#ifdef USEWEAKREFS
|
||||
nsCOMPtr<nsISupports> domwin(do_QueryReferent(inInfo->mWindow));
|
||||
if (domwin)
|
||||
rv = os->NotifyObservers(domwin, "domwindowclosed", 0);
|
||||
os->NotifyObservers(domwin, "domwindowclosed", 0);
|
||||
// else bummer. since the window is gone, there's nothing to notify with.
|
||||
#else
|
||||
nsCOMPtr<nsISupports> domwin(do_QueryInterface(inInfo->mWindow));
|
||||
rv = os->NotifyObservers(domwin, "domwindowclosed", 0);
|
||||
os->NotifyObservers(domwin, "domwindowclosed", 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "nsIServiceManager.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsCRT.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#include "nsThebesDeviceContext.h"
|
||||
#include "nsThebesRenderingContext.h"
|
||||
|
@ -307,7 +308,7 @@ static PRBool DeleteValue(nsHashKey* aKey, void* aValue, void* closure)
|
|||
|
||||
nsThebesDeviceContext::~nsThebesDeviceContext()
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> obs(do_GetService("@mozilla.org/observer-service;1"));
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (obs)
|
||||
obs->RemoveObserver(this, "memory-pressure");
|
||||
|
||||
|
@ -709,7 +710,7 @@ nsThebesDeviceContext::Init(nsIWidget *aWidget)
|
|||
|
||||
// register as a memory-pressure observer to free font resources
|
||||
// in low-memory situations.
|
||||
nsCOMPtr<nsIObserverService> obs(do_GetService("@mozilla.org/observer-service;1"));
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (obs)
|
||||
obs->AddObserver(this, "memory-pressure", PR_TRUE);
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "nsWeakReference.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
static NS_DEFINE_CID(kCharsetAliasCID, NS_CHARSETALIAS_CID);
|
||||
|
||||
|
@ -203,13 +204,13 @@ NS_IMETHODIMP nsXMLEncodingObserver::Start()
|
|||
if (bXMLEncodingObserverStarted)
|
||||
return res;
|
||||
|
||||
nsCOMPtr<nsIObserverService> anObserverService = do_GetService("@mozilla.org/observer-service;1", &res);
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (!obs)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = anObserverService->AddObserver(this, "xmlparser", PR_TRUE);
|
||||
res = obs->AddObserver(this, "xmlparser", PR_TRUE);
|
||||
|
||||
bXMLEncodingObserverStarted = PR_TRUE;
|
||||
}
|
||||
bXMLEncodingObserverStarted = PR_TRUE;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -221,12 +222,13 @@ NS_IMETHODIMP nsXMLEncodingObserver::End()
|
|||
if (!bXMLEncodingObserverStarted)
|
||||
return res;
|
||||
|
||||
nsCOMPtr<nsIObserverService> anObserverService = do_GetService("@mozilla.org/observer-service;1", &res);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = anObserverService->RemoveObserver(this, "xmlparser");
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (!obs)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
bXMLEncodingObserverStarted = PR_FALSE;
|
||||
}
|
||||
res = obs->RemoveObserver(this, "xmlparser");
|
||||
|
||||
bXMLEncodingObserverStarted = PR_FALSE;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -582,7 +582,7 @@ nsStringBundleService::~nsStringBundleService()
|
|||
nsresult
|
||||
nsStringBundleService::Init()
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os) {
|
||||
os->AddObserver(this, "memory-pressure", PR_TRUE);
|
||||
os->AddObserver(this, "profile-do-change", PR_TRUE);
|
||||
|
|
|
@ -1647,8 +1647,7 @@ PresShell::Init(nsIDocument* aDocument,
|
|||
}
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> os =
|
||||
do_GetService("@mozilla.org/observer-service;1", &result);
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os) {
|
||||
os->AddObserver(this, "agent-sheet-added", PR_FALSE);
|
||||
os->AddObserver(this, "user-sheet-added", PR_FALSE);
|
||||
|
@ -1723,8 +1722,7 @@ PresShell::Destroy()
|
|||
}
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> os =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os) {
|
||||
os->RemoveObserver(this, "agent-sheet-added");
|
||||
os->RemoveObserver(this, "user-sheet-added");
|
||||
|
|
|
@ -151,7 +151,7 @@ nsStyleSheetService::LoadAndRegisterSheet(nsIURI *aSheetURI,
|
|||
const char* message = (aSheetType == AGENT_SHEET) ?
|
||||
"agent-sheet-added" : "user-sheet-added";
|
||||
nsCOMPtr<nsIObserverService> serv =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (serv) {
|
||||
// We're guaranteed that the new sheet is the last sheet in
|
||||
// mSheets[aSheetType]
|
||||
|
@ -212,10 +212,9 @@ nsStyleSheetService::UnregisterSheet(nsIURI *sheetURI, PRUint32 aSheetType)
|
|||
const char* message = (aSheetType == AGENT_SHEET) ?
|
||||
"agent-sheet-removed" : "user-sheet-removed";
|
||||
nsCOMPtr<nsIObserverService> serv =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
if (serv) {
|
||||
mozilla::services::GetObserverService();
|
||||
if (serv)
|
||||
serv->NotifyObservers(sheet, message, nsnull);
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -95,6 +95,7 @@
|
|||
#include "nsXULPopupManager.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsIContentUtils.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#include "nsIEventListenerService.h"
|
||||
// Transformiix stuff
|
||||
|
@ -355,7 +356,7 @@ Initialize(nsIModule* aSelf)
|
|||
|
||||
// Add our shutdown observer.
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
|
||||
if (observerService) {
|
||||
LayoutShutdownObserver* observer = new LayoutShutdownObserver();
|
||||
|
|
|
@ -90,6 +90,7 @@
|
|||
#include "nsIVariant.h"
|
||||
#include "nsIContentPrefService.h"
|
||||
#include "nsIContentURIGrouper.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#define SYNC_TEXT 0x1
|
||||
#define SYNC_BUTTON 0x2
|
||||
|
@ -493,7 +494,7 @@ void nsFileControlFrame::InitUploadLastDir() {
|
|||
NS_IF_ADDREF(gUploadLastDir);
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService && gUploadLastDir) {
|
||||
observerService->AddObserver(gUploadLastDir, NS_PRIVATE_BROWSING_SWITCH_TOPIC, PR_TRUE);
|
||||
observerService->AddObserver(gUploadLastDir, "browser:purge-session-history", PR_TRUE);
|
||||
|
@ -843,12 +844,10 @@ NS_IMETHODIMP nsFileControlFrame::GetAccessible(nsIAccessible** aAccessible)
|
|||
{
|
||||
// Accessible object exists just to hold onto its children, for later shutdown
|
||||
nsCOMPtr<nsIAccessibilityService> accService = do_GetService("@mozilla.org/accessibilityService;1");
|
||||
if (!accService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (accService) {
|
||||
return accService->CreateHTMLGenericAccessible(static_cast<nsIFrame*>(this), aAccessible);
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
return accService->CreateHTMLGenericAccessible(static_cast<nsIFrame*>(this), aAccessible);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1263,7 +1263,8 @@ nsObjectFrame::SetAbsoluteScreenPosition(nsIDOMElement* element,
|
|||
|
||||
nsresult
|
||||
nsObjectFrame::PluginEventNotifier::Run() {
|
||||
nsCOMPtr<nsIObserverService> obsSvc = do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> obsSvc =
|
||||
mozilla::services::GetObserverService();
|
||||
obsSvc->NotifyObservers(nsnull, "plugin-changed-event", mEventType.get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -579,12 +579,11 @@ nsGlyphTableList::Observe(nsISupports* aSubject,
|
|||
nsresult
|
||||
nsGlyphTableList::Initialize()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (!obs)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = obs->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
|
||||
nsresult rv = obs->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -596,11 +595,12 @@ nsGlyphTableList::Finalize()
|
|||
{
|
||||
// Remove our observer from the observer service
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (obs)
|
||||
rv = obs->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
||||
gInitialized = PR_FALSE;
|
||||
// our oneself will be destroyed when our |Release| is called by the observer
|
||||
return rv;
|
||||
|
|
|
@ -90,6 +90,7 @@
|
|||
#include "nsIObserverService.h"
|
||||
#include "nsIPrivateBrowsingService.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#define VISITED_PSEUDO_PREF "layout.css.visited_links_enabled"
|
||||
|
||||
|
@ -803,15 +804,15 @@ nsPrivateBrowsingObserver::Init()
|
|||
{
|
||||
nsCOMPtr<nsIPrivateBrowsingService> pbService =
|
||||
do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID);
|
||||
if (pbService) {
|
||||
pbService->GetPrivateBrowsingEnabled(&mInPrivateBrowsing);
|
||||
if (!pbService)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
if (observerService) {
|
||||
observerService->AddObserver(this, NS_PRIVATE_BROWSING_SWITCH_TOPIC, PR_TRUE);
|
||||
}
|
||||
}
|
||||
pbService->GetPrivateBrowsingEnabled(&mInPrivateBrowsing);
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService)
|
||||
observerService->AddObserver(this, NS_PRIVATE_BROWSING_SWITCH_TOPIC, PR_TRUE);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -164,7 +164,7 @@ nsLayoutStylesheetCache::Shutdown()
|
|||
nsLayoutStylesheetCache::nsLayoutStylesheetCache()
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> obsSvc =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
NS_ASSERTION(obsSvc, "No global observer service?");
|
||||
|
||||
if (obsSvc) {
|
||||
|
|
|
@ -665,9 +665,9 @@ imgCacheQueue & imgLoader::GetCacheQueue(nsIURI *aURI)
|
|||
nsresult imgLoader::InitCache()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (!os)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
gCacheObserver = new imgCacheObserver();
|
||||
if (!gCacheObserver)
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
|
||||
#include "plstr.h"
|
||||
#include "nsCRT.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#include "prefapi_private_data.h"
|
||||
|
||||
|
@ -89,8 +90,8 @@ nsPrefBranch::nsPrefBranch(const char *aPrefRoot, PRBool aDefaultBranch)
|
|||
mPrefRootLength = mPrefRoot.Length();
|
||||
mIsDefault = aDefaultBranch;
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService) {
|
||||
++mRefCnt; // Our refcnt must be > 0 when we call this, or we'll get deleted!
|
||||
// add weak so we don't have to clean up at shutdown
|
||||
|
|
|
@ -139,14 +139,15 @@ nsresult nsPrefService::Init()
|
|||
static_cast<nsISupports *>(static_cast<void *>(this)),
|
||||
"pref-config-startup");
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
if (observerService) {
|
||||
rv = observerService->AddObserver(this, "profile-before-change", PR_TRUE);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = observerService->AddObserver(this, "profile-do-change", PR_TRUE);
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = observerService->AddObserver(this, "profile-before-change", PR_TRUE);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = observerService->AddObserver(this, "profile-do-change", PR_TRUE);
|
||||
|
||||
return(rv);
|
||||
}
|
||||
|
@ -247,12 +248,10 @@ NS_IMETHODIMP nsPrefService::GetDefaultBranch(const char *aPrefRoot, nsIPrefBran
|
|||
|
||||
nsresult nsPrefService::NotifyServiceObservers(const char *aTopic)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
|
||||
if (NS_FAILED(rv) || !observerService)
|
||||
return rv;
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsISupports *subject = (nsISupports *)((nsIPrefService *)this);
|
||||
observerService->NotifyObservers(subject, aTopic, nsnull);
|
||||
|
@ -704,11 +703,10 @@ static nsresult pref_InitInitialObjects()
|
|||
NS_CreateServicesFromCategory(NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID,
|
||||
nsnull, NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID);
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
|
||||
if (NS_FAILED(rv) || !observerService)
|
||||
return rv;
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
observerService->NotifyObservers(nsnull, NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID, nsnull);
|
||||
|
||||
|
|
|
@ -195,7 +195,7 @@ void NS_NotifyPluginCall(PRIntervalTime startTime)
|
|||
{
|
||||
PRIntervalTime endTime = PR_IntervalNow() - startTime;
|
||||
nsCOMPtr<nsIObserverService> notifyUIService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (!notifyUIService)
|
||||
return;
|
||||
|
||||
|
|
|
@ -1533,7 +1533,8 @@ nsPluginHost::nsPluginHost()
|
|||
#endif
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> obsService = do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> obsService =
|
||||
mozilla::services::GetObserverService();
|
||||
if (obsService) {
|
||||
obsService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
|
||||
obsService->AddObserver(this, NS_PRIVATE_BROWSING_SWITCH_TOPIC, PR_FALSE);
|
||||
|
@ -3555,8 +3556,8 @@ NS_IMETHODIMP nsPluginHost::LoadPlugins()
|
|||
|
||||
// only if plugins have changed will we notify plugin-change observers
|
||||
if (pluginschanged) {
|
||||
nsCOMPtr<nsIObserverService>
|
||||
obsService(do_GetService("@mozilla.org/observer-service;1"));
|
||||
nsCOMPtr<nsIObserverService> obsService =
|
||||
mozilla::services::GetObserverService();
|
||||
if (obsService)
|
||||
obsService->NotifyObservers(nsnull, "plugins-list-updated", nsnull);
|
||||
}
|
||||
|
@ -5068,7 +5069,7 @@ nsPluginHost::PluginCrashed(nsNPAPIPlugin* aPlugin,
|
|||
// a crashreport.
|
||||
PRBool submittedCrashReport = PR_FALSE;
|
||||
nsCOMPtr<nsIObserverService> obsService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
nsCOMPtr<nsIWritablePropertyBag2> propbag =
|
||||
do_CreateInstance("@mozilla.org/hash-property-bag;1");
|
||||
if (obsService && propbag) {
|
||||
|
|
|
@ -229,7 +229,7 @@ nsIOService::Init()
|
|||
|
||||
// Register for profile change notifications
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService) {
|
||||
observerService->AddObserver(this, kProfileChangeNetTeardownTopic, PR_TRUE);
|
||||
observerService->AddObserver(this, kProfileChangeNetRestoreTopic, PR_TRUE);
|
||||
|
@ -665,7 +665,7 @@ nsIOService::SetOffline(PRBool offline)
|
|||
mSettingOffline = PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
|
||||
while (mSetOfflineValue != mOffline) {
|
||||
offline = mSetOfflineValue;
|
||||
|
|
|
@ -126,7 +126,7 @@ nsIOThreadPool::Init()
|
|||
PR_INIT_CLIST(&mEventQ);
|
||||
|
||||
// We want to shutdown the i/o thread pool at xpcom-shutdown-threads time.
|
||||
nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os)
|
||||
os->AddObserver(this, "xpcom-shutdown-threads", PR_FALSE);
|
||||
return NS_OK;
|
||||
|
|
|
@ -504,8 +504,7 @@ nsIncrementalDownload::Start(nsIRequestObserver *observer,
|
|||
// between ourselves and the timer. We have the observer service hold a weak
|
||||
// reference to us, so that we don't have to worry about calling
|
||||
// RemoveObserver. XXX(darin): The timer code should do this for us.
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (obs)
|
||||
obs->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE);
|
||||
|
||||
|
|
|
@ -338,8 +338,7 @@ nsProtocolProxyService::Init()
|
|||
}
|
||||
|
||||
// register for shutdown notification so we can clean ourselves up properly.
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (obs)
|
||||
obs->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "nsITransport.h"
|
||||
#include "nsIRunnable.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsInputStreamTransport
|
||||
|
@ -481,7 +482,7 @@ nsStreamTransportService::Init()
|
|||
mPool->SetIdleThreadTimeout(PR_SecondsToInterval(60));
|
||||
|
||||
nsCOMPtr<nsIObserverService> obsSvc =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (obsSvc)
|
||||
obsSvc->AddObserver(this, "xpcom-shutdown-threads", PR_FALSE);
|
||||
return NS_OK;
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
#include "nsIPrivateBrowsingService.h"
|
||||
#include "nsNetCID.h"
|
||||
#include <math.h> // for log()
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -174,13 +175,13 @@ NS_IMPL_ISUPPORTS1(nsCacheProfilePrefObserver, nsIObserver)
|
|||
nsresult
|
||||
nsCacheProfilePrefObserver::Install()
|
||||
{
|
||||
nsresult rv, rv2 = NS_OK;
|
||||
|
||||
// install profile-change observer
|
||||
nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_ARG(observerService);
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv, rv2 = NS_OK;
|
||||
for (unsigned int i=0; i<NS_ARRAY_LENGTH(observerList); i++) {
|
||||
rv = observerService->AddObserver(this, observerList[i], PR_FALSE);
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -210,12 +211,11 @@ nsCacheProfilePrefObserver::Install()
|
|||
// In that case, we detect the presence of a profile by the existence
|
||||
// of the NS_APP_USER_PROFILE_50_DIR directory.
|
||||
|
||||
nsCOMPtr<nsIFile> directory;
|
||||
nsCOMPtr<nsIFile> directory;
|
||||
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
|
||||
getter_AddRefs(directory));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mHaveProfile = PR_TRUE;
|
||||
}
|
||||
|
||||
rv = ReadPrefs(branch);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -229,7 +229,7 @@ nsCacheProfilePrefObserver::Remove()
|
|||
{
|
||||
// remove Observer Service observers
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (obs) {
|
||||
for (unsigned int i=0; i<NS_ARRAY_LENGTH(observerList); i++) {
|
||||
obs->RemoveObserver(this, observerList[i]);
|
||||
|
@ -238,13 +238,11 @@ nsCacheProfilePrefObserver::Remove()
|
|||
|
||||
// remove Pref Service observers
|
||||
nsCOMPtr<nsIPrefBranch2> prefs =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (prefs) {
|
||||
for (unsigned int i=0; i<NS_ARRAY_LENGTH(prefList); i++) {
|
||||
// remove cache pref observers
|
||||
prefs->RemoveObserver(prefList[i], this);
|
||||
}
|
||||
}
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (!prefs)
|
||||
return;
|
||||
for (unsigned int i=0; i<NS_ARRAY_LENGTH(prefList); i++)
|
||||
prefs->RemoveObserver(prefList[i], this); // remove cache pref observers
|
||||
}
|
||||
|
||||
|
||||
|
@ -794,7 +792,7 @@ nsCacheService::EvictEntriesForClient(const char * clientID,
|
|||
if (this == nsnull) return NS_ERROR_NOT_AVAILABLE; // XXX eh?
|
||||
|
||||
nsCOMPtr<nsIObserverService> obsSvc =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (obsSvc) {
|
||||
// Proxy to the UI thread since the observer service isn't thredsafe.
|
||||
// We use an async proxy, since this it's not important whether this
|
||||
|
|
|
@ -545,7 +545,7 @@ nsCookieService::Init()
|
|||
if (NS_FAILED(rv))
|
||||
COOKIE_LOGSTRING(PR_LOG_WARNING, ("Init(): InitDB() gave error %x", rv));
|
||||
|
||||
mObserverService = do_GetService("@mozilla.org/observer-service;1");
|
||||
mObserverService = mozilla::services::GetObserverService();
|
||||
if (mObserverService) {
|
||||
mObserverService->AddObserver(this, "profile-before-change", PR_TRUE);
|
||||
mObserverService->AddObserver(this, "profile-do-change", PR_TRUE);
|
||||
|
|
|
@ -123,9 +123,8 @@ NS_IMPL_THREADSAFE_ISUPPORTS4(nsFtpProtocolHandler,
|
|||
nsresult
|
||||
nsFtpProtocolHandler::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (mIdleTimeout == -1) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrefBranch2> branch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
@ -138,7 +137,7 @@ nsFtpProtocolHandler::Init()
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService) {
|
||||
observerService->AddObserver(this,
|
||||
"network:offline-about-to-go-offline",
|
||||
|
|
|
@ -291,7 +291,7 @@ nsHttpHandler::Init()
|
|||
static_cast<nsISupports*>(static_cast<void*>(this)),
|
||||
NS_HTTP_STARTUP_TOPIC);
|
||||
|
||||
mObserverService = do_GetService("@mozilla.org/observer-service;1");
|
||||
mObserverService = mozilla::services::GetObserverService();
|
||||
if (mObserverService) {
|
||||
mObserverService->AddObserver(this, "profile-change-net-teardown", PR_TRUE);
|
||||
mObserverService->AddObserver(this, "profile-change-net-restore", PR_TRUE);
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsMaemoNetworkManager.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsMaemoNetworkLinkService,
|
||||
nsINetworkLinkService,
|
||||
|
@ -70,13 +71,12 @@ nsMaemoNetworkLinkService::Observe(nsISupports *aSubject,
|
|||
nsresult
|
||||
nsMaemoNetworkLinkService::Init(void)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = observerService->AddObserver(this, "xpcom-shutdown", PR_FALSE);
|
||||
nsresult rv = observerService->AddObserver(this, "xpcom-shutdown", PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!nsMaemoNetworkManager::Startup())
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "nsNotifyAddrListener.h"
|
||||
#include "nsString.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#include <iptypes.h>
|
||||
#include <iphlpapi.h>
|
||||
|
@ -229,13 +230,13 @@ nsNotifyAddrListener::Init(void)
|
|||
mOSVerInfo.dwMajorVersion < 5)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = observerService->AddObserver(this, "xpcom-shutdown-threads",
|
||||
PR_FALSE);
|
||||
nsresult rv = observerService->AddObserver(this, "xpcom-shutdown-threads",
|
||||
PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mShutdownEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
|
@ -252,7 +253,7 @@ nsNotifyAddrListener::Shutdown(void)
|
|||
{
|
||||
// remove xpcom shutdown observer
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService)
|
||||
observerService->RemoveObserver(this, "xpcom-shutdown-threads");
|
||||
|
||||
|
@ -294,7 +295,7 @@ NS_IMETHODIMP
|
|||
nsNotifyAddrListener::ChangeEvent::Run()
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService)
|
||||
observerService->NotifyObservers(
|
||||
mService, NS_NETWORK_LINK_TOPIC,
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "nsIProxyObjectManager.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#if defined(PR_LOGGING)
|
||||
PRLogModuleInfo *gWifiMonitorLog;
|
||||
|
@ -71,7 +72,7 @@ nsWifiMonitor::nsWifiMonitor()
|
|||
|
||||
mMonitor = nsAutoMonitor::NewMonitor("nsWifiMonitor");
|
||||
|
||||
nsCOMPtr<nsIObserverService> obsSvc = do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();
|
||||
if (obsSvc)
|
||||
obsSvc->AddObserver(this, "xpcom-shutdown", PR_FALSE);
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "nsHtml5Module.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
// static
|
||||
PRBool nsHtml5Module::sEnabled = PR_FALSE;
|
||||
|
@ -147,7 +148,7 @@ nsHtml5Module::GetStreamParserThread()
|
|||
if (!sStreamParserThread) {
|
||||
NS_NewThread(&sStreamParserThread);
|
||||
NS_ASSERTION(sStreamParserThread, "Thread creation failed!");
|
||||
nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
NS_ASSERTION(os, "do_GetService failed");
|
||||
os->AddObserver(new nsHtml5ParserThreadTerminator(sStreamParserThread),
|
||||
"xpcom-shutdown-threads",
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "nsISupportsUtils.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
// File Name Defines
|
||||
|
||||
|
@ -127,7 +128,7 @@ nsProfileDirServiceProvider::SetProfileDir(nsIFile* aProfileDir,
|
|||
|
||||
if (mNotifyObservers) {
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -158,7 +159,7 @@ nsProfileDirServiceProvider::Shutdown()
|
|||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "nsILocaleService.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#include "sqlite3.h"
|
||||
|
||||
|
@ -170,7 +171,7 @@ Service::initialize()
|
|||
return convertResultCode(rc);
|
||||
|
||||
nsCOMPtr<nsIObserverService> os =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
NS_ENSURE_TRUE(os, NS_ERROR_FAILURE);
|
||||
|
||||
nsresult rv = os->AddObserver(this, "xpcom-shutdown", PR_FALSE);
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "nsIGenericFactory.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIDOMKeyEvent.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
static const char *kAutoCompleteSearchCID = "@mozilla.org/autocomplete/search;1?name=";
|
||||
|
||||
|
@ -1133,7 +1134,7 @@ nsAutoCompleteController::EnterMatch(PRBool aIsPopupSelection)
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> obsSvc =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
NS_ENSURE_STATE(obsSvc);
|
||||
obsSvc->NotifyObservers(input, "autocomplete-will-enter-text", nsnull);
|
||||
|
||||
|
@ -1169,7 +1170,7 @@ nsAutoCompleteController::RevertTextValue()
|
|||
|
||||
if (!cancel) {
|
||||
nsCOMPtr<nsIObserverService> obsSvc =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
NS_ENSURE_STATE(obsSvc);
|
||||
obsSvc->NotifyObservers(input, "autocomplete-will-revert-text", nsnull);
|
||||
|
||||
|
|
|
@ -842,9 +842,11 @@ nsDownloadManager::Init()
|
|||
}
|
||||
}
|
||||
|
||||
mObserverService = mozilla::services::GetObserverService();
|
||||
if (!mObserverService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv;
|
||||
mObserverService = do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIStringBundleService> bundleService =
|
||||
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
|
||||
|
|
|
@ -1060,7 +1060,7 @@ ExpireFaviconsStatementCallbackNotifier::HandleCompletion(PRUint16 aReason)
|
|||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService) {
|
||||
(void)observerService->NotifyObservers(nsnull,
|
||||
NS_PLACES_FAVICONS_EXPIRED_TOPIC_ID,
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
#include "nsIMutableArray.h"
|
||||
#include "nsIPrivateBrowsingService.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#define DB_SCHEMA_VERSION 3
|
||||
#define DB_FILENAME NS_LITERAL_STRING("formhistory.sqlite")
|
||||
|
@ -141,7 +142,7 @@ nsFormHistory::Init()
|
|||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mObserverService = do_GetService("@mozilla.org/observer-service;1");
|
||||
mObserverService = mozilla::services::GetObserverService();
|
||||
if (mObserverService) {
|
||||
mObserverService->AddObserver(this, NS_EARLYFORMSUBMIT_SUBJECT, PR_TRUE);
|
||||
mObserverService->AddObserver(this, "idle-daily", PR_TRUE);
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsAppShellCID.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
|
||||
|
@ -111,9 +112,10 @@ nsAppStartup::Init()
|
|||
mAppShell = do_GetService(kAppShellCID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIObserverService> os
|
||||
(do_GetService("@mozilla.org/observer-service;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIObserverService> os =
|
||||
mozilla::services::GetObserverService();
|
||||
if (!os)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
os->AddObserver(this, "quit-application-forced", PR_TRUE);
|
||||
os->AddObserver(this, "profile-change-teardown", PR_TRUE);
|
||||
|
@ -256,7 +258,7 @@ nsAppStartup::Quit(PRUint32 aMode)
|
|||
if (!mRestart)
|
||||
mRestart = (aMode & eRestart) != 0;
|
||||
|
||||
obsService = do_GetService("@mozilla.org/observer-service;1");
|
||||
obsService = mozilla::services::GetObserverService();
|
||||
|
||||
if (!mAttemptingQuit) {
|
||||
mAttemptingQuit = PR_TRUE;
|
||||
|
|
|
@ -3948,7 +3948,7 @@ nsUrlClassifierDBService::Init()
|
|||
|
||||
// Add an observer for shutdown
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ nsUrlClassifierHashCompleterRequest::Begin()
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService)
|
||||
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
|
||||
|
||||
|
@ -471,7 +471,7 @@ nsUrlClassifierHashCompleterRequest::OnStopRequest(nsIRequest *request,
|
|||
this, status));
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService)
|
||||
observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
|
||||
|
||||
|
@ -537,7 +537,7 @@ nsUrlClassifierHashCompleter::Init()
|
|||
#endif
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService)
|
||||
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE);
|
||||
|
||||
|
@ -673,17 +673,14 @@ nsUrlClassifierHashCompleter::RekeyRequested()
|
|||
// Notify the key manager that we need a new key. Until we get a
|
||||
// new key, gethash requests will be unauthenticated (and therefore
|
||||
// uncacheable).
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = observerService->NotifyObservers(static_cast<nsIUrlClassifierHashCompleter*>(this),
|
||||
"url-classifier-rekey-requested",
|
||||
nsnull);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
return observerService->NotifyObservers(static_cast<nsIUrlClassifierHashCompleter*>(this),
|
||||
"url-classifier-rekey-requested",
|
||||
nsnull);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -212,7 +212,7 @@ nsUrlClassifierStreamUpdater::DownloadUpdates(
|
|||
// downloads. quit-application is the same event that the download
|
||||
// manager listens for and uses to cancel pending downloads.
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -274,10 +274,11 @@ nsUrlClassifierStreamUpdater::UpdateUrlRequested(const nsACString &aUrl,
|
|||
NS_IMETHODIMP
|
||||
nsUrlClassifierStreamUpdater::RekeyRequested()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mozilla::services::GetObserverService();
|
||||
|
||||
if (!observerService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return observerService->NotifyObservers(static_cast<nsIUrlClassifierStreamUpdater*>(this),
|
||||
"url-classifier-rekey-requested",
|
||||
|
|
|
@ -3438,8 +3438,8 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
|||
|
||||
/* Special-case services that need early access to the command
|
||||
line. */
|
||||
nsCOMPtr<nsIObserverService> obsService
|
||||
(do_GetService("@mozilla.org/observer-service;1"));
|
||||
nsCOMPtr<nsIObserverService> obsService =
|
||||
mozilla::services::GetObserverService();
|
||||
if (obsService) {
|
||||
obsService->NotifyObservers(cmdLine, "command-line-startup", nsnull);
|
||||
}
|
||||
|
@ -3524,8 +3524,8 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
|||
|
||||
MOZ_SPLASHSCREEN_UPDATE(70);
|
||||
|
||||
nsCOMPtr<nsIObserverService> obsService
|
||||
(do_GetService("@mozilla.org/observer-service;1"));
|
||||
nsCOMPtr<nsIObserverService> obsService =
|
||||
mozilla::services::GetObserverService();
|
||||
if (obsService)
|
||||
obsService->NotifyObservers(nsnull, "final-ui-startup", nsnull);
|
||||
|
||||
|
|
|
@ -1012,8 +1012,7 @@ NS_IMETHODIMP
|
|||
nsNativeAppSupportOS2::Enable()
|
||||
{
|
||||
mCanHandleRequests = PR_TRUE;
|
||||
nsCOMPtr<nsIObserverService> obs
|
||||
(do_GetService("@mozilla.org/observer-service;1"));
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (obs) {
|
||||
obs->AddObserver(this, "quit-application", PR_FALSE);
|
||||
} else {
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "nsIWidget.h"
|
||||
#include "nsIWritablePropertyBag2.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
|
@ -129,7 +130,7 @@ gboolean save_yourself_cb(GnomeClient *client, gint phase,
|
|||
gpointer user_data)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> obsServ =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
|
||||
nsCOMPtr<nsISupportsPRBool> didSaveSession =
|
||||
do_CreateInstance(NS_SUPPORTS_PRBOOL_CONTRACTID);
|
||||
|
@ -297,7 +298,7 @@ static void OssoRequestAccelerometer(osso_context_t *ctx, PRBool aEnabled)
|
|||
|
||||
static void OssoDisplayCallback(osso_display_state_t state, gpointer data)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (!os)
|
||||
return;
|
||||
|
||||
|
@ -326,16 +327,14 @@ static void OssoHardwareCallback(osso_hw_state_t *state, gpointer data)
|
|||
return;
|
||||
}
|
||||
|
||||
if (state->memory_low_ind) {
|
||||
if (! ourState->memory_low_ind) {
|
||||
nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
|
||||
if (os)
|
||||
os->NotifyObservers(nsnull, "memory-pressure", NS_LITERAL_STRING("low-memory").get());
|
||||
}
|
||||
if (state->memory_low_ind && !ourState->memory_low_ind) {
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os)
|
||||
os->NotifyObservers(nsnull, "memory-pressure", NS_LITERAL_STRING("low-memory").get());
|
||||
}
|
||||
|
||||
if (state->system_inactivity_ind != ourState->system_inactivity_ind) {
|
||||
nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (!os)
|
||||
return;
|
||||
|
||||
|
|
|
@ -862,8 +862,7 @@ nsNativeAppSupportWin::Enable()
|
|||
{
|
||||
mCanHandleRequests = PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs
|
||||
(do_GetService("@mozilla.org/observer-service;1"));
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (obs) {
|
||||
obs->AddObserver(this, "quit-application", PR_FALSE);
|
||||
} else {
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
#include "nsArrayEnumerator.h"
|
||||
#include "nsEnumeratorUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -800,8 +801,8 @@ NS_IMETHODIMP
|
|||
nsXREDirProvider::DoStartup()
|
||||
{
|
||||
if (!mProfileNotified) {
|
||||
nsCOMPtr<nsIObserverService> obsSvc
|
||||
(do_GetService("@mozilla.org/observer-service;1"));
|
||||
nsCOMPtr<nsIObserverService> obsSvc =
|
||||
mozilla::services::GetObserverService();
|
||||
if (!obsSvc) return NS_ERROR_FAILURE;
|
||||
|
||||
mProfileNotified = PR_TRUE;
|
||||
|
@ -850,15 +851,15 @@ void
|
|||
nsXREDirProvider::DoShutdown()
|
||||
{
|
||||
if (mProfileNotified) {
|
||||
nsCOMPtr<nsIObserverService> obssvc
|
||||
(do_GetService("@mozilla.org/observer-service;1"));
|
||||
NS_ASSERTION(obssvc, "No observer service?");
|
||||
if (obssvc) {
|
||||
nsCOMPtr<nsIObserverService> obsSvc =
|
||||
mozilla::services::GetObserverService();
|
||||
NS_ASSERTION(obsSvc, "No observer service?");
|
||||
if (obsSvc) {
|
||||
nsCOMPtr<nsIProfileChangeStatus> cs = new ProfileChangeStatusImpl();
|
||||
static const PRUnichar kShutdownPersist[] =
|
||||
{'s','h','u','t','d','o','w','n','-','p','e','r','s','i','s','t','\0'};
|
||||
obssvc->NotifyObservers(cs, "profile-change-net-teardown", kShutdownPersist);
|
||||
obssvc->NotifyObservers(cs, "profile-change-teardown", kShutdownPersist);
|
||||
obsSvc->NotifyObservers(cs, "profile-change-net-teardown", kShutdownPersist);
|
||||
obsSvc->NotifyObservers(cs, "profile-change-teardown", kShutdownPersist);
|
||||
|
||||
// Phase 2c: Now that things are torn down, force JS GC so that things which depend on
|
||||
// resources which are about to go away in "profile-before-change" are destroyed first.
|
||||
|
@ -873,7 +874,7 @@ nsXREDirProvider::DoShutdown()
|
|||
}
|
||||
|
||||
// Phase 3: Notify observers of a profile change
|
||||
obssvc->NotifyObservers(cs, "profile-before-change", kShutdownPersist);
|
||||
obsSvc->NotifyObservers(cs, "profile-before-change", kShutdownPersist);
|
||||
}
|
||||
mProfileNotified = PR_FALSE;
|
||||
}
|
||||
|
|
|
@ -580,9 +580,9 @@ nsresult nsExternalHelperAppService::Init()
|
|||
}
|
||||
|
||||
// Add an observer for profile change
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIObserverService> obs = do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (!obs)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
if (!mLog) {
|
||||
|
@ -592,7 +592,7 @@ nsresult nsExternalHelperAppService::Init()
|
|||
}
|
||||
#endif
|
||||
|
||||
rv = obs->AddObserver(this, "profile-before-change", PR_TRUE);
|
||||
nsresult rv = obs->AddObserver(this, "profile-before-change", PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return obs->AddObserver(this, NS_PRIVATE_BROWSING_SWITCH_TOPIC, PR_TRUE);
|
||||
}
|
||||
|
|
|
@ -2342,8 +2342,6 @@ nsOfflineCacheUpdateService::~nsOfflineCacheUpdateService()
|
|||
nsresult
|
||||
nsOfflineCacheUpdateService::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
#if defined(PR_LOGGING)
|
||||
if (!gOfflineCacheUpdateLog)
|
||||
gOfflineCacheUpdateLog = PR_NewLogModule("nsOfflineCacheUpdate");
|
||||
|
@ -2351,12 +2349,13 @@ nsOfflineCacheUpdateService::Init()
|
|||
|
||||
// Observe xpcom-shutdown event
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = observerService->AddObserver(this,
|
||||
NS_XPCOM_SHUTDOWN_OBSERVER_ID,
|
||||
PR_TRUE);
|
||||
nsresult rv = observerService->AddObserver(this,
|
||||
NS_XPCOM_SHUTDOWN_OBSERVER_ID,
|
||||
PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
gOfflineCacheUpdateService = this;
|
||||
|
@ -2407,10 +2406,10 @@ nsOfflineCacheUpdateService::Schedule(nsOfflineCacheUpdate *aUpdate)
|
|||
|
||||
aUpdate->SetOwner(this);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
observerService->NotifyObservers(static_cast<nsIOfflineCacheUpdate*>(aUpdate),
|
||||
"offline-cache-update-added",
|
||||
|
@ -2466,10 +2465,10 @@ nsOfflineCacheUpdateService::UpdateFinished(nsOfflineCacheUpdate *aUpdate)
|
|||
mUpdates.RemoveElementAt(0);
|
||||
mUpdateRunning = PR_FALSE;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
observerService->NotifyObservers(static_cast<nsIOfflineCacheUpdate*>(aUpdate),
|
||||
"offline-cache-update-completed",
|
||||
|
|
|
@ -441,12 +441,13 @@ nsPrefetchService::Init()
|
|||
}
|
||||
|
||||
// Observe xpcom-shutdown event
|
||||
nsCOMPtr<nsIObserverService> observerServ(
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = observerServ->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!mDisabled)
|
||||
AddProgressListener();
|
||||
|
@ -486,11 +487,10 @@ nsPrefetchService::ProcessNextURI()
|
|||
void
|
||||
nsPrefetchService::NotifyLoadRequested(nsPrefetchNode *node)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
if (NS_FAILED(rv)) return;
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return;
|
||||
|
||||
observerService->NotifyObservers(static_cast<nsIDOMLoadStatus*>(node),
|
||||
"prefetch-load-requested", nsnull);
|
||||
|
@ -499,11 +499,10 @@ nsPrefetchService::NotifyLoadRequested(nsPrefetchNode *node)
|
|||
void
|
||||
nsPrefetchService::NotifyLoadCompleted(nsPrefetchNode *node)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
if (NS_FAILED(rv)) return;
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return;
|
||||
|
||||
observerService->NotifyObservers(static_cast<nsIDOMLoadStatus*>(node),
|
||||
"prefetch-load-completed", nsnull);
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "nsImageToPixbuf.h"
|
||||
#include "nsStringStream.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#include "imgIContainer.h"
|
||||
|
||||
|
@ -141,10 +142,9 @@ NS_IMPL_ISUPPORTS1(nsClipboard, nsIClipboard)
|
|||
nsresult
|
||||
nsClipboard::Init(void)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIObserverService> os
|
||||
(do_GetService("@mozilla.org/observer-service;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (!os)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
os->AddObserver(this, "quit-application", PR_FALSE);
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include "nsCRT.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#include "gfxASurface.h"
|
||||
#include "gfxXlibSurface.h"
|
||||
|
@ -112,7 +113,7 @@ nsDragService::nsDragService()
|
|||
// We have to destroy the hidden widget before the event loop stops
|
||||
// running.
|
||||
nsCOMPtr<nsIObserverService> obsServ =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
obsServ->AddObserver(this, "quit-application", PR_FALSE);
|
||||
|
||||
// our hidden source widget
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#ifdef MOZ_PLATFORM_MAEMO
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "mozilla/Services.h"
|
||||
#endif
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
|
@ -587,7 +588,7 @@ nsGtkIMModule::SetIMEEnabled(nsWindow* aCaller, PRUint32 aState)
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService) {
|
||||
nsAutoString rectBuf;
|
||||
PRInt32 x, y, w, h;
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsIDOMNSHTMLInputElement.h"
|
||||
#include "nsWidgetAtoms.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#include <gdk/gdkprivate.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
@ -82,7 +83,7 @@ nsNativeThemeGTK::nsNativeThemeGTK()
|
|||
|
||||
// We have to call moz_gtk_shutdown before the event loop stops running.
|
||||
nsCOMPtr<nsIObserverService> obsServ =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
obsServ->AddObserver(this, "xpcom-shutdown", PR_FALSE);
|
||||
|
||||
memset(mDisabledWidgetTypes, 0, sizeof(mDisabledWidgetTypes));
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "nsIServiceManager.h"
|
||||
#include "nsOS2Uni.h"
|
||||
#include "nsClipboard.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
inline ULONG RegisterClipboardFormat(PCSZ pcszFormat)
|
||||
{
|
||||
|
@ -75,7 +76,7 @@ nsClipboard::nsClipboard() : nsBaseClipboard()
|
|||
// Register for a shutdown notification so that we can flush data
|
||||
// to the OS clipboard.
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService)
|
||||
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "nsLiteralString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#define INCL_WIN
|
||||
#define INCL_DOS
|
||||
|
@ -1224,7 +1225,7 @@ static nsresult nsRwsServiceInit(nsRwsService **aClass)
|
|||
NS_ADDREF(*aClass);
|
||||
|
||||
// set the class up as a shutdown observer
|
||||
nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os)
|
||||
os->AddObserver(*aClass, "quit-application", PR_FALSE);
|
||||
|
||||
|
|
|
@ -154,6 +154,7 @@
|
|||
#include "nsTHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#if defined(WINCE)
|
||||
#include "nsWindowCE.h"
|
||||
|
@ -4083,7 +4084,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
|
|||
// Ask if it's ok to quit, and store the answer until we
|
||||
// get WM_ENDSESSION signaling the round is complete.
|
||||
nsCOMPtr<nsIObserverService> obsServ =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
nsCOMPtr<nsISupportsPRBool> cancelQuit =
|
||||
do_CreateInstance(NS_SUPPORTS_PRBOOL_CONTRACTID);
|
||||
cancelQuit->SetData(PR_FALSE);
|
||||
|
@ -4109,7 +4110,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
|
|||
// require having a chance to pump some messages. Unfortunately
|
||||
// Windows won't let us do that. Bug 212316.
|
||||
nsCOMPtr<nsIObserverService> obsServ =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
NS_NAMED_LITERAL_STRING(context, "shutdown-persist");
|
||||
obsServ->NotifyObservers(nsnull, "quit-application-granted", nsnull);
|
||||
obsServ->NotifyObservers(nsnull, "quit-application-forced", nsnull);
|
||||
|
@ -4998,11 +4999,10 @@ void nsWindow::GlobalMsgWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
|
|||
#ifndef WINCE
|
||||
void nsWindow::PostSleepWakeNotification(const char* aNotification)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService)
|
||||
{
|
||||
observerService->NotifyObservers(nsnull, aNotification, nsnull);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "nsThreadUtils.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#ifdef MOZ_IPC
|
||||
#include "base/message_loop.h"
|
||||
|
@ -81,7 +82,7 @@ nsBaseAppShell::Init()
|
|||
threadInt->SetObserver(this);
|
||||
|
||||
nsCOMPtr<nsIObserverService> obsSvc =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
if (obsSvc)
|
||||
obsSvc->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
|
||||
return NS_OK;
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "nsLiteralString.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsXPCOM.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#if defined(XP_WIN) && !defined(WINCE)
|
||||
#include <ole2.h>
|
||||
|
@ -58,12 +59,12 @@ NS_IMPL_ISUPPORTS2(nsClipboardPrivacyHandler, nsIObserver, nsISupportsWeakRefere
|
|||
nsresult
|
||||
nsClipboardPrivacyHandler::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = observerService->AddObserver(this, NS_PRIVATE_BROWSING_SWITCH_TOPIC, PR_TRUE);
|
||||
return rv;
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return NS_ERROR_FAILURE;
|
||||
return observerService->AddObserver(this, NS_PRIVATE_BROWSING_SWITCH_TOPIC,
|
||||
PR_TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "nsDebug.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "prinrval.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
// observer topics used:
|
||||
#define OBSERVER_TOPIC_IDLE "idle"
|
||||
|
@ -80,7 +81,7 @@ nsIdleServiceDaily::Observe(nsISupports *,
|
|||
{
|
||||
// Notify anyone who cares.
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
|
||||
observerService->NotifyObservers(nsnull,
|
||||
OBSERVER_TOPIC_IDLE_DAILY,
|
||||
|
|
|
@ -144,6 +144,7 @@
|
|||
#include "nsThreadUtils.h"
|
||||
#include "nsTPtrArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -2502,10 +2503,9 @@ nsCycleCollector::Collect(PRUint32 aTryCollections)
|
|||
mCollectionInProgress = PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
if (obs) {
|
||||
mozilla::services::GetObserverService();
|
||||
if (obs)
|
||||
obs->NotifyObservers(nsnull, "cycle-collector-begin", nsnull);
|
||||
}
|
||||
|
||||
mFollowupCollection = PR_FALSE;
|
||||
mCollectedObjects = 0;
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "prthread.h"
|
||||
#include "prlock.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
static const PRUintn BAD_TLS_INDEX = (PRUintn) -1;
|
||||
|
||||
#define CHECK_SERVICE_USE_OK() if (!lock) return NS_ERROR_NOT_INITIALIZED
|
||||
|
@ -172,7 +174,8 @@ nsExceptionService::nsExceptionService()
|
|||
NS_ASSERTION(lock, "Error allocating ExceptionService lock");
|
||||
|
||||
// observe XPCOM shutdown.
|
||||
nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
NS_ASSERTION(observerService, "Could not get observer service!");
|
||||
if (observerService)
|
||||
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "nsAutoLock.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#if defined(XP_WIN)
|
||||
#include <windows.h>
|
||||
|
@ -206,7 +207,7 @@ nsMemoryImpl::FlushMemory(const PRUnichar* aReason, PRBool aImmediate)
|
|||
nsresult
|
||||
nsMemoryImpl::RunFlushers(const PRUnichar* aReason)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os) {
|
||||
|
||||
// Instead of:
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include "nsEnumeratorUtils.h"
|
||||
#include "nsIProxyObjectManager.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
using namespace mozilla;
|
||||
class nsIComponentLoaderManager;
|
||||
|
@ -519,8 +520,8 @@ nsCategoryManager::NotifyObservers( const char *aTopic,
|
|||
if (mSuppressNotifications)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService
|
||||
(do_GetService("@mozilla.org/observer-service;1"));
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
return;
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "nsIObserverService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIProxyObjectManager.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(TimerThread, nsIRunnable, nsIObserver)
|
||||
|
||||
|
@ -111,7 +112,7 @@ nsresult TimerThread::Init()
|
|||
}
|
||||
else {
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
mozilla::services::GetObserverService();
|
||||
// We must not use the observer service from a background thread!
|
||||
if (observerService && !NS_IsMainThread()) {
|
||||
nsCOMPtr<nsIObserverService> result = nsnull;
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include "nsAutoLock.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -293,7 +294,8 @@ void PR_CALLBACK nsProcess::Monitor(void *arg)
|
|||
void nsProcess::ProcessComplete()
|
||||
{
|
||||
if (mThread) {
|
||||
nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> os =
|
||||
mozilla::services::GetObserverService();
|
||||
if (os)
|
||||
os->RemoveObserver(this, "xpcom-shutdown");
|
||||
PR_JoinThread(mThread);
|
||||
|
@ -519,7 +521,8 @@ nsProcess::RunProcess(PRBool blocking, char **my_argv, PRUint32 count,
|
|||
}
|
||||
|
||||
// It isn't a failure if we just can't watch for shutdown
|
||||
nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> os =
|
||||
mozilla::services::GetObserverService();
|
||||
if (os)
|
||||
os->AddObserver(this, "xpcom-shutdown", PR_FALSE);
|
||||
}
|
||||
|
@ -567,7 +570,7 @@ nsProcess::Kill()
|
|||
|
||||
// We must null out mThread if we want IsRunning to return false immediately
|
||||
// after this call.
|
||||
nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os)
|
||||
os->RemoveObserver(this, "xpcom-shutdown");
|
||||
PR_JoinThread(mThread);
|
||||
|
@ -591,7 +594,8 @@ nsProcess::Observe(nsISupports* subject, const char* topic, const PRUnichar* dat
|
|||
{
|
||||
// Shutting down, drop all references
|
||||
if (mThread) {
|
||||
nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
|
||||
nsCOMPtr<nsIObserverService> os =
|
||||
mozilla::services::GetObserverService();
|
||||
if (os)
|
||||
os->RemoveObserver(this, "xpcom-shutdown");
|
||||
mThread = nsnull;
|
||||
|
|
|
@ -256,7 +256,8 @@ nsInstallTrigger::HandleContent(const char * aContentType,
|
|||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));
|
||||
nsCOMPtr<nsIObserverService> os =
|
||||
mozilla::services::GetObserverService();
|
||||
if (os)
|
||||
os->NotifyObservers(installInfo,
|
||||
"xpinstall-install-blocked",
|
||||
|
|
|
@ -420,7 +420,8 @@ InstallTriggerGlobalInstall(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
|
|||
nativeThis->UpdateEnabled(checkuri, XPI_WHITELIST, &enabled);
|
||||
if (!enabled)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));
|
||||
nsCOMPtr<nsIObserverService> os =
|
||||
mozilla::services::GetObserverService();
|
||||
if (os)
|
||||
os->NotifyObservers(installInfo,
|
||||
"xpinstall-install-blocked",
|
||||
|
@ -543,7 +544,8 @@ InstallTriggerGlobalInstallChrome(JSContext *cx, JSObject *obj, uintN argc, jsva
|
|||
&enabled);
|
||||
if (!enabled)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));
|
||||
nsCOMPtr<nsIObserverService> os =
|
||||
mozilla::services::GetObserverService();
|
||||
if (os)
|
||||
os->NotifyObservers(installInfo,
|
||||
"xpinstall-install-blocked",
|
||||
|
@ -647,7 +649,8 @@ InstallTriggerGlobalStartSoftwareUpdate(JSContext *cx, JSObject *obj, uintN argc
|
|||
nativeThis->UpdateEnabled(checkuri, XPI_WHITELIST, &enabled);
|
||||
if (!enabled)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));
|
||||
nsCOMPtr<nsIObserverService> os =
|
||||
mozilla::services::GetObserverService();
|
||||
if (os)
|
||||
os->NotifyObservers(installInfo,
|
||||
"xpinstall-install-blocked",
|
||||
|
|
|
@ -527,7 +527,8 @@ nsXPInstallManager::OpenProgressDialog(const PRUnichar **aPackageList, PRUint32
|
|||
nsCOMPtr<nsIDOMWindowInternal> recentWindow;
|
||||
wm->GetMostRecentWindow(type.get(), getter_AddRefs(recentWindow));
|
||||
if (recentWindow) {
|
||||
nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));
|
||||
nsCOMPtr<nsIObserverService> os =
|
||||
mozilla::services::GetObserverService();
|
||||
os->NotifyObservers(params, "xpinstall-download-started", nsnull);
|
||||
|
||||
recentWindow->Focus();
|
||||
|
@ -574,7 +575,8 @@ NS_IMETHODIMP nsXPInstallManager::Observe( nsISupports *aSubject,
|
|||
mDialogOpen = PR_TRUE;
|
||||
rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));
|
||||
nsCOMPtr<nsIObserverService> os =
|
||||
mozilla::services::GetObserverService();
|
||||
if (os)
|
||||
{
|
||||
os->AddObserver(this, NS_IOSERVICE_GOING_OFFLINE_TOPIC, PR_TRUE);
|
||||
|
@ -998,7 +1000,8 @@ void nsXPInstallManager::Shutdown(PRInt32 status)
|
|||
item->mFile->Remove(PR_FALSE);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));
|
||||
nsCOMPtr<nsIObserverService> os =
|
||||
mozilla::services::GetObserverService();
|
||||
if (os)
|
||||
{
|
||||
os->RemoveObserver(this, NS_IOSERVICE_GOING_OFFLINE_TOPIC);
|
||||
|
|
Загрузка…
Ссылка в новой задаче