Bug 1181445 (part 9) - Use nsBaseHashTable::Iterator in nsConsoleService. r=froydnj.

This commit is contained in:
Nicholas Nethercote 2015-07-09 16:54:59 -07:00
parent 85c9fe03d6
commit 16b5e58866
2 changed files with 8 additions and 17 deletions

View File

@ -137,17 +137,6 @@ private:
nsRefPtr<nsConsoleService> mService;
};
typedef nsCOMArray<nsIConsoleListener> ListenerArrayType;
PLDHashOperator
CollectCurrentListeners(nsISupports* aKey, nsIConsoleListener* aValue,
void* aClosure)
{
ListenerArrayType* listeners = static_cast<ListenerArrayType*>(aClosure);
listeners->AppendObject(aValue);
return PL_DHASH_NEXT;
}
NS_IMETHODIMP
LogMessageRunnable::Run()
{
@ -156,7 +145,7 @@ LogMessageRunnable::Run()
// Snapshot of listeners so that we don't reenter this hash during
// enumeration.
nsCOMArray<nsIConsoleListener> listeners;
mService->EnumerateListeners(CollectCurrentListeners, &listeners);
mService->CollectCurrentListeners(listeners);
mService->SetIsDelivering();
@ -306,11 +295,14 @@ nsConsoleService::LogMessageWithMode(nsIConsoleMessage* aMessage,
}
void
nsConsoleService::EnumerateListeners(ListenerHash::EnumReadFunction aFunction,
void* aClosure)
nsConsoleService::CollectCurrentListeners(
nsCOMArray<nsIConsoleListener>& aListeners)
{
MutexAutoLock lock(mLock);
mListeners.EnumerateRead(aFunction, aClosure);
for (auto iter = mListeners.Iter(); !iter.Done(); iter.Next()) {
nsIConsoleListener* value = iter.GetUserData();
aListeners.AppendObject(value);
}
}
NS_IMETHODIMP

View File

@ -55,8 +55,7 @@ public:
typedef nsInterfaceHashtable<nsISupportsHashKey,
nsIConsoleListener> ListenerHash;
void EnumerateListeners(ListenerHash::EnumReadFunction aFunction,
void* aClosure);
void CollectCurrentListeners(nsCOMArray<nsIConsoleListener>& aListeners);
private:
~nsConsoleService();