Bug 1184432 - Use nsClassHashtable::ConstIter in GeckoMediaPluginServiceParent::AsyncShutdownPluginStates. r=cpearce
authorGerald Squelart <gsquelart@mozilla.com>
Thu, 16 Jul 2015 17:00:00 -0400
changeset 253497 ca42fdde60f66047d7ae04f15f7da196b2d136dd
parent 253496 e5a750ee7e0b99b35219bcb240e3319dc7af027e
child 253498 a3daf80507807860477b32609aef8a6a45c4d09d
push id29067
push userkwierso@gmail.com
push dateSat, 18 Jul 2015 00:57:04 +0000
treeherdermozilla-central@e2f2eb9ecca0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1184432
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 1184432 - Use nsClassHashtable::ConstIter in GeckoMediaPluginServiceParent::AsyncShutdownPluginStates. r=cpearce
dom/media/gmp/GMPServiceParent.cpp
dom/media/gmp/GMPServiceParent.h
--- a/dom/media/gmp/GMPServiceParent.cpp
+++ b/dom/media/gmp/GMPServiceParent.cpp
@@ -418,58 +418,40 @@ GeckoMediaPluginServiceParent::AsyncShut
   nsCString note;
   StatesByInstance* instances = mStates.LookupOrAdd(aPlugin);
   if (!instances) { return; }
   State* state = instances->LookupOrAdd(aInstance);
   if (!state) { return; }
   state->mStateSequence += aId;
   state->mLastStateDescription = aState;
   note += '{';
-  mStates.EnumerateRead(EnumReadPlugins, &note);
+  bool firstPlugin = true;
+  for (auto pluginIt = mStates.ConstIter(); !pluginIt.Done(); pluginIt.Next()) {
+    if (!firstPlugin) { note += ','; } else { firstPlugin = false; }
+    note += pluginIt.GetKey();
+    note += ":{";
+    bool firstInstance = true;
+    for (auto instanceIt = pluginIt.GetData()->ConstIter(); !instanceIt.Done(); instanceIt.Next()) {
+      if (!firstInstance) { note += ','; } else { firstInstance = false; }
+      note += instanceIt.GetKey();
+      note += ":\"";
+      note += instanceIt.GetData()->mStateSequence;
+      note += '=';
+      note += instanceIt.GetData()->mLastStateDescription;
+      note += '"';
+    }
+    note += '}';
+  }
   note += '}';
   LOGD(("%s::%s states[%s][%s]='%c'/'%s' -> %s", __CLASS__, __FUNCTION__,
         aPlugin.get(), aInstance.get(), aId, aState.get(), note.get()));
   CrashReporter::AnnotateCrashReport(
     NS_LITERAL_CSTRING("AsyncPluginShutdownStates"),
     note);
 }
-
-// static
-PLDHashOperator
-GeckoMediaPluginServiceParent::AsyncShutdownPluginStates::EnumReadPlugins(
-  StateInstancesByPlugin::KeyType aKey,
-  StateInstancesByPlugin::UserDataType aData,
-  void* aUserArg)
-{
-  nsCString& note = *static_cast<nsCString*>(aUserArg);
-  if (note.Last() != '{') { note += ','; }
-  note += aKey;
-  note += ":{";
-  aData->EnumerateRead(EnumReadInstances, &note);
-  note += '}';
-  return PL_DHASH_NEXT;
-}
-
-// static
-PLDHashOperator
-GeckoMediaPluginServiceParent::AsyncShutdownPluginStates::EnumReadInstances(
-  StatesByInstance::KeyType aKey,
-  StatesByInstance::UserDataType aData,
-  void* aUserArg)
-{
-  nsCString& note = *static_cast<nsCString*>(aUserArg);
-  if (note.Last() != '{') { note += ','; }
-  note += aKey;
-  note += ":\"";
-  note += aData->mStateSequence;
-  note += '=';
-  note += aData->mLastStateDescription;
-  note += '"';
-  return PL_DHASH_NEXT;
-}
 #endif // MOZ_CRASHREPORTER
 
 void
 GeckoMediaPluginServiceParent::NotifyAsyncShutdownComplete()
 {
   MOZ_ASSERT(NS_IsMainThread());
   // Nothing to do, this task is just used to wake up the event loop in Observe().
 }
--- a/dom/media/gmp/GMPServiceParent.h
+++ b/dom/media/gmp/GMPServiceParent.h
@@ -147,22 +147,16 @@ private:
   {
   public:
     void Update(const nsCString& aPlugin, const nsCString& aInstance,
                 char aId, const nsCString& aState);
   private:
     struct State { nsAutoCString mStateSequence; nsCString mLastStateDescription; };
     typedef nsClassHashtable<nsCStringHashKey, State> StatesByInstance;
     typedef nsClassHashtable<nsCStringHashKey, StatesByInstance> StateInstancesByPlugin;
-    static PLDHashOperator EnumReadPlugins(StateInstancesByPlugin::KeyType aKey,
-                                           StateInstancesByPlugin::UserDataType aData,
-                                           void* aUserArg);
-    static PLDHashOperator EnumReadInstances(StatesByInstance::KeyType aKey,
-                                             StatesByInstance::UserDataType aData,
-                                             void* aUserArg);
     StateInstancesByPlugin mStates;
   } mAsyncShutdownPluginStates;
 #endif // MOZ_CRASHREPORTER
 
   // True if we've inspected MOZ_GMP_PATH on the GMP thread and loaded any
   // plugins found there into mPlugins.
   Atomic<bool> mScannedPluginOnDisk;