Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1181445 (part 9) - Use nsBaseHashTable::Iterator in nsConsoleServ…
Browse files Browse the repository at this point in the history
…ice. r=froydnj.
  • Loading branch information
nnethercote committed Jul 9, 2015
1 parent f9d225d commit 92f739d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
22 changes: 7 additions & 15 deletions xpcom/base/nsConsoleService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,6 @@ class LogMessageRunnable : public nsRunnable
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()
{
Expand All @@ -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();

Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions xpcom/base/nsConsoleService.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ class nsConsoleService final : public nsIConsoleService

typedef nsInterfaceHashtable<nsISupportsHashKey,
nsIConsoleListener> ListenerHash;
void EnumerateListeners(ListenerHash::EnumReadFunction aFunction,
void* aClosure);
void CollectCurrentListeners(nsCOMArray<nsIConsoleListener>& aListeners);

private:
~nsConsoleService();
Expand Down

0 comments on commit 92f739d

Please sign in to comment.