mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1058043 - Patch 2 - StopListeningForEvents in ServiceWorkerRegistration destructor. r=baku
--HG-- extra : rebase_source : 224f28dcb1b9604916cbdd53bf4690ef32d71be9
This commit is contained in:
parent
e4ade03675
commit
4cf96ddcba
@ -1851,6 +1851,7 @@ NS_IMETHODIMP
|
||||
ServiceWorkerManager::AddRegistrationEventListener(nsIURI* aDocumentURI, nsIDOMEventTarget* aListener)
|
||||
{
|
||||
MOZ_ASSERT(aDocumentURI);
|
||||
AssertIsOnMainThread();
|
||||
nsRefPtr<ServiceWorkerDomainInfo> domainInfo = GetDomainInfo(aDocumentURI);
|
||||
if (!domainInfo) {
|
||||
nsCString domain;
|
||||
@ -1875,6 +1876,7 @@ ServiceWorkerManager::AddRegistrationEventListener(nsIURI* aDocumentURI, nsIDOME
|
||||
NS_IMETHODIMP
|
||||
ServiceWorkerManager::RemoveRegistrationEventListener(nsIURI* aDocumentURI, nsIDOMEventTarget* aListener)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(aDocumentURI);
|
||||
nsRefPtr<ServiceWorkerDomainInfo> domainInfo = GetDomainInfo(aDocumentURI);
|
||||
if (!domainInfo) {
|
||||
|
@ -38,6 +38,7 @@ ServiceWorkerRegistration::ServiceWorkerRegistration(nsPIDOMWindow* aWindow,
|
||||
const nsAString& aScope)
|
||||
: DOMEventTargetHelper(aWindow)
|
||||
, mScope(aScope)
|
||||
, mListeningForEvents(false)
|
||||
{
|
||||
MOZ_ASSERT(aWindow);
|
||||
MOZ_ASSERT(aWindow->IsInnerWindow());
|
||||
@ -47,6 +48,7 @@ ServiceWorkerRegistration::ServiceWorkerRegistration(nsPIDOMWindow* aWindow,
|
||||
|
||||
ServiceWorkerRegistration::~ServiceWorkerRegistration()
|
||||
{
|
||||
StopListeningForEvents();
|
||||
}
|
||||
|
||||
void
|
||||
@ -176,15 +178,21 @@ ServiceWorkerRegistration::StartListeningForEvents()
|
||||
nsCOMPtr<nsIServiceWorkerManager> swm = do_GetService(SERVICEWORKERMANAGER_CONTRACTID);
|
||||
if (swm) {
|
||||
swm->AddRegistrationEventListener(GetDocumentURI(), this);
|
||||
mListeningForEvents = true;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServiceWorkerRegistration::StopListeningForEvents()
|
||||
{
|
||||
if (!mListeningForEvents) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIServiceWorkerManager> swm = do_GetService(SERVICEWORKERMANAGER_CONTRACTID);
|
||||
if (swm) {
|
||||
swm->RemoveRegistrationEventListener(GetDocumentURI(), this);
|
||||
mListeningForEvents = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,6 +86,7 @@ private:
|
||||
nsRefPtr<workers::ServiceWorker> mActiveWorker;
|
||||
|
||||
const nsString mScope;
|
||||
bool mListeningForEvents;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
Loading…
Reference in New Issue
Block a user