Bug 1366356 - Decrease the process priority of content processes that are not running a foreground tab - part 2 - enabled if the platform specific code is ready, r=smaug

This commit is contained in:
Andrea Marchesini 2017-06-07 09:59:00 +02:00
parent 61f1dc1bf7
commit 44e8750e68
5 changed files with 26 additions and 1 deletions

View File

@ -332,7 +332,7 @@ ProcessPriorityManagerImpl::PrefChangedCallback(const char* aPref,
/* static */ bool
ProcessPriorityManagerImpl::PrefsEnabled()
{
return sPrefsEnabled && !sRemoteTabsDisabled;
return sPrefsEnabled && hal::SetProcessPrioritySupported() && !sRemoteTabsDisabled;
}
/* static */ bool

View File

@ -850,6 +850,12 @@ NotifySwitchChange(const SwitchEvent& aEvent)
observer.Broadcast(aEvent);
}
bool
SetProcessPrioritySupported()
{
RETURN_PROXY_IF_SANDBOXED(SetProcessPrioritySupported(), false);
}
void
SetProcessPriority(int aPid, ProcessPriority aPriority)
{

View File

@ -430,6 +430,12 @@ hal::SwitchState GetCurrentSwitchState(hal::SwitchDevice aDevice);
void NotifySwitchStateFromInputDevice(hal::SwitchDevice aDevice,
hal::SwitchState aState);
/**
* Return true if the current platform supports the setting of process
* priority.
*/
bool SetProcessPrioritySupported();
/**
* Set the priority of the given process.
*

View File

@ -10,6 +10,12 @@ using namespace mozilla::hal;
namespace mozilla {
namespace hal_impl {
bool
SetProcessPrioritySupported()
{
return false;
}
void
SetProcessPriority(int aPid, ProcessPriority aPriority)
{

View File

@ -354,6 +354,13 @@ SetProcessPriority(int aPid, ProcessPriority aPriority)
NS_RUNTIMEABORT("Only the main process may set processes' priorities.");
}
bool
SetProcessPrioritySupported()
{
NS_RUNTIMEABORT("Only the main process may call SetProcessPrioritySupported().");
return false;
}
void
SetCurrentThreadPriority(ThreadPriority aThreadPriority)
{