зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1178339 - Account for service workers separately in WorkerDomainInfo; r=nsm
This commit is contained in:
Родитель
61f2737242
Коммит
92139cbfb2
|
@ -1509,6 +1509,9 @@ RuntimeService::RegisterWorker(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
|
|||
else if (parent) {
|
||||
domainInfo->mChildWorkerCount++;
|
||||
}
|
||||
else if (isServiceWorker) {
|
||||
domainInfo->mActiveServiceWorkers.AppendElement(aWorkerPrivate);
|
||||
}
|
||||
else {
|
||||
domainInfo->mActiveWorkers.AppendElement(aWorkerPrivate);
|
||||
}
|
||||
|
@ -1613,12 +1616,17 @@ RuntimeService::UnregisterWorker(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
|
|||
domainInfo->mQueuedWorkers.RemoveElementAt(index);
|
||||
}
|
||||
else if (parent) {
|
||||
NS_ASSERTION(domainInfo->mChildWorkerCount, "Must be non-zero!");
|
||||
MOZ_ASSERT(domainInfo->mChildWorkerCount, "Must be non-zero!");
|
||||
domainInfo->mChildWorkerCount--;
|
||||
}
|
||||
else if (aWorkerPrivate->IsServiceWorker()) {
|
||||
MOZ_ASSERT(domainInfo->mActiveServiceWorkers.Contains(aWorkerPrivate),
|
||||
"Don't know about this worker!");
|
||||
domainInfo->mActiveServiceWorkers.RemoveElement(aWorkerPrivate);
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(domainInfo->mActiveWorkers.Contains(aWorkerPrivate),
|
||||
"Don't know about this worker!");
|
||||
MOZ_ASSERT(domainInfo->mActiveWorkers.Contains(aWorkerPrivate),
|
||||
"Don't know about this worker!");
|
||||
domainInfo->mActiveWorkers.RemoveElement(aWorkerPrivate);
|
||||
}
|
||||
|
||||
|
@ -1652,6 +1660,9 @@ RuntimeService::UnregisterWorker(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
|
|||
if (queuedWorker->GetParent()) {
|
||||
domainInfo->mChildWorkerCount++;
|
||||
}
|
||||
else if (queuedWorker->IsServiceWorker()) {
|
||||
domainInfo->mActiveServiceWorkers.AppendElement(queuedWorker);
|
||||
}
|
||||
else {
|
||||
domainInfo->mActiveWorkers.AppendElement(queuedWorker);
|
||||
}
|
||||
|
@ -2214,12 +2225,17 @@ RuntimeService::AddAllTopLevelWorkersToArray(const nsACString& aKey,
|
|||
|
||||
#ifdef DEBUG
|
||||
for (uint32_t index = 0; index < aData->mActiveWorkers.Length(); index++) {
|
||||
NS_ASSERTION(!aData->mActiveWorkers[index]->GetParent(),
|
||||
"Shouldn't have a parent in this list!");
|
||||
MOZ_ASSERT(!aData->mActiveWorkers[index]->GetParent(),
|
||||
"Shouldn't have a parent in this list!");
|
||||
}
|
||||
for (uint32_t index = 0; index < aData->mActiveServiceWorkers.Length(); index++) {
|
||||
MOZ_ASSERT(!aData->mActiveServiceWorkers[index]->GetParent(),
|
||||
"Shouldn't have a parent in this list!");
|
||||
}
|
||||
#endif
|
||||
|
||||
array->AppendElements(aData->mActiveWorkers);
|
||||
array->AppendElements(aData->mActiveServiceWorkers);
|
||||
|
||||
// These might not be top-level workers...
|
||||
for (uint32_t index = 0; index < aData->mQueuedWorkers.Length(); index++) {
|
||||
|
|
|
@ -43,6 +43,7 @@ class RuntimeService final : public nsIObserver
|
|||
{
|
||||
nsCString mDomain;
|
||||
nsTArray<WorkerPrivate*> mActiveWorkers;
|
||||
nsTArray<WorkerPrivate*> mActiveServiceWorkers;
|
||||
nsTArray<WorkerPrivate*> mQueuedWorkers;
|
||||
nsClassHashtable<nsCStringHashKey, SharedWorkerInfo> mSharedWorkerInfos;
|
||||
uint32_t mChildWorkerCount;
|
||||
|
@ -54,7 +55,9 @@ class RuntimeService final : public nsIObserver
|
|||
uint32_t
|
||||
ActiveWorkerCount() const
|
||||
{
|
||||
return mActiveWorkers.Length() + mChildWorkerCount;
|
||||
return mActiveWorkers.Length() +
|
||||
mActiveServiceWorkers.Length() +
|
||||
mChildWorkerCount;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче