diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 8fa4cbc491e..7e3a9b6cc4c 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -88,14 +88,6 @@ #include "nsPermissionManager.h" #endif -#if defined(ANDROID) || defined(LINUX) -#include -#include -// TODO: For other platforms that support setpriority, figure out -// appropriate values of niceness -static const int kRelativeNiceness = 10; -#endif - #include "nsAccelerometer.h" #if defined(ANDROID) @@ -233,18 +225,6 @@ ContentChild::Init(MessageLoop* aIOLoop, NS_ASSERTION(!sSingleton, "only one ContentChild per child"); -#if defined(ANDROID) || defined(LINUX) - // XXX We change the behavior of Linux child processes here. That - // means that, not just in Fennec, but also in Firefox, once it has - // child processes, those will be niced. IOW, Firefox with child processes - // will have different performance profiles on Linux than other - // platforms. This may alter Talos results and so forth. - char* relativeNicenessStr = getenv("MOZ_CHILD_PROCESS_RELATIVE_NICENESS"); - setpriority(PRIO_PROCESS, 0, getpriority(PRIO_PROCESS, 0) + - (relativeNicenessStr ? atoi(relativeNicenessStr) : - kRelativeNiceness)); -#endif - Open(aChannel, aParentHandle, aIOLoop); sSingleton = this; @@ -415,7 +395,7 @@ ContentChild::RecvSetOffline(const PRBool& offline) NS_ASSERTION(io, "IO Service can not be null"); io->SetOffline(offline); - + return true; } @@ -435,7 +415,7 @@ ContentChild::ActorDestroy(ActorDestroyReason why) #endif mAlertObservers.Clear(); - + nsCOMPtr svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID)); if (svc) { svc->UnregisterListener(mConsoleListener); diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index c983ab0bbc5..45595e31f97 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -70,6 +70,11 @@ #include "nsConsoleMessage.h" #include "AudioParent.h" +#if defined(ANDROID) || defined(LINUX) +#include +#include +#endif + #ifdef MOZ_PERMISSIONS #include "nsPermissionManager.h" #endif @@ -145,6 +150,26 @@ ContentParent::OnChannelConnected(int32 pid) } else { SetOtherProcess(handle); + +#if defined(ANDROID) || defined(LINUX) + EnsurePrefService(); + nsCOMPtr branch; + branch = do_QueryInterface(mPrefService); + + // Check nice preference + PRInt32 nice = 0; + branch->GetIntPref("dom.ipc.content.nice", &nice); + + // Environment variable overrides preference + char* relativeNicenessStr = getenv("MOZ_CHILD_PROCESS_RELATIVE_NICENESS"); + if (relativeNicenessStr) { + nice = atoi(relativeNicenessStr); + } + + if (nice != 0) { + setpriority(PRIO_PROCESS, pid, getpriority(PRIO_PROCESS, pid) + nice); + } +#endif } }