Skip to content

Commit

Permalink
Bug 1320395: Part 1 - Allow keeping non-default process types alive. …
Browse files Browse the repository at this point in the history
…r=bobowen,gabor

MozReview-Commit-ID: 6TvKN3wFLms
  • Loading branch information
kmaglione committed Jan 12, 2017
1 parent 0395a07 commit c117aeb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions dom/ipc/ContentParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1608,21 +1608,22 @@ ContentParent::ShouldKeepProcessAlive() const
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 might want to keep alive some content processes alive during test runs,
// for performance reasons. This should never be used in production.
// 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))) {
return false;
}

int32_t numberOfAliveProcesses = contentParents->Length();

return numberOfAliveProcesses <= processesToKeepAlive;
Expand Down
2 changes: 1 addition & 1 deletion testing/mochitest/browser-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function testInit() {
if (processCount > 1) {
// Currently starting a content process is slow, to aviod timeouts, let's
// keep alive content processes.
prefs.setIntPref("dom.ipc.keepProcessesAlive", processCount);
prefs.setIntPref("dom.ipc.keepProcessesAlive.web", processCount);
}

let globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
Expand Down

0 comments on commit c117aeb

Please sign in to comment.