Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(575)

Unified Diff: base/process/process.h

Issue 2454073003: Allow backgrounding processes on Mac (Closed)
Patch Set: Remove unnecessary forward declare Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/process/process.h
diff --git a/base/process/process.h b/base/process/process.h
index 70c8260193247d079009014f28c5bf72388eca00..ae8e613800925e7841bb1cec75ea2e64b087c299 100644
--- a/base/process/process.h
+++ b/base/process/process.h
@@ -15,6 +15,10 @@
#include "base/win/scoped_handle.h"
#endif
+#if defined(OS_MACOSX)
+#include "base/process/port_provider_mac.h"
+#endif
+
namespace base {
// Provides a move-only encapsulation of a process.
@@ -106,6 +110,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|.
+ // Return true if the port_provider can locate a task port for the process and
+ // it
shrike 2016/10/31 17:26:04 Move straggler "it" to the next line?
lgrey 2016/10/31 19:22:01 Done.
+ // 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 +141,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;
« no previous file with comments | « base/BUILD.gn ('k') | base/process/process_mac.cc » ('j') | base/process/process_mac.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698