| 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 #if defined(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) | 16 #elif defined(OS_LINUX) |
| 17 #include <dirent.h> | 17 #include <dirent.h> |
| 18 #include <limits.h> | 18 #include <limits.h> |
| 19 #include <sys/types.h> | 19 #include <sys/types.h> |
| 20 #endif | 20 #endif |
| 21 | 21 |
| 22 #include <string> | 22 #include <string> |
| 23 #include <vector> |
| 23 | 24 |
| 24 #include "base/command_line.h" | 25 #include "base/command_line.h" |
| 25 #include "base/process.h" | 26 #include "base/process.h" |
| 26 | 27 |
| 27 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
| 28 typedef PROCESSENTRY32 ProcessEntry; | 29 typedef PROCESSENTRY32 ProcessEntry; |
| 29 typedef IO_COUNTERS IoCounters; | 30 typedef IO_COUNTERS IoCounters; |
| 30 #elif defined(OS_POSIX) | 31 #elif defined(OS_POSIX) |
| 32 // TODO(port): we should not rely on a Win32 structure. |
| 31 struct ProcessEntry { | 33 struct ProcessEntry { |
| 32 int pid; | 34 int pid; |
| 33 int ppid; | 35 int ppid; |
| 34 char szExeFile[NAME_MAX+1]; | 36 char szExeFile[NAME_MAX + 1]; |
| 35 }; | 37 }; |
| 36 | 38 |
| 37 struct IoCounters { | 39 struct IoCounters { |
| 38 unsigned long long ReadOperationCount; | 40 unsigned long long ReadOperationCount; |
| 39 unsigned long long WriteOperationCount; | 41 unsigned long long WriteOperationCount; |
| 40 unsigned long long OtherOperationCount; | 42 unsigned long long OtherOperationCount; |
| 41 unsigned long long ReadTransferCount; | 43 unsigned long long ReadTransferCount; |
| 42 unsigned long long WriteTransferCount; | 44 unsigned long long WriteTransferCount; |
| 43 unsigned long long OtherTransferCount; | 45 unsigned long long OtherTransferCount; |
| 44 }; | 46 }; |
| 45 #endif | 47 #endif |
| 46 | 48 |
| 49 #if defined(OS_MACOSX) |
| 50 struct kinfo_proc; |
| 51 #endif |
| 52 |
| 47 namespace base { | 53 namespace base { |
| 48 | 54 |
| 49 // A minimalistic but hopefully cross-platform set of exit codes. | 55 // A minimalistic but hopefully cross-platform set of exit codes. |
| 50 // Do not change the enumeration values or you will break third-party | 56 // Do not change the enumeration values or you will break third-party |
| 51 // installers. | 57 // installers. |
| 52 enum { | 58 enum { |
| 53 PROCESS_END_NORMAL_TERMINATON = 0, | 59 PROCESS_END_NORMAL_TERMINATON = 0, |
| 54 PROCESS_END_KILLED_BY_USER = 1, | 60 PROCESS_END_KILLED_BY_USER = 1, |
| 55 PROCESS_END_PROCESS_WAS_HUNG = 2 | 61 PROCESS_END_PROCESS_WAS_HUNG = 2 |
| 56 }; | 62 }; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 void InitProcessEntry(ProcessEntry* entry); | 214 void InitProcessEntry(ProcessEntry* entry); |
| 209 | 215 |
| 210 std::wstring executable_name_; | 216 std::wstring executable_name_; |
| 211 | 217 |
| 212 #if defined(OS_WIN) | 218 #if defined(OS_WIN) |
| 213 HANDLE snapshot_; | 219 HANDLE snapshot_; |
| 214 bool started_iteration_; | 220 bool started_iteration_; |
| 215 #elif defined(OS_LINUX) | 221 #elif defined(OS_LINUX) |
| 216 DIR *procfs_dir_; | 222 DIR *procfs_dir_; |
| 217 #elif defined(OS_MACOSX) | 223 #elif defined(OS_MACOSX) |
| 218 // probably kvm_t *kvmd_; | 224 std::vector<kinfo_proc> kinfo_procs_; |
| 225 size_t index_of_kinfo_proc_; |
| 219 #endif | 226 #endif |
| 220 | |
| 221 ProcessEntry entry_; | 227 ProcessEntry entry_; |
| 222 const ProcessFilter* filter_; | 228 const ProcessFilter* filter_; |
| 223 | 229 |
| 224 DISALLOW_EVIL_CONSTRUCTORS(NamedProcessIterator); | 230 DISALLOW_EVIL_CONSTRUCTORS(NamedProcessIterator); |
| 225 }; | 231 }; |
| 226 | 232 |
| 227 // Working Set (resident) memory usage broken down by | 233 // Working Set (resident) memory usage broken down by |
| 228 // priv (private): These pages (kbytes) cannot be shared with any other process. | 234 // priv (private): These pages (kbytes) cannot be shared with any other process. |
| 229 // shareable: These pages (kbytes) can be shared with other processes under | 235 // shareable: These pages (kbytes) can be shared with other processes under |
| 230 // the right circumstances. | 236 // the right circumstances. |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 // overflow. Has no effect if the OS doesn't provide the necessary facility. | 342 // overflow. Has no effect if the OS doesn't provide the necessary facility. |
| 337 void EnableTerminationOnHeapCorruption(); | 343 void EnableTerminationOnHeapCorruption(); |
| 338 | 344 |
| 339 // If supported on the platform, and the user has sufficent rights, increase | 345 // If supported on the platform, and the user has sufficent rights, increase |
| 340 // the current process's scheduling priority to a high priority. | 346 // the current process's scheduling priority to a high priority. |
| 341 void RaiseProcessToHighPriority(); | 347 void RaiseProcessToHighPriority(); |
| 342 | 348 |
| 343 } // namespace base | 349 } // namespace base |
| 344 | 350 |
| 345 #endif // BASE_PROCESS_UTIL_H_ | 351 #endif // BASE_PROCESS_UTIL_H_ |
| OLD | NEW |