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
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 07 Jun 2017 09:59:00 +0200
changeset 413129 d95970dc9b7d41ed028960c7aeacd3584bdef689
parent 413128 a8011068db5a26fc837f8e78fb7e38d38822c2f6
child 413130 985626bc4d9c44f1bb12f808276a256397596d0b
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1366356
milestone55.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 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
dom/ipc/ProcessPriorityManager.cpp
hal/Hal.cpp
hal/Hal.h
hal/fallback/FallbackProcessPriority.cpp
hal/sandbox/SandboxHal.cpp
--- a/dom/ipc/ProcessPriorityManager.cpp
+++ b/dom/ipc/ProcessPriorityManager.cpp
@@ -327,17 +327,17 @@ ProcessPriorityManagerImpl::PrefChangedC
     sSingleton = nullptr;
     sInitialized = false;
   }
 }
 
 /* static */ bool
 ProcessPriorityManagerImpl::PrefsEnabled()
 {
-  return sPrefsEnabled && !sRemoteTabsDisabled;
+  return sPrefsEnabled && hal::SetProcessPrioritySupported() && !sRemoteTabsDisabled;
 }
 
 /* static */ bool
 ProcessPriorityManagerImpl::TestMode()
 {
   return sTestMode;
 }
 
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -845,16 +845,22 @@ NotifySwitchChange(const SwitchEvent& aE
   // first. We should check if this pointer is valid.
   if (!sSwitchObserverLists)
     return;
 
   SwitchObserverList& observer = GetSwitchObserverList(aEvent.device());
   observer.Broadcast(aEvent);
 }
 
+bool
+SetProcessPrioritySupported()
+{
+  RETURN_PROXY_IF_SANDBOXED(SetProcessPrioritySupported(), false);
+}
+
 void
 SetProcessPriority(int aPid, ProcessPriority aPriority)
 {
   // n.b. The sandboxed implementation crashes; SetProcessPriority works only
   // from the main process.
   PROXY_IF_SANDBOXED(SetProcessPriority(aPid, aPriority));
 }
 
--- a/hal/Hal.h
+++ b/hal/Hal.h
@@ -426,16 +426,22 @@ hal::SwitchState GetCurrentSwitchState(h
 
 /**
  * Notify switch status change from input device.
  */
 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.
  *
  * Exactly what this does will vary between platforms.  On *nix we might give
  * background processes higher nice values.  On other platforms, we might
  * ignore this call entirely.
  */
 void SetProcessPriority(int aPid, hal::ProcessPriority aPriority);
 
--- a/hal/fallback/FallbackProcessPriority.cpp
+++ b/hal/fallback/FallbackProcessPriority.cpp
@@ -5,16 +5,22 @@
 #include "Hal.h"
 #include "HalLog.h"
 
 using namespace mozilla::hal;
 
 namespace mozilla {
 namespace hal_impl {
 
+bool
+SetProcessPrioritySupported()
+{
+  return false;
+}
+
 void
 SetProcessPriority(int aPid, ProcessPriority aPriority)
 {
   HAL_LOG("FallbackProcessPriority - SetProcessPriority(%d, %s)\n",
           aPid, ProcessPriorityToString(aPriority));
 }
 
 } // namespace hal_impl
--- a/hal/sandbox/SandboxHal.cpp
+++ b/hal/sandbox/SandboxHal.cpp
@@ -349,16 +349,23 @@ SetAlarm(int32_t aSeconds, int32_t aNano
 }
 
 void
 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)
 {
   NS_RUNTIMEABORT("Setting current thread priority cannot be called from sandboxed contexts.");
 }
 
 void
 SetThreadPriority(PlatformThreadId aThreadId,