mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1434342 P6 Make ServiceWorker call nsIGlobalObject::AddServiceWorker and RemoveServiceWorker. r=asuth
This commit is contained in:
parent
0ff28a0a92
commit
9dfb987159
@ -73,8 +73,11 @@ ServiceWorker::ServiceWorker(nsIGlobalObject* aGlobal,
|
||||
, mInner(aInner)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_DIAGNOSTIC_ASSERT(aGlobal);
|
||||
MOZ_DIAGNOSTIC_ASSERT(mInner);
|
||||
|
||||
aGlobal->AddServiceWorker(this);
|
||||
|
||||
// This will update our state too.
|
||||
mInner->AddServiceWorker(this);
|
||||
}
|
||||
@ -83,6 +86,10 @@ ServiceWorker::~ServiceWorker()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mInner->RemoveServiceWorker(this);
|
||||
nsIGlobalObject* global = GetParentObject();
|
||||
if (global) {
|
||||
global->RemoveServiceWorker(this);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(ServiceWorker, DOMEventTargetHelper)
|
||||
@ -145,5 +152,15 @@ ServiceWorker::MatchesDescriptor(const ServiceWorkerDescriptor& aDescriptor) con
|
||||
mDescriptor.Id() == aDescriptor.Id();
|
||||
}
|
||||
|
||||
void
|
||||
ServiceWorker::DisconnectFromOwner()
|
||||
{
|
||||
nsIGlobalObject* global = GetParentObject();
|
||||
if (global) {
|
||||
global->RemoveServiceWorker(this);
|
||||
}
|
||||
DOMEventTargetHelper::DisconnectFromOwner();
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -86,6 +86,9 @@ public:
|
||||
bool
|
||||
MatchesDescriptor(const ServiceWorkerDescriptor& aDescriptor) const;
|
||||
|
||||
void
|
||||
DisconnectFromOwner() override;
|
||||
|
||||
private:
|
||||
ServiceWorker(nsIGlobalObject* aWindow,
|
||||
const ServiceWorkerDescriptor& aDescriptor,
|
||||
|
Loading…
Reference in New Issue
Block a user