From c51668f9430afc3b8479e562249f566c942a231f Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Mon, 13 Jul 2015 12:44:41 -0400 Subject: [PATCH] Bug 1183158 - Part 2: Get rid of SoftUpdateEnumerator; r=baku --- dom/workers/ServiceWorkerManagerService.cpp | 68 +++++---------------- 1 file changed, 16 insertions(+), 52 deletions(-) diff --git a/dom/workers/ServiceWorkerManagerService.cpp b/dom/workers/ServiceWorkerManagerService.cpp index 19e44902437c..d5a6aedb27cd 100644 --- a/dom/workers/ServiceWorkerManagerService.cpp +++ b/dom/workers/ServiceWorkerManagerService.cpp @@ -84,55 +84,6 @@ ServiceWorkerManagerService::UnregisterActor(ServiceWorkerManagerParent* aParent namespace { -struct MOZ_STACK_CLASS SoftUpdateData final -{ - SoftUpdateData(const OriginAttributes& aOriginAttributes, - const nsAString& aScope, - uint64_t aParentID) - : mOriginAttributes(aOriginAttributes) - , mScope(aScope) - , mParentID(aParentID) -#ifdef DEBUG - , mParentFound(false) -#endif - { - MOZ_COUNT_CTOR(SoftUpdateData); - } - - ~SoftUpdateData() - { - MOZ_COUNT_DTOR(SoftUpdateData); - } - - const OriginAttributes& mOriginAttributes; - const nsString mScope; - const uint64_t mParentID; -#ifdef DEBUG - bool mParentFound; -#endif -}; - -PLDHashOperator -SoftUpdateEnumerator(nsPtrHashKey* aKey, void* aPtr) -{ - AssertIsOnBackgroundThread(); - - auto* data = static_cast(aPtr); - ServiceWorkerManagerParent* parent = aKey->GetKey(); - MOZ_ASSERT(parent); - - if (parent->ID() != data->mParentID) { - unused <SendNotifySoftUpdate(data->mOriginAttributes, - data->mScope); -#ifdef DEBUG - } else { - data->mParentFound = true; -#endif - } - - return PL_DHASH_NEXT; -} - struct MOZ_STACK_CLASS UnregisterData final { UnregisterData(const PrincipalInfo& aPrincipalInfo, @@ -304,11 +255,24 @@ ServiceWorkerManagerService::PropagateSoftUpdate( { AssertIsOnBackgroundThread(); - SoftUpdateData data(aOriginAttributes, aScope, aParentID); - mAgents.EnumerateEntries(SoftUpdateEnumerator, &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) { + nsString scope(aScope); + unused << parent->SendNotifySoftUpdate(aOriginAttributes, + scope); +#ifdef DEBUG + } else { + parentFound = true; +#endif + } + } #ifdef DEBUG - MOZ_ASSERT(data.mParentFound); + MOZ_ASSERT(parentFound); #endif }