From 1c9ff443326f3bce82f1a0fc0a3094be0ffcb8a6 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Mon, 13 Jul 2015 12:18:24 -0400 Subject: [PATCH] Bug 1183158 - Part 1: Get rid of RegistrationEnumerator; 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 a4a6ac1dffc..19e44902437 100644 --- a/dom/workers/ServiceWorkerManagerService.cpp +++ b/dom/workers/ServiceWorkerManagerService.cpp @@ -84,52 +84,6 @@ ServiceWorkerManagerService::UnregisterActor(ServiceWorkerManagerParent* aParent namespace { -struct MOZ_STACK_CLASS RegistrationData final -{ - RegistrationData(ServiceWorkerRegistrationData& aData, - uint64_t aParentID) - : mData(aData) - , mParentID(aParentID) -#ifdef DEBUG - , mParentFound(false) -#endif - { - MOZ_COUNT_CTOR(RegistrationData); - } - - ~RegistrationData() - { - MOZ_COUNT_DTOR(RegistrationData); - } - - const ServiceWorkerRegistrationData& mData; - const uint64_t mParentID; -#ifdef DEBUG - bool mParentFound; -#endif -}; - -PLDHashOperator -RegistrationEnumerator(nsPtrHashKey* aKey, void* aPtr) -{ - AssertIsOnBackgroundThread(); - - auto* data = static_cast(aPtr); - - ServiceWorkerManagerParent* parent = aKey->GetKey(); - MOZ_ASSERT(parent); - - if (parent->ID() != data->mParentID) { - unused << parent->SendNotifyRegister(data->mData); -#ifdef DEBUG - } else { - data->mParentFound = true; -#endif - } - - return PL_DHASH_NEXT; -} - struct MOZ_STACK_CLASS SoftUpdateData final { SoftUpdateData(const OriginAttributes& aOriginAttributes, @@ -323,11 +277,22 @@ ServiceWorkerManagerService::PropagateRegistration( { AssertIsOnBackgroundThread(); - RegistrationData data(aData, aParentID); - mAgents.EnumerateEntries(RegistrationEnumerator, &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->SendNotifyRegister(aData); +#ifdef DEBUG + } else { + parentFound = true; +#endif + } + } #ifdef DEBUG - MOZ_ASSERT(data.mParentFound); + MOZ_ASSERT(parentFound); #endif }