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