import changes from `dev' branch of rmottola/Arctic-Fox:

- Bug 586587 - support kHTMLMime in the Windows clipboard as CF_HTML. r=jimm (6af5a0d7fa)
- Bug 1159604: Use a fallible allocation in nsClipboard::GetGlobalData. r=bbondy (c9645301a4)
- Bug 1048624 - Cleanup and refactor the media crashtest manifests and re-enable some disabled tests that now pass. (d712e08056)
- crashtest for bug 1020370 r=padenot (c0900de1df)
- crashtest for bug 1206362 r=padenot (07ace6a42f)
- Bug 1207546 - Integrate WebRTC with audio channels, r=roc (0ecafba529)
- Bug 1219478: Replace PRLogModuleInfo usage with LazyLogModule in dom folders except media.r=amerchesini (2e67bd7308)
- Bug 1198422 - CSP: Allow nonce to load if default-src is not specified in second policy (r=dveditz) (8a8bca1eb3)
- Bug 1187152 (part 1) - Replace nsBaseHashtable::Enumerate() calls in modules/ with iterators. r=mwu. (85cea6dce7)
- Bug 1187152 (part 2) - Replace nsBaseHashtable::Enumerate() calls in modules/ with iterators. r=froydnj. (e909442934)
- Bug 1187152 (part 3) - Replace nsBaseHashtable::Enumerate() calls in modules/ with iterators. r=froydnj. (48c78d75e6)
This commit is contained in:
2023-03-23 10:03:31 +08:00
parent 7bf7c35e9f
commit 21cd830e68
70 changed files with 502 additions and 377 deletions
+41 -58
View File
@@ -261,60 +261,10 @@ public:
protected:
static const uint32_t kSuspectReferentCount = 1000;
static PLDHashOperator CountReferents(PrefCallback* aKey,
nsAutoPtr<PrefCallback>& aCallback,
void* aClosure);
};
NS_IMPL_ISUPPORTS(PreferenceServiceReporter, nsIMemoryReporter)
struct PreferencesReferentCount {
PreferencesReferentCount() : numStrong(0), numWeakAlive(0), numWeakDead(0) {}
size_t numStrong;
size_t numWeakAlive;
size_t numWeakDead;
nsTArray<nsCString> suspectPreferences;
// Count of the number of referents for each preference.
nsDataHashtable<nsCStringHashKey, uint32_t> prefCounter;
};
PLDHashOperator
PreferenceServiceReporter::CountReferents(PrefCallback* aKey,
nsAutoPtr<PrefCallback>& aCallback,
void* aClosure)
{
PreferencesReferentCount* referentCount =
static_cast<PreferencesReferentCount*>(aClosure);
nsPrefBranch* prefBranch = aCallback->GetPrefBranch();
const char* pref = prefBranch->getPrefName(aCallback->GetDomain().get());
if (aCallback->IsWeak()) {
nsCOMPtr<nsIObserver> callbackRef = do_QueryReferent(aCallback->mWeakRef);
if (callbackRef) {
referentCount->numWeakAlive++;
} else {
referentCount->numWeakDead++;
}
} else {
referentCount->numStrong++;
}
nsDependentCString prefString(pref);
uint32_t oldCount = 0;
referentCount->prefCounter.Get(prefString, &oldCount);
uint32_t currentCount = oldCount + 1;
referentCount->prefCounter.Put(prefString, currentCount);
// Keep track of preferences that have a suspiciously large
// number of referents (symptom of leak).
if (currentCount == kSuspectReferentCount) {
referentCount->suspectPreferences.AppendElement(prefString);
}
return PL_DHASH_NEXT;
}
MOZ_DEFINE_MALLOC_SIZE_OF(PreferenceServiceMallocSizeOf)
NS_IMETHODIMP
@@ -342,13 +292,46 @@ PreferenceServiceReporter::CollectReports(nsIMemoryReporterCallback* aCb,
return NS_OK;
}
PreferencesReferentCount referentCount;
rootBranch->mObservers.Enumerate(&CountReferents, &referentCount);
size_t numStrong = 0;
size_t numWeakAlive = 0;
size_t numWeakDead = 0;
nsTArray<nsCString> suspectPreferences;
// Count of the number of referents for each preference.
nsDataHashtable<nsCStringHashKey, uint32_t> prefCounter;
for (uint32_t i = 0; i < referentCount.suspectPreferences.Length(); i++) {
nsCString& suspect = referentCount.suspectPreferences[i];
for (auto iter = rootBranch->mObservers.Iter(); !iter.Done(); iter.Next()) {
nsAutoPtr<PrefCallback>& callback = iter.Data();
nsPrefBranch* prefBranch = callback->GetPrefBranch();
const char* pref = prefBranch->getPrefName(callback->GetDomain().get());
if (callback->IsWeak()) {
nsCOMPtr<nsIObserver> callbackRef = do_QueryReferent(callback->mWeakRef);
if (callbackRef) {
numWeakAlive++;
} else {
numWeakDead++;
}
} else {
numStrong++;
}
nsDependentCString prefString(pref);
uint32_t oldCount = 0;
prefCounter.Get(prefString, &oldCount);
uint32_t currentCount = oldCount + 1;
prefCounter.Put(prefString, currentCount);
// Keep track of preferences that have a suspiciously large number of
// referents (a symptom of a leak).
if (currentCount == kSuspectReferentCount) {
suspectPreferences.AppendElement(prefString);
}
}
for (uint32_t i = 0; i < suspectPreferences.Length(); i++) {
nsCString& suspect = suspectPreferences[i];
uint32_t totalReferentCount = 0;
referentCount.prefCounter.Get(suspect, &totalReferentCount);
prefCounter.Get(suspect, &totalReferentCount);
nsPrintfCString suspectPath("preference-service-suspect/"
"referent(pref=%s)", suspect.get());
@@ -360,16 +343,16 @@ PreferenceServiceReporter::CollectReports(nsIMemoryReporterCallback* aCb,
}
REPORT(NS_LITERAL_CSTRING("preference-service/referent/strong"),
KIND_OTHER, UNITS_COUNT, referentCount.numStrong,
KIND_OTHER, UNITS_COUNT, numStrong,
"The number of strong referents held by the preference service.");
REPORT(NS_LITERAL_CSTRING("preference-service/referent/weak/alive"),
KIND_OTHER, UNITS_COUNT, referentCount.numWeakAlive,
KIND_OTHER, UNITS_COUNT, numWeakAlive,
"The number of weak referents held by the preference service "
"that are still alive.");
REPORT(NS_LITERAL_CSTRING("preference-service/referent/weak/dead"),
KIND_OTHER, UNITS_COUNT, referentCount.numWeakDead,
KIND_OTHER, UNITS_COUNT, numWeakDead,
"The number of weak referents held by the preference service "
"that are dead.");