mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-23 10:54:33 +00:00
Bug 1471628 - Use singleton for captive portal constructor r=bagder
This is to make sure that the test is using the same Captive Portal Service that nsIOService initializes. --HG-- extra : rebase_source : 62bd371b8d510f596d3484aec6fad997739ada8b
This commit is contained in:
parent
57418912d1
commit
e6ea31c9c7
@ -3,6 +3,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/net/CaptivePortalService.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsIObserverService.h"
|
||||
@ -29,6 +30,21 @@ NS_IMPL_ISUPPORTS(CaptivePortalService, nsICaptivePortalService, nsIObserver,
|
||||
nsISupportsWeakReference, nsITimerCallback,
|
||||
nsICaptivePortalCallback, nsINamed)
|
||||
|
||||
static StaticRefPtr<CaptivePortalService> gCPService;
|
||||
|
||||
// static
|
||||
already_AddRefed<nsICaptivePortalService>
|
||||
CaptivePortalService::GetSingleton()
|
||||
{
|
||||
if (gCPService) {
|
||||
return do_AddRef(gCPService);
|
||||
}
|
||||
|
||||
gCPService = new CaptivePortalService();
|
||||
ClearOnShutdown(&gCPService);
|
||||
return do_AddRef(gCPService);
|
||||
}
|
||||
|
||||
CaptivePortalService::CaptivePortalService()
|
||||
: mState(UNKNOWN)
|
||||
, mStarted(false)
|
||||
|
@ -33,15 +33,17 @@ public:
|
||||
NS_DECL_NSICAPTIVEPORTALCALLBACK
|
||||
NS_DECL_NSINAMED
|
||||
|
||||
CaptivePortalService();
|
||||
nsresult Initialize();
|
||||
nsresult Start();
|
||||
nsresult Stop();
|
||||
|
||||
static already_AddRefed<nsICaptivePortalService> GetSingleton();
|
||||
|
||||
// This method is only called in the content process, in order to mirror
|
||||
// the captive portal state in the parent process.
|
||||
void SetStateInChild(int32_t aState);
|
||||
private:
|
||||
CaptivePortalService();
|
||||
virtual ~CaptivePortalService();
|
||||
nsresult PerformCheck();
|
||||
nsresult RearmTimer();
|
||||
|
@ -148,7 +148,8 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(LoadContextInfoFactory)
|
||||
#include "mozilla/net/CaptivePortalService.h"
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(CaptivePortalService)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsICaptivePortalService,
|
||||
CaptivePortalService::GetSingleton)
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
||||
@ -896,7 +897,7 @@ static const mozilla::Module::CIDEntry kNeckoCIDs[] = {
|
||||
{ &kNS_CACHE_STORAGE_SERVICE_CID, false, nullptr, CacheStorageServiceConstructor },
|
||||
{ &kNS_NSILOADCONTEXTINFOFACTORY_CID, false, nullptr, LoadContextInfoFactoryConstructor },
|
||||
{ &kNS_NETWORKPREDICTOR_CID, false, nullptr, mozilla::net::Predictor::Create },
|
||||
{ &kNS_CAPTIVEPORTAL_CID, false, nullptr, mozilla::net::CaptivePortalServiceConstructor },
|
||||
{ &kNS_CAPTIVEPORTAL_CID, false, nullptr, mozilla::net::nsICaptivePortalServiceConstructor },
|
||||
{ &kNS_REQUESTCONTEXTSERVICE_CID, false, nullptr, RequestContextServiceConstructor },
|
||||
#ifdef BUILD_NETWORK_INFO_SERVICE
|
||||
{ &kNETWORKINFOSERVICE_CID, false, nullptr, nsNetworkInfoServiceConstructor },
|
||||
|
Loading…
x
Reference in New Issue
Block a user