зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1183158 - Part 2: Get rid of SoftUpdateEnumerator; r=baku
This commit is contained in:
Родитель
44899f18a4
Коммит
c51668f943
|
@ -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<ServiceWorkerManagerParent>* aKey, void* aPtr)
|
||||
{
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
auto* data = static_cast<SoftUpdateData*>(aPtr);
|
||||
ServiceWorkerManagerParent* parent = aKey->GetKey();
|
||||
MOZ_ASSERT(parent);
|
||||
|
||||
if (parent->ID() != data->mParentID) {
|
||||
unused <<parent->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<bool> 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
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче