Bug 838616 - Boost preallocated process's priority sooner after we decide to transform it into an app process. r=cjones
authorJustin Lebar <justin.lebar@gmail.com>
Fri, 08 Feb 2013 14:32:23 +0000
changeset 131203 b7b4cfecd9dc6a07a70723fa2185208211affead
parent 131202 fd0993e9805b10d79bf397d2cb3f10f2512e66d6
child 131204 4fb612f6279f5d42f3d572bb9b69e494e59852cf
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscjones
bugs838616
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 838616 - Boost preallocated process's priority sooner after we decide to transform it into an app process. r=cjones
dom/ipc/ContentParent.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -535,16 +535,26 @@ ContentParent::Init()
 void
 ContentParent::TransformPreallocatedIntoApp(const nsAString& aAppManifestURL,
                                             ChildPrivileges aPrivs)
 {
     MOZ_ASSERT(mAppManifestURL == MAGIC_PREALLOCATED_APP_MANIFEST_URL);
     // Clients should think of mAppManifestURL as const ... we're
     // bending the rules here just for the preallocation hack.
     const_cast<nsString&>(mAppManifestURL) = aAppManifestURL;
+
+    // Boost this process's priority.  The subprocess will call
+    // TemporarilySetProcessPriorityToForeground() from within
+    // ContentChild::AllocPBrowser, but this happens earlier, thus reducing the
+    // window in which the child might be killed due to low memory.
+    if (Preferences::GetBool("dom.ipc.processPriorityManager.enabled")) {
+        SetProcessPriority(base::GetProcId(mSubprocess->GetChildProcessHandle()),
+                           PROCESS_PRIORITY_FOREGROUND);
+    }
+
     // If this fails, the child process died.
     unused << SendSetProcessPrivileges(aPrivs);
 }
 
 void
 ContentParent::ShutDownProcess()
 {
   if (!mIsDestroyed) {