Bug 1141689 - use services::GetObserverService more; r=ehsan

This commit is contained in:
Nathan Froyd 2014-04-29 13:31:06 -04:00
parent 0e8278219d
commit e9f067ac2a
10 changed files with 26 additions and 27 deletions

View File

@ -10,6 +10,7 @@
#include "nsIGlobalHistory2.h"
#include "nsIObserverService.h"
#include "nsIURI.h"
#include "mozilla/Services.h"
////////////////////////////////////////////////////////////////////////////////
//// nsDownloadHistory
@ -42,7 +43,7 @@ nsDownloadHistory::AddDownload(nsIURI* aSource,
if (!visited) {
nsCOMPtr<nsIObserverService> os =
do_GetService("@mozilla.org/observer-service;1");
mozilla::services::GetObserverService();
if (os) {
os->NotifyObservers(aSource, NS_LINK_VISITED_EVENT_TOPIC, nullptr);
}

View File

@ -8846,7 +8846,7 @@ public:
NS_IMETHOD Run()
{
nsCOMPtr<nsIObserverService> observerService =
do_GetService("@mozilla.org/observer-service;1");
services::GetObserverService();
if (observerService) {
nsCOMPtr<nsISupportsPRUint64> wrapper =
do_CreateInstance(NS_SUPPORTS_PRUINT64_CONTRACTID);

View File

@ -242,8 +242,7 @@ NS_IMPL_ISUPPORTS(AppCacheClearDataObserver, nsIObserver)
void
nsApplicationCacheService::AppClearDataObserverInit()
{
nsCOMPtr<nsIObserverService> observerService =
do_GetService("@mozilla.org/observer-service;1");
nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
if (observerService) {
nsRefPtr<AppCacheClearDataObserver> obs
= new AppCacheClearDataObserver();

View File

@ -696,7 +696,7 @@ nsCookieService::GetSingleton()
/* static */ void
nsCookieService::AppClearDataObserverInit()
{
nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1");
nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
nsCOMPtr<nsIObserver> obs = new AppClearDataObserver();
observerService->AddObserver(obs, TOPIC_WEB_APP_CLEAR_DATA,
/* holdsWeak= */ false);

View File

@ -610,8 +610,7 @@ nsDNSService::Init()
nsCOMPtr<nsIIDNService> idn = do_GetService(NS_IDNSERVICE_CONTRACTID);
nsCOMPtr<nsIObserverService> obs =
do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
nsRefPtr<nsHostResolver> res;
nsresult rv = nsHostResolver::Create(maxCacheEntries,

View File

@ -76,6 +76,7 @@ static gfxIntSize gAndroidScreenBounds;
#include "mozilla/layers/CompositorParent.h"
#include "mozilla/layers/LayerTransactionParent.h"
#include "mozilla/Mutex.h"
#include "mozilla/Services.h"
#include "nsThreadUtils.h"
class ContentCreationNotifier;
@ -100,8 +101,8 @@ public:
ContentParent* cp = static_cast<ContentParent*>(cpo.get());
unused << cp->SendScreenSizeChanged(gAndroidScreenBounds);
} 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(static_cast<nsIObserver*>(this),
"xpcom-shutdown");
@ -823,7 +824,8 @@ nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae)
// If the content process is not created yet, wait until it's
// created and then tell it the screen size.
nsCOMPtr<nsIObserverService> obs = do_GetService("@mozilla.org/observer-service;1");
nsCOMPtr<nsIObserverService> obs =
mozilla::services::GetObserverService();
if (!obs)
break;

View File

@ -35,6 +35,7 @@ extern "C" {
#include "nsIServiceManager.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
using namespace mozilla;
@ -61,7 +62,7 @@ nsToolkit::~nsToolkit()
void
nsToolkit::PostSleepWakeNotification(const char* aNotification)
{
nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1");
nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
if (observerService)
observerService->NotifyObservers(nullptr, aNotification, nullptr);
}

View File

@ -1291,8 +1291,7 @@ nsMemoryReporterManager::GetReportsExtended(
// Request memory reports from child processes. We do this *before*
// collecting reports for this process so each process can collect
// reports in parallel.
nsCOMPtr<nsIObserverService> obs =
do_GetService("@mozilla.org/observer-service;1");
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
NS_ENSURE_STATE(obs);
nsPrintfCString genStr("generation=%x anonymize=%d minimize=%d DMDident=",

View File

@ -40,6 +40,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "mozilla/StartupTimeline.h"
#include "nsEmbedCID.h"
@ -63,8 +64,7 @@ nsAppShellService::nsAppShellService() :
mModalWindowCount(0),
mApplicationProvidedHiddenWindow(false)
{
nsCOMPtr<nsIObserverService> obs
(do_GetService("@mozilla.org/observer-service;1"));
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
if (obs) {
obs->AddObserver(this, "xpcom-will-shutdown", false);
@ -806,8 +806,7 @@ nsAppShellService::RegisterTopLevelWindow(nsIXULWindow* aWindow)
}
// an ongoing attempt to quit is stopped by a newly opened window
nsCOMPtr<nsIObserverService> obssvc =
do_GetService("@mozilla.org/observer-service;1");
nsCOMPtr<nsIObserverService> obssvc = services::GetObserverService();
NS_ASSERTION(obssvc, "Couldn't get observer service.");
if (obssvc)

View File

@ -55,6 +55,7 @@
#include "prenv.h"
#include "mozilla/AutoRestore.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "mozilla/dom/BarProps.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Event.h"
@ -509,8 +510,7 @@ NS_IMETHODIMP nsXULWindow::Destroy()
is destroyed, because onunload handlers fire then, and those being
script, anything could happen. A new window could open, even.
See bug 130719. */
nsCOMPtr<nsIObserverService> obssvc =
do_GetService("@mozilla.org/observer-service;1");
nsCOMPtr<nsIObserverService> obssvc = services::GetObserverService();
NS_ASSERTION(obssvc, "Couldn't get observer service?");
if (obssvc)
@ -816,8 +816,7 @@ NS_IMETHODIMP nsXULWindow::SetVisibility(bool aVisibility)
windowMediator->UpdateWindowTimeStamp(static_cast<nsIXULWindow*>(this));
// notify observers so that we can hide the splash screen if possible
nsCOMPtr<nsIObserverService> obssvc
(do_GetService("@mozilla.org/observer-service;1"));
nsCOMPtr<nsIObserverService> obssvc = services::GetObserverService();
NS_ASSERTION(obssvc, "Couldn't get observer service.");
if (obssvc) {
obssvc->NotifyObservers(nullptr, "xul-window-visible", nullptr);