Bug 1181445 (part 2) - Use nsTHashTable::Iterator in nsMemoryReporterManager. r=froydnj.

This commit is contained in:
Nicholas Nethercote 2015-07-08 22:32:39 -07:00
parent 099f5c1870
commit 1840f58314

View File

@ -1400,24 +1400,6 @@ nsMemoryReporterManager::StartGettingReports()
return NS_OK;
}
typedef nsCOMArray<nsIMemoryReporter> MemoryReporterArray;
static PLDHashOperator
StrongEnumerator(nsRefPtrHashKey<nsIMemoryReporter>* aElem, void* aData)
{
MemoryReporterArray* allReporters = static_cast<MemoryReporterArray*>(aData);
allReporters->AppendElement(aElem->GetKey());
return PL_DHASH_NEXT;
}
static PLDHashOperator
WeakEnumerator(nsPtrHashKey<nsIMemoryReporter>* aElem, void* aData)
{
MemoryReporterArray* allReporters = static_cast<MemoryReporterArray*>(aData);
allReporters->AppendElement(aElem->GetKey());
return PL_DHASH_NEXT;
}
NS_IMETHODIMP
nsMemoryReporterManager::GetReportsForThisProcess(
nsIHandleReportCallback* aHandleReport,
@ -1448,11 +1430,17 @@ nsMemoryReporterManager::GetReportsForThisProcessExtended(
MOZ_ASSERT(!aDMDFile);
#endif
MemoryReporterArray allReporters;
nsCOMArray<nsIMemoryReporter> allReporters;
{
mozilla::MutexAutoLock autoLock(mMutex);
mStrongReporters->EnumerateEntries(StrongEnumerator, &allReporters);
mWeakReporters->EnumerateEntries(WeakEnumerator, &allReporters);
for (auto iter = mStrongReporters->Iter(); !iter.Done(); iter.Next()) {
nsRefPtrHashKey<nsIMemoryReporter>* entry = iter.Get();
allReporters.AppendElement(entry->GetKey());
}
for (auto iter = mWeakReporters->Iter(); !iter.Done(); iter.Next()) {
nsPtrHashKey<nsIMemoryReporter>* entry = iter.Get();
allReporters.AppendElement(entry->GetKey());
}
}
for (uint32_t i = 0; i < allReporters.Length(); i++) {
allReporters[i]->CollectReports(aHandleReport, aHandleReportData,