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 |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 | 13 |
14 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
15 #include <windows.h> | 15 #include <windows.h> |
16 #include <tlhelp32.h> | 16 #include <tlhelp32.h> |
17 #elif defined(OS_MACOSX) | 17 #elif defined(OS_MACOSX) || defined(OS_OPENBSD) |
18 // kinfo_proc is defined in <sys/sysctl.h>, but this forward declaration | 18 // kinfo_proc is defined in <sys/sysctl.h>, but this forward declaration |
19 // is sufficient for the vector<kinfo_proc> below. | 19 // is sufficient for the vector<kinfo_proc> below. |
20 struct kinfo_proc; | 20 struct kinfo_proc; |
21 // malloc_zone_t is defined in <malloc/malloc.h>, but this forward declaration | 21 // malloc_zone_t is defined in <malloc/malloc.h>, but this forward declaration |
22 // is sufficient for GetPurgeableZone() below. | 22 // is sufficient for GetPurgeableZone() below. |
23 typedef struct _malloc_zone_t malloc_zone_t; | 23 typedef struct _malloc_zone_t malloc_zone_t; |
| 24 #if !defined(OS_OPENBSD) |
24 #include <mach/mach.h> | 25 #include <mach/mach.h> |
| 26 #endif |
25 #elif defined(OS_POSIX) | 27 #elif defined(OS_POSIX) |
26 #include <dirent.h> | 28 #include <dirent.h> |
27 #include <limits.h> | 29 #include <limits.h> |
28 #include <sys/types.h> | 30 #include <sys/types.h> |
29 #endif | 31 #endif |
30 | 32 |
31 #include <list> | 33 #include <list> |
32 #include <string> | 34 #include <string> |
33 #include <utility> | 35 #include <utility> |
34 #include <vector> | 36 #include <vector> |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 // that process's info if there is one, false otherwise. | 521 // that process's info if there is one, false otherwise. |
520 bool CheckForNextProcess(); | 522 bool CheckForNextProcess(); |
521 | 523 |
522 // Initializes a PROCESSENTRY32 data structure so that it's ready for | 524 // Initializes a PROCESSENTRY32 data structure so that it's ready for |
523 // use with Process32First/Process32Next. | 525 // use with Process32First/Process32Next. |
524 void InitProcessEntry(ProcessEntry* entry); | 526 void InitProcessEntry(ProcessEntry* entry); |
525 | 527 |
526 #if defined(OS_WIN) | 528 #if defined(OS_WIN) |
527 HANDLE snapshot_; | 529 HANDLE snapshot_; |
528 bool started_iteration_; | 530 bool started_iteration_; |
529 #elif defined(OS_MACOSX) | 531 #elif defined(OS_MACOSX) || defined(OS_OPENBSD) |
530 std::vector<kinfo_proc> kinfo_procs_; | 532 std::vector<kinfo_proc> kinfo_procs_; |
531 size_t index_of_kinfo_proc_; | 533 size_t index_of_kinfo_proc_; |
532 #elif defined(OS_POSIX) | 534 #elif defined(OS_POSIX) |
533 DIR *procfs_dir_; | 535 DIR *procfs_dir_; |
534 #endif | 536 #endif |
535 ProcessEntry entry_; | 537 ProcessEntry entry_; |
536 const ProcessFilter* filter_; | 538 const ProcessFilter* filter_; |
537 | 539 |
538 DISALLOW_COPY_AND_ASSIGN(ProcessIterator); | 540 DISALLOW_COPY_AND_ASSIGN(ProcessIterator); |
539 }; | 541 }; |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 // instance running inside the parent. The parent's Breakpad instance should | 774 // instance running inside the parent. The parent's Breakpad instance should |
773 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler | 775 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler |
774 // in the child after forking will restore the standard exception handler. | 776 // in the child after forking will restore the standard exception handler. |
775 // See http://crbug.com/20371/ for more details. | 777 // See http://crbug.com/20371/ for more details. |
776 void RestoreDefaultExceptionHandler(); | 778 void RestoreDefaultExceptionHandler(); |
777 #endif // defined(OS_MACOSX) | 779 #endif // defined(OS_MACOSX) |
778 | 780 |
779 } // namespace base | 781 } // namespace base |
780 | 782 |
781 #endif // BASE_PROCESS_UTIL_H_ | 783 #endif // BASE_PROCESS_UTIL_H_ |
OLD | NEW |