Bug 1184432 - Use nsClassHashtable::ConstIter in GeckoMediaPluginServiceParent::AsyncShutdownPluginStates. r=cpearce

This commit is contained in:
Gerald Squelart 2015-07-16 17:00:00 -04:00
parent ac4e47349f
commit 35f6d9fd0f
2 changed files with 17 additions and 41 deletions

View File

@ -423,7 +423,23 @@ GeckoMediaPluginServiceParent::AsyncShutdownPluginStates::Update(const nsCString
state->mStateSequence += aId; state->mStateSequence += aId;
state->mLastStateDescription = aState; state->mLastStateDescription = aState;
note += '{'; 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 += '}'; note += '}';
LOGD(("%s::%s states[%s][%s]='%c'/'%s' -> %s", __CLASS__, __FUNCTION__, LOGD(("%s::%s states[%s][%s]='%c'/'%s' -> %s", __CLASS__, __FUNCTION__,
aPlugin.get(), aInstance.get(), aId, aState.get(), note.get())); aPlugin.get(), aInstance.get(), aId, aState.get(), note.get()));
@ -431,40 +447,6 @@ GeckoMediaPluginServiceParent::AsyncShutdownPluginStates::Update(const nsCString
NS_LITERAL_CSTRING("AsyncPluginShutdownStates"), NS_LITERAL_CSTRING("AsyncPluginShutdownStates"),
note); 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 #endif // MOZ_CRASHREPORTER
void void

View File

@ -152,12 +152,6 @@ private:
struct State { nsAutoCString mStateSequence; nsCString mLastStateDescription; }; struct State { nsAutoCString mStateSequence; nsCString mLastStateDescription; };
typedef nsClassHashtable<nsCStringHashKey, State> StatesByInstance; typedef nsClassHashtable<nsCStringHashKey, State> StatesByInstance;
typedef nsClassHashtable<nsCStringHashKey, StatesByInstance> StateInstancesByPlugin; 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; StateInstancesByPlugin mStates;
} mAsyncShutdownPluginStates; } mAsyncShutdownPluginStates;
#endif // MOZ_CRASHREPORTER #endif // MOZ_CRASHREPORTER