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 // This file/namespace contains utility functions for enumerating, ending and | 5 // This file/namespace contains utility functions for enumerating, ending and |
6 // computing statistics of processes. | 6 // computing statistics of processes. |
7 | 7 |
8 #ifndef BASE_PROCESS_UTIL_H_ | 8 #ifndef BASE_PROCESS_UTIL_H_ |
9 #define BASE_PROCESS_UTIL_H_ | 9 #define BASE_PROCESS_UTIL_H_ |
10 #pragma once | 10 #pragma once |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 // Closes the process handle opened by OpenProcessHandle. | 158 // Closes the process handle opened by OpenProcessHandle. |
159 BASE_API void CloseProcessHandle(ProcessHandle process); | 159 BASE_API void CloseProcessHandle(ProcessHandle process); |
160 | 160 |
161 // Returns the unique ID for the specified process. This is functionally the | 161 // Returns the unique ID for the specified process. This is functionally the |
162 // same as Windows' GetProcessId(), but works on versions of Windows before | 162 // same as Windows' GetProcessId(), but works on versions of Windows before |
163 // Win XP SP1 as well. | 163 // Win XP SP1 as well. |
164 BASE_API ProcessId GetProcId(ProcessHandle process); | 164 BASE_API ProcessId GetProcId(ProcessHandle process); |
165 | 165 |
166 #if defined(OS_LINUX) | 166 #if defined(OS_LINUX) |
167 // Returns the path to the executable of the given process. | 167 // Returns the path to the executable of the given process. |
168 BASE_API FilePath GetProcessExecutablePath(ProcessHandle process); | 168 FilePath GetProcessExecutablePath(ProcessHandle process); |
169 | 169 |
170 // Parse the data found in /proc/<pid>/stat and return the sum of the | 170 // Parse the data found in /proc/<pid>/stat and return the sum of the |
171 // CPU-related ticks. Returns -1 on parse error. | 171 // CPU-related ticks. Returns -1 on parse error. |
172 // Exposed for testing. | 172 // Exposed for testing. |
173 BASE_API int ParseProcStatCPU(const std::string& input); | 173 BASE_API int ParseProcStatCPU(const std::string& input); |
174 | 174 |
175 static const char kAdjustOOMScoreSwitch[] = "--adjust-oom-score"; | 175 static const char kAdjustOOMScoreSwitch[] = "--adjust-oom-score"; |
176 | 176 |
177 // This adjusts /proc/process/oom_adj so the Linux OOM killer will prefer | 177 // This adjusts /proc/process/oom_adj so the Linux OOM killer will prefer |
178 // certain process types over others. The range for the adjustment is | 178 // certain process types over others. The range for the adjustment is |
179 // [-17,15], with [0,15] being user accessible. | 179 // [-17,15], with [0,15] being user accessible. |
180 BASE_API bool AdjustOOMScore(ProcessId process, int score); | 180 bool AdjustOOMScore(ProcessId process, int score); |
181 #endif | 181 #endif |
182 | 182 |
183 #if defined(OS_POSIX) | 183 #if defined(OS_POSIX) |
184 // Returns the ID for the parent of the given process. | 184 // Returns the ID for the parent of the given process. |
185 BASE_API ProcessId GetParentProcessId(ProcessHandle process); | 185 BASE_API ProcessId GetParentProcessId(ProcessHandle process); |
186 | 186 |
187 // Close all file descriptors, except those which are a destination in the | 187 // Close all file descriptors, except those which are a destination in the |
188 // given multimap. Only call this function in a child process where you know | 188 // given multimap. Only call this function in a child process where you know |
189 // that there aren't any other threads. | 189 // that there aren't any other threads. |
190 BASE_API void CloseSuperfluousFds(const InjectiveMultimap& saved_map); | 190 void CloseSuperfluousFds(const InjectiveMultimap& saved_map); |
191 #endif | 191 #endif |
192 | 192 |
193 #if defined(OS_WIN) | 193 #if defined(OS_WIN) |
194 | 194 |
195 enum IntegrityLevel { | 195 enum IntegrityLevel { |
196 INTEGRITY_UNKNOWN, | 196 INTEGRITY_UNKNOWN, |
197 LOW_INTEGRITY, | 197 LOW_INTEGRITY, |
198 MEDIUM_INTEGRITY, | 198 MEDIUM_INTEGRITY, |
199 HIGH_INTEGRITY, | 199 HIGH_INTEGRITY, |
200 }; | 200 }; |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 // instance running inside the parent. The parent's Breakpad instance should | 673 // instance running inside the parent. The parent's Breakpad instance should |
674 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler | 674 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler |
675 // in the child after forking will restore the standard exception handler. | 675 // in the child after forking will restore the standard exception handler. |
676 // See http://crbug.com/20371/ for more details. | 676 // See http://crbug.com/20371/ for more details. |
677 void RestoreDefaultExceptionHandler(); | 677 void RestoreDefaultExceptionHandler(); |
678 #endif // defined(OS_MACOSX) | 678 #endif // defined(OS_MACOSX) |
679 | 679 |
680 } // namespace base | 680 } // namespace base |
681 | 681 |
682 #endif // BASE_PROCESS_UTIL_H_ | 682 #endif // BASE_PROCESS_UTIL_H_ |
OLD | NEW |