OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 | 12 |
13 #ifdef OS_WIN | 13 #if defined(OS_WIN) |
14 #include <windows.h> | 14 #include <windows.h> |
15 #include <tlhelp32.h> | 15 #include <tlhelp32.h> |
| 16 #elif defined(OS_LINUX) |
| 17 #include <dirent.h> |
| 18 #include <limits.h> |
| 19 #include <sys/types.h> |
16 #endif | 20 #endif |
17 | 21 |
18 #include <string> | 22 #include <string> |
19 | 23 |
20 #include "base/command_line.h" | 24 #include "base/command_line.h" |
21 #include "base/process.h" | 25 #include "base/process.h" |
22 | 26 |
23 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
24 typedef PROCESSENTRY32 ProcessEntry; | 28 typedef PROCESSENTRY32 ProcessEntry; |
25 typedef IO_COUNTERS IoCounters; | 29 typedef IO_COUNTERS IoCounters; |
26 #elif defined(OS_POSIX) | 30 #elif defined(OS_POSIX) |
27 typedef int ProcessEntry; | 31 struct ProcessEntry { |
| 32 int pid; |
| 33 int ppid; |
| 34 char szExeFile[NAME_MAX+1]; |
| 35 }; |
| 36 |
28 struct IoCounters { | 37 struct IoCounters { |
29 unsigned long long ReadOperationCount; | 38 unsigned long long ReadOperationCount; |
30 unsigned long long WriteOperationCount; | 39 unsigned long long WriteOperationCount; |
31 unsigned long long OtherOperationCount; | 40 unsigned long long OtherOperationCount; |
32 unsigned long long ReadTransferCount; | 41 unsigned long long ReadTransferCount; |
33 unsigned long long WriteTransferCount; | 42 unsigned long long WriteTransferCount; |
34 unsigned long long OtherTransferCount; | 43 unsigned long long OtherTransferCount; |
35 }; | 44 }; |
36 #endif | 45 #endif |
37 | 46 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // that process's info if there is one, false otherwise. | 174 // that process's info if there is one, false otherwise. |
166 bool CheckForNextProcess(); | 175 bool CheckForNextProcess(); |
167 | 176 |
168 bool IncludeEntry(); | 177 bool IncludeEntry(); |
169 | 178 |
170 // Initializes a PROCESSENTRY32 data structure so that it's ready for | 179 // Initializes a PROCESSENTRY32 data structure so that it's ready for |
171 // use with Process32First/Process32Next. | 180 // use with Process32First/Process32Next. |
172 void InitProcessEntry(ProcessEntry* entry); | 181 void InitProcessEntry(ProcessEntry* entry); |
173 | 182 |
174 std::wstring executable_name_; | 183 std::wstring executable_name_; |
175 #ifdef OS_WIN | 184 |
| 185 #if defined(OS_WIN) |
176 HANDLE snapshot_; | 186 HANDLE snapshot_; |
| 187 bool started_iteration_; |
| 188 #elif defined(OS_LINUX) |
| 189 DIR *procfs_dir_; |
| 190 #elif defined(OS_MACOSX) |
| 191 // probably kvm_t *kvmd_; |
177 #endif | 192 #endif |
178 bool started_iteration_; | 193 |
179 ProcessEntry entry_; | 194 ProcessEntry entry_; |
180 const ProcessFilter* filter_; | 195 const ProcessFilter* filter_; |
181 | 196 |
182 DISALLOW_EVIL_CONSTRUCTORS(NamedProcessIterator); | 197 DISALLOW_EVIL_CONSTRUCTORS(NamedProcessIterator); |
183 }; | 198 }; |
184 | 199 |
185 // Working Set (resident) memory usage broken down by | 200 // Working Set (resident) memory usage broken down by |
186 // priv (private): These pages (kbytes) cannot be shared with any other process. | 201 // priv (private): These pages (kbytes) cannot be shared with any other process. |
187 // shareable: These pages (kbytes) can be shared with other processes under | 202 // shareable: These pages (kbytes) can be shared with other processes under |
188 // the right circumstances. | 203 // the right circumstances. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 // overflow. Has no effect if the OS doesn't provide the necessary facility. | 309 // overflow. Has no effect if the OS doesn't provide the necessary facility. |
295 void EnableTerminationOnHeapCorruption(); | 310 void EnableTerminationOnHeapCorruption(); |
296 | 311 |
297 // If supported on the platform, and the user has sufficent rights, increase | 312 // If supported on the platform, and the user has sufficent rights, increase |
298 // the current process's scheduling priority to a high priority. | 313 // the current process's scheduling priority to a high priority. |
299 void RaiseProcessToHighPriority(); | 314 void RaiseProcessToHighPriority(); |
300 | 315 |
301 } // namespace process_util | 316 } // namespace process_util |
302 | 317 |
303 #endif // BASE_PROCESS_UTIL_H_ | 318 #endif // BASE_PROCESS_UTIL_H_ |
OLD | NEW |