mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1171486 - Avoid recursively obtaining the service worker manager service; r=nsm
This commit is contained in:
parent
9c6bf709fd
commit
41a471c0de
@ -25,6 +25,7 @@
|
||||
#include "jsapi.h"
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/ErrorNames.h"
|
||||
#include "mozilla/LoadContext.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
@ -84,6 +85,8 @@ static_assert(nsIHttpChannelInternal::CORS_MODE_CORS == static_cast<uint32_t>(Re
|
||||
static_assert(nsIHttpChannelInternal::CORS_MODE_CORS_WITH_FORCED_PREFLIGHT == static_cast<uint32_t>(RequestMode::Cors_with_forced_preflight),
|
||||
"RequestMode enumeration value should match Necko CORS mode value.");
|
||||
|
||||
static StaticRefPtr<ServiceWorkerManager> gInstance;
|
||||
|
||||
struct ServiceWorkerManager::RegistrationDataPerPrincipal
|
||||
{
|
||||
// Ordered list of scopes for glob matching.
|
||||
@ -343,9 +346,6 @@ NS_INTERFACE_MAP_BEGIN(ServiceWorkerManager)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIServiceWorkerManager)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIIPCBackgroundChildCreateCallback)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
||||
if (aIID.Equals(NS_GET_IID(ServiceWorkerManager)))
|
||||
foundInterface = static_cast<nsIServiceWorkerManager*>(this);
|
||||
else
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIServiceWorkerManager)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
@ -354,7 +354,17 @@ ServiceWorkerManager::ServiceWorkerManager()
|
||||
{
|
||||
// Register this component to PBackground.
|
||||
MOZ_ALWAYS_TRUE(BackgroundChild::GetOrCreateForCurrentThread(this));
|
||||
}
|
||||
|
||||
ServiceWorkerManager::~ServiceWorkerManager()
|
||||
{
|
||||
// The map will assert if it is not empty when destroyed.
|
||||
mRegistrationInfos.Clear();
|
||||
}
|
||||
|
||||
void
|
||||
ServiceWorkerManager::Init()
|
||||
{
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
||||
nsRefPtr<ServiceWorkerRegistrar> swr = ServiceWorkerRegistrar::Get();
|
||||
MOZ_ASSERT(swr);
|
||||
@ -376,12 +386,6 @@ ServiceWorkerManager::ServiceWorkerManager()
|
||||
}
|
||||
}
|
||||
|
||||
ServiceWorkerManager::~ServiceWorkerManager()
|
||||
{
|
||||
// The map will assert if it is not empty when destroyed.
|
||||
mRegistrationInfos.Clear();
|
||||
}
|
||||
|
||||
class ContinueLifecycleTask : public nsISupports
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
@ -2287,9 +2291,19 @@ ServiceWorkerManager::GetOrCreateJobQueue(const nsACString& aKey,
|
||||
already_AddRefed<ServiceWorkerManager>
|
||||
ServiceWorkerManager::GetInstance()
|
||||
{
|
||||
nsCOMPtr<nsIServiceWorkerManager> swm = mozilla::services::GetServiceWorkerManager();
|
||||
nsRefPtr<ServiceWorkerManager> concrete = do_QueryObject(swm);
|
||||
return concrete.forget();
|
||||
// Note: We don't simply check gInstance for null-ness here, since otherwise
|
||||
// this can resurrect the ServiceWorkerManager pretty late during shutdown.
|
||||
static bool firstTime = true;
|
||||
if (firstTime) {
|
||||
AssertIsOnMainThread();
|
||||
|
||||
gInstance = new ServiceWorkerManager();
|
||||
gInstance->Init();
|
||||
ClearOnShutdown(&gInstance);
|
||||
firstTime = false;
|
||||
}
|
||||
nsRefPtr<ServiceWorkerManager> copy = gInstance.get();
|
||||
return copy.forget();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -277,16 +277,6 @@ public:
|
||||
NS_DECL_NSISERVICEWORKERMANAGER
|
||||
NS_DECL_NSIIPCBACKGROUNDCHILDCREATECALLBACK
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_SERVICEWORKERMANAGER_IMPL_IID)
|
||||
|
||||
static ServiceWorkerManager* FactoryCreate()
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
|
||||
ServiceWorkerManager* res = new ServiceWorkerManager;
|
||||
NS_ADDREF(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
struct RegistrationDataPerPrincipal;
|
||||
nsClassHashtable<nsCStringHashKey, RegistrationDataPerPrincipal> mRegistrationInfos;
|
||||
@ -382,6 +372,9 @@ private:
|
||||
ServiceWorkerManager();
|
||||
~ServiceWorkerManager();
|
||||
|
||||
void
|
||||
Init();
|
||||
|
||||
ServiceWorkerJobQueue*
|
||||
GetOrCreateJobQueue(const nsACString& aOriginSuffix,
|
||||
const nsACString& aScope);
|
||||
@ -538,9 +531,6 @@ private:
|
||||
nsTArray<PendingOperation> mPendingOperations;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(ServiceWorkerManager,
|
||||
NS_SERVICEWORKERMANAGER_IMPL_IID);
|
||||
|
||||
} // namespace workers
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -312,7 +312,7 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(DOMRequestService,
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(QuotaManager,
|
||||
QuotaManager::FactoryCreate)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ServiceWorkerManager,
|
||||
ServiceWorkerManager::FactoryCreate)
|
||||
ServiceWorkerManager::GetInstance)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ServiceWorkerPeriodicUpdater,
|
||||
ServiceWorkerPeriodicUpdater::GetSingleton)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(WorkerDebuggerManager)
|
||||
|
Loading…
Reference in New Issue
Block a user