зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1254741 P2 Don't aggressively terminate service workers when last controlled window is closed. r=baku
This commit is contained in:
Родитель
05c6dff3b5
Коммит
05565765eb
|
@ -1918,13 +1918,10 @@ ServiceWorkerManager::StopControllingADocument(ServiceWorkerRegistrationInfo* aR
|
|||
if (aRegistration->mPendingUninstall) {
|
||||
RemoveRegistration(aRegistration);
|
||||
} else {
|
||||
// If the registration has an active worker that is running
|
||||
// this might be a good time to stop it.
|
||||
if (aRegistration->GetActive()) {
|
||||
ServiceWorkerPrivate* serviceWorkerPrivate =
|
||||
aRegistration->GetActive()->WorkerPrivate();
|
||||
serviceWorkerPrivate->NoteStoppedControllingDocuments();
|
||||
}
|
||||
// We use to aggressively terminate the worker at this point, but it
|
||||
// caused problems. There are more uses for a service worker than actively
|
||||
// controlled documents. We need to let the worker naturally terminate
|
||||
// in case its handling push events, message events, etc.
|
||||
aRegistration->TryToActivateAsync();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,6 @@ NS_IMPL_ISUPPORTS0(KeepAliveToken)
|
|||
|
||||
ServiceWorkerPrivate::ServiceWorkerPrivate(ServiceWorkerInfo* aInfo)
|
||||
: mInfo(aInfo)
|
||||
, mIsPushWorker(false)
|
||||
, mDebuggerCount(0)
|
||||
, mTokenCount(0)
|
||||
{
|
||||
|
@ -1598,7 +1597,6 @@ ServiceWorkerPrivate::SpawnWorkerIfNeeded(WakeUpReason aWhy,
|
|||
return error.StealNSResult();
|
||||
}
|
||||
|
||||
mIsPushWorker = false;
|
||||
RenewKeepAliveToken(aWhy);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1659,17 +1657,6 @@ ServiceWorkerPrivate::NoteDeadServiceWorkerInfo()
|
|||
TerminateWorker();
|
||||
}
|
||||
|
||||
void
|
||||
ServiceWorkerPrivate::NoteStoppedControllingDocuments()
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
if (mIsPushWorker || mDebuggerCount) {
|
||||
return;
|
||||
}
|
||||
|
||||
TerminateWorker();
|
||||
}
|
||||
|
||||
void
|
||||
ServiceWorkerPrivate::Activated()
|
||||
{
|
||||
|
@ -1801,10 +1788,6 @@ ServiceWorkerPrivate::RenewKeepAliveToken(WakeUpReason aWhy)
|
|||
// We should have an active worker if we're renewing the keep alive token.
|
||||
MOZ_ASSERT(mWorkerPrivate);
|
||||
|
||||
if (aWhy == PushEvent || aWhy == PushSubscriptionChangeEvent) {
|
||||
mIsPushWorker = true;
|
||||
}
|
||||
|
||||
// If there is at least one debugger attached to the worker, the idle worker
|
||||
// timeout was canceled when the first debugger attached to the worker. It
|
||||
// should not be reset until the last debugger detaches from the worker.
|
||||
|
|
|
@ -193,11 +193,6 @@ private:
|
|||
|
||||
nsCOMPtr<nsITimer> mIdleWorkerTimer;
|
||||
|
||||
// We keep track if this worker received any push events since it was last
|
||||
// woken up. The flag is reset to false every time a new WorkerPrivate
|
||||
// is created.
|
||||
bool mIsPushWorker;
|
||||
|
||||
// We keep a token for |dom.serviceWorkers.idle_timeout| seconds to give the
|
||||
// worker a grace period after each event.
|
||||
RefPtr<KeepAliveToken> mKeepAliveToken;
|
||||
|
|
Загрузка…
Ссылка в новой задаче