From d0d2389e74f8ef20583b5ea418385a79a4b7a8e1 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Wed, 1 Jul 2015 17:32:52 -0400 Subject: [PATCH] Bug 1179489 - Don't count service workers towards an origin's max worker quota; r=nsm This is a follow-up to bug 1178339. --- dom/workers/RuntimeService.cpp | 2 +- dom/workers/RuntimeService.h | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index d97e538fce3..66573fd2eee 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -1668,7 +1668,7 @@ RuntimeService::UnregisterWorker(JSContext* aCx, WorkerPrivate* aWorkerPrivate) } } - if (!domainInfo->ActiveWorkerCount()) { + if (domainInfo->HasNoWorkers()) { MOZ_ASSERT(domainInfo->mQueuedWorkers.IsEmpty()); mDomainMap.Remove(domain); } diff --git a/dom/workers/RuntimeService.h b/dom/workers/RuntimeService.h index aa27cc085bc..984c32b6f8c 100644 --- a/dom/workers/RuntimeService.h +++ b/dom/workers/RuntimeService.h @@ -56,9 +56,21 @@ class RuntimeService final : public nsIObserver ActiveWorkerCount() const { return mActiveWorkers.Length() + - mActiveServiceWorkers.Length() + mChildWorkerCount; } + + uint32_t + ActiveServiceWorkerCount() const + { + return mActiveServiceWorkers.Length(); + } + + bool + HasNoWorkers() const + { + return ActiveWorkerCount() == 0 && + ActiveServiceWorkerCount() == 0; + } }; struct IdleThreadInfo;