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

Side by Side Diff: base/process/process.h

Issue 989703002: Add support for backgrounding processes on the Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_PROCESS_PROCESS_PROCESS_H_ 5 #ifndef BASE_PROCESS_PROCESS_PROCESS_H_
6 #define BASE_PROCESS_PROCESS_PROCESS_H_ 6 #define BASE_PROCESS_PROCESS_PROCESS_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/move.h" 10 #include "base/move.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 // Waits for the process to exit. Returns true on success. 99 // Waits for the process to exit. Returns true on success.
100 // On POSIX, if the process has been signaled then |exit_code| is set to -1. 100 // On POSIX, if the process has been signaled then |exit_code| is set to -1.
101 // On Linux this must be a child process, however on Mac and Windows it can be 101 // On Linux this must be a child process, however on Mac and Windows it can be
102 // any process. 102 // any process.
103 bool WaitForExit(int* exit_code); 103 bool WaitForExit(int* exit_code);
104 104
105 // Same as WaitForExit() but only waits for up to |timeout|. 105 // Same as WaitForExit() but only waits for up to |timeout|.
106 bool WaitForExitWithTimeout(TimeDelta timeout, int* exit_code); 106 bool WaitForExitWithTimeout(TimeDelta timeout, int* exit_code);
107 107
108 #if defined(OS_MACOSX)
109 // The Mac needs a Mach port in order to manipulate a process's priority,
110 // and there's no good way to get that from base:: given the pid. These
111 // Mac variants of the IsProcessBackgrounded and SetProcessBackgrounded API
112 // take the Mach port for this reason. See crbug.com/460102
113 //
114 // A process is backgrounded when it's priority is lower than normal.
115 // Return true if the process with mach port |process_port| is backgrounded,
116 // false otherwise.
117 bool IsProcessBackgrounded(mach_port_t process_port) const;
118
119 // Set the process with the specified mach port as backgrounded. If value is
120 // true, the priority of the process will be lowered. If value is false, the
121 // priority of the process will be made "normal" - equivalent to default
122 // process priority. Returns true if the priority was changed, false
123 // otherwise.
124 bool SetProcessBackgrounded(mach_port_t process_port, bool value);
125 #else
108 // A process is backgrounded when it's priority is lower than normal. 126 // A process is backgrounded when it's priority is lower than normal.
109 // Return true if this process is backgrounded, false otherwise. 127 // Return true if this process is backgrounded, false otherwise.
110 bool IsProcessBackgrounded() const; 128 bool IsProcessBackgrounded() const;
111 129
112 // Set a process as backgrounded. If value is true, the priority of the 130 // Set a process as backgrounded. If value is true, the priority of the
113 // process will be lowered. If value is false, the priority of the process 131 // process will be lowered. If value is false, the priority of the process
114 // will be made "normal" - equivalent to default process priority. 132 // will be made "normal" - equivalent to default process priority.
115 // Returns true if the priority was changed, false otherwise. 133 // Returns true if the priority was changed, false otherwise.
116 bool SetProcessBackgrounded(bool value); 134 bool SetProcessBackgrounded(bool value);
117 135 #endif // defined(OS_MACOSX)
118 // Returns an integer representing the priority of a process. The meaning 136 // Returns an integer representing the priority of a process. The meaning
119 // of this value is OS dependent. 137 // of this value is OS dependent.
120 int GetPriority() const; 138 int GetPriority() const;
121 139
122 private: 140 private:
123 #if defined(OS_WIN) 141 #if defined(OS_WIN)
124 bool is_current_process_; 142 bool is_current_process_;
125 win::ScopedHandle process_; 143 win::ScopedHandle process_;
126 #else 144 #else
127 ProcessHandle process_; 145 ProcessHandle process_;
128 #endif 146 #endif
129 }; 147 };
130 148
131 } // namespace base 149 } // namespace base
132 150
133 #endif // BASE_PROCESS_PROCESS_PROCESS_H_ 151 #endif // BASE_PROCESS_PROCESS_PROCESS_H_
OLDNEW
« no previous file with comments | « base/base.gypi ('k') | base/process/process_mac.cc » ('j') | base/process/process_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698