Bug 633986 Pref nice value, default to 1 on Android r=dougt a=blocking-fennec

This commit is contained in:
Benjamin Stover 2011-02-14 14:34:46 -08:00
Родитель 133b6f4784
Коммит 46148c1dd1
2 изменённых файлов: 27 добавлений и 22 удалений

Просмотреть файл

@ -88,14 +88,6 @@
#include "nsPermissionManager.h"
#endif
#if defined(ANDROID) || defined(LINUX)
#include <sys/time.h>
#include <sys/resource.h>
// 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<nsIConsoleService> svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
if (svc) {
svc->UnregisterListener(mConsoleListener);

Просмотреть файл

@ -70,6 +70,11 @@
#include "nsConsoleMessage.h"
#include "AudioParent.h"
#if defined(ANDROID) || defined(LINUX)
#include <sys/time.h>
#include <sys/resource.h>
#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<nsIPrefBranch> 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
}
}