Bug 1183158 - Part 1: Get rid of RegistrationEnumerator; r=baku
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 13 Jul 2015 12:18:24 -0400
changeset 252671 b37ee095e71f3af091d65882c7e89996c2ff714e
parent 252670 12f790e0982a38a1a075cb34abbdf48913396db8
child 252672 96684d85aa76634e6563b1a3dd60d7bd7afc5a52
push id62212
push usereakhgari@mozilla.com
push dateTue, 14 Jul 2015 02:52:47 +0000
treeherdermozilla-inbound@07ee075d8e6c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1183158
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1183158 - Part 1: Get rid of RegistrationEnumerator; r=baku
dom/workers/ServiceWorkerManagerService.cpp
--- a/dom/workers/ServiceWorkerManagerService.cpp
+++ b/dom/workers/ServiceWorkerManagerService.cpp
@@ -79,62 +79,16 @@ ServiceWorkerManagerService::UnregisterA
   MOZ_ASSERT(aParent);
   MOZ_ASSERT(mAgents.Contains(aParent));
 
   mAgents.RemoveEntry(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<ServiceWorkerManagerParent>* aKey, void* aPtr)
-{
-  AssertIsOnBackgroundThread();
-
-  auto* data = static_cast<RegistrationData*>(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,
                  const nsAString& aScope,
                  uint64_t aParentID)
     : mOriginAttributes(aOriginAttributes)
     , mScope(aScope)
     , mParentID(aParentID)
@@ -318,21 +272,32 @@ RemoveEnumerator(nsPtrHashKey<ServiceWor
 
 void
 ServiceWorkerManagerService::PropagateRegistration(
                                            uint64_t aParentID,
                                            ServiceWorkerRegistrationData& aData)
 {
   AssertIsOnBackgroundThread();
 
-  RegistrationData data(aData, aParentID);
-  mAgents.EnumerateEntries(RegistrationEnumerator, &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) {
+      unused << parent->SendNotifyRegister(aData);
+#ifdef DEBUG
+    } else {
+      parentFound = true;
+#endif
+    }
+  }
 
 #ifdef DEBUG
-  MOZ_ASSERT(data.mParentFound);
+  MOZ_ASSERT(parentFound);
 #endif
 }
 
 void
 ServiceWorkerManagerService::PropagateSoftUpdate(
                                       uint64_t aParentID,
                                       const OriginAttributes& aOriginAttributes,
                                       const nsAString& aScope)