Bug 1320395: Part 1 - Allow keeping non-default process types alive. r?bobowen
MozReview-Commit-ID: 6TvKN3wFLms
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -1610,31 +1610,37 @@ ContentParent::ShouldKeepProcessAlive()
return false;
}
// If we have already been marked as dead, don't prevent shutdown.
if (!IsAlive()) {
return false;
}
- // Only keep processes for the default remote type alive.
- if (!mRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE)) {
- return false;
- }
-
auto contentParents = sBrowserContentParents->Get(mRemoteType);
if (!contentParents) {
return false;
}
// We might want to keep alive some content processes for testing, because of
// performance reasons.
// We don't want to alter behavior if the pref is not set, so default to 0.
- int32_t processesToKeepAlive =
- Preferences::GetInt("dom.ipc.keepProcessesAlive", 0);
+ int32_t processesToKeepAlive = 0;
+
+ nsAutoCString keepAlivePref("dom.ipc.keepProcessesAlive.");
+ keepAlivePref.Append(NS_ConvertUTF16toUTF8(mRemoteType));
+ if (NS_FAILED(Preferences::GetInt(keepAlivePref.get(), &processesToKeepAlive))) {
+ // Otherwise, only keep processes for the default remote type alive.
+ if (!mRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE)) {
+ return false;
+ }
+
+ processesToKeepAlive = Preferences::GetInt("dom.ipc.keepProcessesAlive", 0);
+ }
+
int32_t numberOfAliveProcesses = contentParents->Length();
return numberOfAliveProcesses <= processesToKeepAlive;
}
void
ContentParent::NotifyTabDestroying(const TabId& aTabId,
const ContentParentId& aCpId)