зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1610692 - Move call that can run content code out of constructor. r=dom-workers-and-storage-reviewers,asuth
ServiceWorkerRegistration::UpdateState can call content code, which in turn can result in the registrations getting deleted. This commit moves the call outside the constructor, so the registration's creator has a chance to get a proper RefPtr to it. Differential Revision: https://phabricator.services.mozilla.com/D61706 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
1624e3f67f
Коммит
5c6bfb7d9a
|
@ -50,7 +50,6 @@ ServiceWorkerRegistration::ServiceWorkerRegistration(
|
|||
|
||||
KeepAliveIfHasListenersFor(NS_LITERAL_STRING("updatefound"));
|
||||
|
||||
UpdateState(mDescriptor);
|
||||
mInner->SetServiceWorkerRegistration(this);
|
||||
}
|
||||
|
||||
|
@ -81,6 +80,10 @@ ServiceWorkerRegistration::CreateForMainThread(
|
|||
|
||||
RefPtr<ServiceWorkerRegistration> registration =
|
||||
new ServiceWorkerRegistration(aWindow->AsGlobal(), aDescriptor, inner);
|
||||
// This is not called from within the constructor, as it may call content code
|
||||
// which can cause the deletion of the registration, so we need to keep a
|
||||
// strong reference while calling it.
|
||||
registration->UpdateState(aDescriptor);
|
||||
|
||||
return registration.forget();
|
||||
}
|
||||
|
@ -104,6 +107,10 @@ ServiceWorkerRegistration::CreateForWorker(
|
|||
|
||||
RefPtr<ServiceWorkerRegistration> registration =
|
||||
new ServiceWorkerRegistration(aGlobal, aDescriptor, inner);
|
||||
// This is not called from within the constructor, as it may call content code
|
||||
// which can cause the deletion of the registration, so we need to keep a
|
||||
// strong reference while calling it.
|
||||
registration->UpdateState(aDescriptor);
|
||||
|
||||
return registration.forget();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче