diff --git a/netwerk/dns/nsDNSService2.cpp b/netwerk/dns/nsDNSService2.cpp index 1f0d8463191..49a320a4619 100644 --- a/netwerk/dns/nsDNSService2.cpp +++ b/netwerk/dns/nsDNSService2.cpp @@ -454,25 +454,24 @@ nsDNSSyncRequest::SizeOfIncludingThis(MallocSizeOf mallocSizeOf) const class NotifyDNSResolution: public nsRunnable { public: - NotifyDNSResolution(nsMainThreadPtrHandle &aObs, - const nsACString &aHostname) - : mObs(aObs) - , mHostname(aHostname) + explicit NotifyDNSResolution(const nsACString &aHostname) + : mHostname(aHostname) { - MOZ_ASSERT(mObs); } NS_IMETHOD Run() { MOZ_ASSERT(NS_IsMainThread()); - mObs->NotifyObservers(nullptr, - "dns-resolution-request", - NS_ConvertUTF8toUTF16(mHostname).get()); + nsCOMPtr obs = services::GetObserverService(); + if (obs) { + obs->NotifyObservers(nullptr, + "dns-resolution-request", + NS_ConvertUTF8toUTF16(mHostname).get()); + } return NS_OK; } private: - nsMainThreadPtrHandle mObs; nsCString mHostname; }; @@ -606,8 +605,6 @@ nsDNSService::Init() nsCOMPtr idn = do_GetService(NS_IDNSERVICE_CONTRACTID); - nsCOMPtr obs = services::GetObserverService(); - nsRefPtr res; nsresult rv = nsHostResolver::Create(maxCacheEntries, defaultCacheLifetime, @@ -635,10 +632,6 @@ nsDNSService::Init() } } mNotifyResolution = notifyResolution; - if (mNotifyResolution) { - mObserverService = - new nsMainThreadPtrHolder(obs); - } } #if !defined(MOZILLA_XPCOMRT_API) @@ -760,8 +753,7 @@ nsDNSService::AsyncResolveExtended(const nsACString &aHostname, } if (mNotifyResolution) { - NS_DispatchToMainThread(new NotifyDNSResolution(mObserverService, - aHostname)); + NS_DispatchToMainThread(new NotifyDNSResolution(aHostname)); } if (!res) @@ -874,8 +866,7 @@ nsDNSService::Resolve(const nsACString &aHostname, } if (mNotifyResolution) { - NS_DispatchToMainThread(new NotifyDNSResolution(mObserverService, - aHostname)); + NS_DispatchToMainThread(new NotifyDNSResolution(aHostname)); } NS_ENSURE_TRUE(res, NS_ERROR_OFFLINE); diff --git a/netwerk/dns/nsDNSService2.h b/netwerk/dns/nsDNSService2.h index 39add3d4e50..5085e9b1e08 100644 --- a/netwerk/dns/nsDNSService2.h +++ b/netwerk/dns/nsDNSService2.h @@ -16,8 +16,6 @@ #include "nsString.h" #include "nsTHashtable.h" #include "nsHashKeys.h" -#include "nsIObserverService.h" -#include "nsProxyRelease.h" #include "mozilla/Mutex.h" #include "mozilla/Attributes.h" @@ -61,7 +59,6 @@ private: bool mOffline; bool mNotifyResolution; bool mOfflineLocalhost; - nsMainThreadPtrHandle mObserverService; nsTHashtable mLocalDomains; };