OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef BASE_PROCESS_PROCESS_HANDLE_H_ | 5 #ifndef BASE_PROCESS_PROCESS_HANDLE_H_ |
6 #define BASE_PROCESS_PROCESS_HANDLE_H_ | 6 #define BASE_PROCESS_PROCESS_HANDLE_H_ |
7 | 7 |
8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 | 12 |
13 #include <sys/types.h> | 13 #include <sys/types.h> |
14 #if defined(OS_WIN) | |
15 #include <windows.h> | |
16 #endif | |
17 | 14 |
18 namespace base { | 15 namespace base { |
19 | 16 |
20 // ProcessHandle is a platform specific type which represents the underlying OS | 17 // ProcessHandle is a platform specific type which represents the underlying OS |
21 // handle to a process. | 18 // handle to a process. |
22 // ProcessId is a number which identifies the process in the OS. | 19 // ProcessId is a number which identifies the process in the OS. |
23 #if defined(OS_WIN) | 20 #if defined(OS_POSIX) |
24 typedef HANDLE ProcessHandle; | |
25 typedef DWORD ProcessId; | |
26 typedef HANDLE UserTokenHandle; | |
27 const ProcessHandle kNullProcessHandle = NULL; | |
28 const ProcessId kNullProcessId = 0; | |
29 #elif defined(OS_POSIX) | |
30 // On POSIX, our ProcessHandle will just be the PID. | 21 // On POSIX, our ProcessHandle will just be the PID. |
31 typedef pid_t ProcessHandle; | 22 typedef pid_t ProcessHandle; |
32 typedef pid_t ProcessId; | 23 typedef pid_t ProcessId; |
33 const ProcessHandle kNullProcessHandle = 0; | 24 const ProcessHandle kNullProcessHandle = 0; |
34 const ProcessId kNullProcessId = 0; | 25 const ProcessId kNullProcessId = 0; |
35 #endif // defined(OS_WIN) | 26 #endif // defined(OS_POSIX) |
36 | 27 |
37 // Returns the id of the current process. | 28 // Returns the id of the current process. |
38 BASE_EXPORT ProcessId GetCurrentProcId(); | 29 BASE_EXPORT ProcessId GetCurrentProcId(); |
39 | 30 |
40 // Returns the ProcessHandle of the current process. | 31 // Returns the ProcessHandle of the current process. |
41 BASE_EXPORT ProcessHandle GetCurrentProcessHandle(); | 32 BASE_EXPORT ProcessHandle GetCurrentProcessHandle(); |
42 | 33 |
43 // Returns the unique ID for the specified process. This is functionally the | 34 // Returns the unique ID for the specified process. This is functionally the |
44 // same as Windows' GetProcessId(), but works on versions of Windows before | 35 // same as Windows' GetProcessId(), but works on versions of Windows before |
45 // Win XP SP1 as well. | 36 // Win XP SP1 as well. |
46 // DEPRECATED. New code should be using Process::Pid() instead. | 37 // DEPRECATED. New code should be using Process::Pid() instead. |
47 BASE_EXPORT ProcessId GetProcId(ProcessHandle process); | 38 BASE_EXPORT ProcessId GetProcId(ProcessHandle process); |
48 | 39 |
49 #if defined(OS_POSIX) | 40 #if defined(OS_POSIX) |
50 // Returns the path to the executable of the given process. | 41 // Returns the path to the executable of the given process. |
51 BASE_EXPORT FilePath GetProcessExecutablePath(ProcessHandle process); | 42 BASE_EXPORT FilePath GetProcessExecutablePath(ProcessHandle process); |
52 | 43 |
53 // Returns the ID for the parent of the given process. | 44 // Returns the ID for the parent of the given process. |
54 BASE_EXPORT ProcessId GetParentProcessId(ProcessHandle process); | 45 BASE_EXPORT ProcessId GetParentProcessId(ProcessHandle process); |
55 #endif | 46 #endif |
56 | 47 |
57 } // namespace base | 48 } // namespace base |
58 | 49 |
59 #endif // BASE_PROCESS_PROCESS_HANDLE_H_ | 50 #endif // BASE_PROCESS_PROCESS_HANDLE_H_ |
OLD | NEW |