Index: base/process/process.h |
diff --git a/base/process/process.h b/base/process/process.h |
index 70c8260193247d079009014f28c5bf72388eca00..5538475863b09f65cba4d7bede6db24b27091f4c 100644 |
--- a/base/process/process.h |
+++ b/base/process/process.h |
@@ -15,8 +15,17 @@ |
#include "base/win/scoped_handle.h" |
#endif |
+#if defined(OS_MACOSX) |
+#include "base/feature_list.h" |
+#include "base/process/port_provider_mac.h" |
+#endif |
+ |
namespace base { |
+#if defined(OS_MACOSX) |
+extern const Feature kMacAllowBackgroundingProcesses; |
+#endif |
+ |
// Provides a move-only encapsulation of a process. |
// |
// This object is not tied to the lifetime of the underlying process: the |
@@ -106,6 +115,28 @@ class BASE_EXPORT Process { |
// is not required. |
bool WaitForExitWithTimeout(TimeDelta timeout, int* exit_code); |
+#if defined(OS_MACOSX) |
+ // The Mac needs a Mach port in order to manipulate a process's priority, |
+ // and there's no good way to get that from base given the pid. These Mac |
+ // variants of the IsProcessBackgrounded and SetProcessBackgrounded API take |
+ // a port provider for this reason. See crbug.com/460102 |
+ // |
+ // A process is backgrounded when its task priority is |
+ // |TASK_BACKGROUND_APPLICATION|. |
+ // |
+ // Returns true if the port_provider can locate a task port for the process |
+ // and it is backgrounded. If port_provider is null, returns false. |
+ bool IsProcessBackgrounded(PortProvider* port_provider) const; |
+ |
+ // Set the process as backgrounded. If value is |
+ // true, the priority of the associated task will be set to |
+ // TASK_BACKGROUND_APPLICATION. If value is false, the |
+ // priority of the process will be set to TASK_FOREGROUND_APPLICATION. |
+ // |
+ // Returns true if the priority was changed, false otherwise. If |
+ // |port_provider| is null, this is a no-op and it returns false. |
+ bool SetProcessBackgrounded(PortProvider* port_provider, bool value); |
+#else |
// A process is backgrounded when it's priority is lower than normal. |
// Return true if this process is backgrounded, false otherwise. |
bool IsProcessBackgrounded() const; |
@@ -115,7 +146,7 @@ class BASE_EXPORT Process { |
// will be made "normal" - equivalent to default process priority. |
// Returns true if the priority was changed, false otherwise. |
bool SetProcessBackgrounded(bool value); |
- |
+#endif // defined(OS_MACOSX) |
// Returns an integer representing the priority of a process. The meaning |
// of this value is OS dependent. |
int GetPriority() const; |