OLD | NEW |
1 // Copyright 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_H_ | 5 #ifndef BASE_PROCESS_PROCESS_H_ |
6 #define BASE_PROCESS_PROCESS_H_ | 6 #define BASE_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" |
11 #include "base/process/process_handle.h" | 11 #include "base/process/process_handle.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 // Waits for the process to exit. Returns true on success. | 101 // Waits for the process to exit. Returns true on success. |
102 // On POSIX, if the process has been signaled then |exit_code| is set to -1. | 102 // On POSIX, if the process has been signaled then |exit_code| is set to -1. |
103 // On Linux this must be a child process, however on Mac and Windows it can be | 103 // On Linux this must be a child process, however on Mac and Windows it can be |
104 // any process. | 104 // any process. |
105 bool WaitForExit(int* exit_code); | 105 bool WaitForExit(int* exit_code); |
106 | 106 |
107 // Same as WaitForExit() but only waits for up to |timeout|. | 107 // Same as WaitForExit() but only waits for up to |timeout|. |
108 bool WaitForExitWithTimeout(TimeDelta timeout, int* exit_code); | 108 bool WaitForExitWithTimeout(TimeDelta timeout, int* exit_code); |
109 | 109 |
110 #if defined(OS_MACOSX) | |
111 // The Mac needs a Mach port in order to manipulate a process's priority, | |
112 // and there's no good way to get that from base given the pid. These Mac | |
113 // variants of the IsProcessBackgrounded and SetProcessBackgrounded API take | |
114 // the Mach port for this reason. See crbug.com/460102 | |
115 // | |
116 // A process is backgrounded when its priority is lower than normal. | |
117 // Return true if the process with mach port |task_port| is backgrounded, | |
118 // false otherwise. | |
119 bool IsProcessBackgrounded(mach_port_t task_port) const; | |
120 | |
121 // Set the process with the specified mach port as backgrounded. If value is | |
122 // true, the priority of the process will be lowered. If value is false, the | |
123 // priority of the process will be made "normal" - equivalent to default | |
124 // process priority. Returns true if the priority was changed, false | |
125 // otherwise. | |
126 bool SetProcessBackgrounded(mach_port_t task_port, bool value); | |
127 #else | |
128 // A process is backgrounded when it's priority is lower than normal. | 110 // A process is backgrounded when it's priority is lower than normal. |
129 // Return true if this process is backgrounded, false otherwise. | 111 // Return true if this process is backgrounded, false otherwise. |
130 bool IsProcessBackgrounded() const; | 112 bool IsProcessBackgrounded() const; |
131 | 113 |
132 // Set a process as backgrounded. If value is true, the priority of the | 114 // Set a process as backgrounded. If value is true, the priority of the |
133 // process will be lowered. If value is false, the priority of the process | 115 // process will be lowered. If value is false, the priority of the process |
134 // will be made "normal" - equivalent to default process priority. | 116 // will be made "normal" - equivalent to default process priority. |
135 // Returns true if the priority was changed, false otherwise. | 117 // Returns true if the priority was changed, false otherwise. |
136 bool SetProcessBackgrounded(bool value); | 118 bool SetProcessBackgrounded(bool value); |
137 #endif // defined(OS_MACOSX) | 119 |
138 // Returns an integer representing the priority of a process. The meaning | 120 // Returns an integer representing the priority of a process. The meaning |
139 // of this value is OS dependent. | 121 // of this value is OS dependent. |
140 int GetPriority() const; | 122 int GetPriority() const; |
141 | 123 |
142 private: | 124 private: |
143 #if defined(OS_WIN) | 125 #if defined(OS_WIN) |
144 bool is_current_process_; | 126 bool is_current_process_; |
145 win::ScopedHandle process_; | 127 win::ScopedHandle process_; |
146 #else | 128 #else |
147 ProcessHandle process_; | 129 ProcessHandle process_; |
148 #endif | 130 #endif |
149 }; | 131 }; |
150 | 132 |
151 } // namespace base | 133 } // namespace base |
152 | 134 |
153 #endif // BASE_PROCESS_PROCESS_H_ | 135 #endif // BASE_PROCESS_PROCESS_H_ |
OLD | NEW |