Bug 1693541 - Improve uses of nsBaseHashtable and descendants and avoid multiple subsequent lookups in dom/ipc. r=nika

Differential Revision: https://phabricator.services.mozilla.com/D106103
This commit is contained in:
Simon Giesecke 2021-03-09 08:20:54 +00:00
parent b23dcf46c1
commit 193e2b0899
3 changed files with 24 additions and 19 deletions

View File

@ -2681,7 +2681,7 @@ void BrowserChild::InitRenderingState(
if (!sBrowserChildren) {
sBrowserChildren = new BrowserChildMap;
}
MOZ_ASSERT(!sBrowserChildren->Get(uint64_t(aLayersId)));
MOZ_ASSERT(!sBrowserChildren->Contains(uint64_t(aLayersId)));
sBrowserChildren->InsertOrUpdate(uint64_t(aLayersId), this);
mLayersId = aLayersId;
}

View File

@ -3189,7 +3189,7 @@ void ContentChild::CreateGetFilesRequest(const nsAString& aDirectoryPath,
bool aRecursiveFlag, nsID& aUUID,
GetFilesHelperChild* aChild) {
MOZ_ASSERT(aChild);
MOZ_ASSERT(!mGetFilesPendingRequests.GetWeak(aUUID));
MOZ_ASSERT(!mGetFilesPendingRequests.Contains(aUUID));
Unused << SendGetFilesRequest(aUUID, nsString(aDirectoryPath),
aRecursiveFlag);
@ -3199,7 +3199,7 @@ void ContentChild::CreateGetFilesRequest(const nsAString& aDirectoryPath,
void ContentChild::DeleteGetFilesRequest(nsID& aUUID,
GetFilesHelperChild* aChild) {
MOZ_ASSERT(aChild);
MOZ_ASSERT(mGetFilesPendingRequests.GetWeak(aUUID));
MOZ_ASSERT(mGetFilesPendingRequests.Contains(aUUID));
Unused << SendDeleteGetFilesRequest(aUUID);
mGetFilesPendingRequests.Remove(aUUID);

View File

@ -877,23 +877,28 @@ void HangMonitorParent::ClearHangNotification() {
bool HangMonitorParent::TakeBrowserMinidump(const PluginHangData& aPhd,
nsString& aCrashId) {
MutexAutoLock lock(mBrowserCrashDumpHashLock);
if (!mBrowserCrashDumpIds.Get(aPhd.pluginId(), &aCrashId)) {
nsCOMPtr<nsIFile> browserDump;
if (CrashReporter::TakeMinidump(getter_AddRefs(browserDump), true)) {
if (!CrashReporter::GetIDFromMinidump(browserDump, aCrashId) ||
aCrashId.IsEmpty()) {
browserDump->Remove(false);
NS_WARNING(
"Failed to generate timely browser stack, "
"this is bad for plugin hang analysis!");
} else {
mBrowserCrashDumpIds.InsertOrUpdate(aPhd.pluginId(), aCrashId);
return true;
}
}
}
return mBrowserCrashDumpIds.WithEntryHandle(
aPhd.pluginId(), [&](auto&& entry) {
if (entry) {
aCrashId = entry.Data();
} else {
nsCOMPtr<nsIFile> browserDump;
if (CrashReporter::TakeMinidump(getter_AddRefs(browserDump), true)) {
if (!CrashReporter::GetIDFromMinidump(browserDump, aCrashId) ||
aCrashId.IsEmpty()) {
browserDump->Remove(false);
NS_WARNING(
"Failed to generate timely browser stack, "
"this is bad for plugin hang analysis!");
} else {
entry.Insert(aCrashId);
return true;
}
}
}
return false;
return false;
});
}
mozilla::ipc::IPCResult HangMonitorParent::RecvHangEvidence(