OLD | NEW |
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" |
11 #include "base/process/process_handle.h" | 11 #include "base/process/process_handle.h" |
| 12 #include "base/time/time.h" |
12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
13 | 14 |
14 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
15 #include "base/win/scoped_handle.h" | 16 #include "base/win/scoped_handle.h" |
16 #endif | 17 #endif |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 | 20 |
20 // Provides a move-only encapsulation of a process. | 21 // Provides a move-only encapsulation of a process. |
21 // | 22 // |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 bool is_current() const; | 75 bool is_current() const; |
75 | 76 |
76 // Close the process handle. This will not terminate the process. | 77 // Close the process handle. This will not terminate the process. |
77 void Close(); | 78 void Close(); |
78 | 79 |
79 // Terminates the process with extreme prejudice. The given |result_code| will | 80 // Terminates the process with extreme prejudice. The given |result_code| will |
80 // be the exit code of the process. | 81 // be the exit code of the process. |
81 // NOTE: On POSIX |result_code| is ignored. | 82 // NOTE: On POSIX |result_code| is ignored. |
82 void Terminate(int result_code); | 83 void Terminate(int result_code); |
83 | 84 |
| 85 // Waits for the process to exit. Returns true on success. |
| 86 // On POSIX, if the process has been signaled then |exit_code| is set to -1. |
| 87 bool WaitForExit(int* exit_code); |
| 88 |
| 89 // Same as WaitForExit() but only waits for up to |timeout|. |
| 90 bool WaitForExitWithTimeout(TimeDelta timeout, int* exit_code); |
| 91 |
84 // A process is backgrounded when it's priority is lower than normal. | 92 // A process is backgrounded when it's priority is lower than normal. |
85 // Return true if this process is backgrounded, false otherwise. | 93 // Return true if this process is backgrounded, false otherwise. |
86 bool IsProcessBackgrounded() const; | 94 bool IsProcessBackgrounded() const; |
87 | 95 |
88 // Set a process as backgrounded. If value is true, the priority of the | 96 // Set a process as backgrounded. If value is true, the priority of the |
89 // process will be lowered. If value is false, the priority of the process | 97 // process will be lowered. If value is false, the priority of the process |
90 // will be made "normal" - equivalent to default process priority. | 98 // will be made "normal" - equivalent to default process priority. |
91 // Returns true if the priority was changed, false otherwise. | 99 // Returns true if the priority was changed, false otherwise. |
92 bool SetProcessBackgrounded(bool value); | 100 bool SetProcessBackgrounded(bool value); |
93 | 101 |
94 // Returns an integer representing the priority of a process. The meaning | 102 // Returns an integer representing the priority of a process. The meaning |
95 // of this value is OS dependent. | 103 // of this value is OS dependent. |
96 int GetPriority() const; | 104 int GetPriority() const; |
97 | 105 |
98 private: | 106 private: |
99 #if defined(OS_WIN) | 107 #if defined(OS_WIN) |
100 bool is_current_process_; | 108 bool is_current_process_; |
101 win::ScopedHandle process_; | 109 win::ScopedHandle process_; |
102 #else | 110 #else |
103 ProcessHandle process_; | 111 ProcessHandle process_; |
104 #endif | 112 #endif |
105 }; | 113 }; |
106 | 114 |
107 } // namespace base | 115 } // namespace base |
108 | 116 |
109 #endif // BASE_PROCESS_PROCESS_PROCESS_H_ | 117 #endif // BASE_PROCESS_PROCESS_PROCESS_H_ |
OLD | NEW |