From a61f08bf74812f94646dc3236dc9740fbdae2f77 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Mon, 13 Jul 2015 13:26:03 -0400 Subject: [PATCH] Bug 1183158 - Part 5: Get rid of RemoveAllEnumerator; r=baku --- dom/workers/ServiceWorkerManagerService.cpp | 63 +++++---------------- 1 file changed, 14 insertions(+), 49 deletions(-) diff --git a/dom/workers/ServiceWorkerManagerService.cpp b/dom/workers/ServiceWorkerManagerService.cpp index 11a788bda71..1864a9bc346 100644 --- a/dom/workers/ServiceWorkerManagerService.cpp +++ b/dom/workers/ServiceWorkerManagerService.cpp @@ -82,52 +82,6 @@ ServiceWorkerManagerService::UnregisterActor(ServiceWorkerManagerParent* aParent mAgents.RemoveEntry(aParent); } -namespace { - -struct MOZ_STACK_CLASS RemoveAllData final -{ - explicit RemoveAllData(uint64_t aParentID) - : mParentID(aParentID) -#ifdef DEBUG - , mParentFound(false) -#endif - { - MOZ_COUNT_CTOR(RemoveAllData); - } - - ~RemoveAllData() - { - MOZ_COUNT_DTOR(RemoveAllData); - } - - const uint64_t mParentID; -#ifdef DEBUG - bool mParentFound; -#endif -}; - -PLDHashOperator -RemoveAllEnumerator(nsPtrHashKey* aKey, void* aPtr) -{ - AssertIsOnBackgroundThread(); - - auto* data = static_cast(aPtr); - ServiceWorkerManagerParent* parent = aKey->GetKey(); - MOZ_ASSERT(parent); - - if (parent->ID() != data->mParentID) { - unused << parent->SendNotifyRemoveAll(); -#ifdef DEBUG - } else { - data->mParentFound = true; -#endif - } - - return PL_DHASH_NEXT; -} - -} // anonymous namespce - void ServiceWorkerManagerService::PropagateRegistration( uint64_t aParentID, @@ -257,11 +211,22 @@ ServiceWorkerManagerService::PropagateRemoveAll(uint64_t aParentID) service->RemoveAll(); - RemoveAllData data(aParentID); - mAgents.EnumerateEntries(RemoveAllEnumerator, &data); + DebugOnly parentFound = false; + for (auto iter = mAgents.Iter(); !iter.Done(); iter.Next()) { + ServiceWorkerManagerParent* parent = iter.Get()->GetKey(); + MOZ_ASSERT(parent); + + if (parent->ID() != aParentID) { + unused << parent->SendNotifyRemoveAll(); +#ifdef DEBUG + } else { + parentFound = true; +#endif + } + } #ifdef DEBUG - MOZ_ASSERT(data.mParentFound); + MOZ_ASSERT(parentFound); #endif }