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" |
(...skipping 16 matching lines...) Expand all Loading... | |
27 const ProcessHandle kNullProcessHandle = NULL; | 27 const ProcessHandle kNullProcessHandle = NULL; |
28 const ProcessId kNullProcessId = 0; | 28 const ProcessId kNullProcessId = 0; |
29 #elif defined(OS_POSIX) | 29 #elif defined(OS_POSIX) |
30 // On POSIX, our ProcessHandle will just be the PID. | 30 // On POSIX, our ProcessHandle will just be the PID. |
31 typedef pid_t ProcessHandle; | 31 typedef pid_t ProcessHandle; |
32 typedef pid_t ProcessId; | 32 typedef pid_t ProcessId; |
33 const ProcessHandle kNullProcessHandle = 0; | 33 const ProcessHandle kNullProcessHandle = 0; |
34 const ProcessId kNullProcessId = 0; | 34 const ProcessId kNullProcessId = 0; |
35 #endif // defined(OS_WIN) | 35 #endif // defined(OS_WIN) |
36 | 36 |
37 // This is not a valid process ID on Linux, Mac, or Windows. | |
38 const uint32 kInvalidUniqueId = 0; | |
39 | |
37 // Returns the id of the current process. | 40 // Returns the id of the current process. |
38 BASE_EXPORT ProcessId GetCurrentProcId(); | 41 BASE_EXPORT ProcessId GetCurrentProcId(); |
39 | 42 |
43 // Returns a unique ID for the current process. The ID will be unique across all | |
44 // currently running processes within the chrome session, but note that IDs of | |
45 // terminated processes may be reused. This defaults to the process's process | |
46 // ID, but may return a different value if SetUniqueIdForProcess has been | |
47 // called. | |
48 BASE_EXPORT uint32 GetUniqueIdForProcess(); | |
49 | |
50 // Sets the unique ID for the current process. |unique_id| may not be | |
51 // kInvalidUniqueId. Not thread safe. | |
52 // WARNING: To avoid inconsistent results from GetUniqueIdForProcess, this | |
53 // should only be called very early after process startup - ideally as soon | |
54 // after process creation as possible. | |
55 BASE_EXPORT void SetUniqueIdForProcess(uint32 unique_id); | |
56 | |
40 // Returns the ProcessHandle of the current process. | 57 // Returns the ProcessHandle of the current process. |
41 BASE_EXPORT ProcessHandle GetCurrentProcessHandle(); | 58 BASE_EXPORT ProcessHandle GetCurrentProcessHandle(); |
42 | 59 |
43 // Returns the unique ID for the specified process. This is functionally the | 60 // Returns the unique ID for the specified process. This is functionally the |
jln (very slow on Chromium)
2015/06/16 22:59:01
Maybe change the comment here saying that it's not
rickyz (no longer on Chrome)
2015/06/17 00:50:34
Done, and added a comment to GetCurrentProcId.
| |
44 // same as Windows' GetProcessId(), but works on versions of Windows before | 61 // same as Windows' GetProcessId(), but works on versions of Windows before |
45 // Win XP SP1 as well. | 62 // Win XP SP1 as well. |
46 // DEPRECATED. New code should be using Process::Pid() instead. | 63 // DEPRECATED. New code should be using Process::Pid() instead. |
jln (very slow on Chromium)
2015/06/16 22:59:01
Should we add a comment that Process::Pid() is a v
rickyz (no longer on Chrome)
2015/06/17 00:50:34
I didn't mention Process::Pid(), since that sounde
| |
47 BASE_EXPORT ProcessId GetProcId(ProcessHandle process); | 64 BASE_EXPORT ProcessId GetProcId(ProcessHandle process); |
48 | 65 |
49 #if defined(OS_POSIX) | 66 #if defined(OS_POSIX) |
50 // Returns the path to the executable of the given process. | 67 // Returns the path to the executable of the given process. |
51 BASE_EXPORT FilePath GetProcessExecutablePath(ProcessHandle process); | 68 BASE_EXPORT FilePath GetProcessExecutablePath(ProcessHandle process); |
52 | 69 |
53 // Returns the ID for the parent of the given process. | 70 // Returns the ID for the parent of the given process. |
54 BASE_EXPORT ProcessId GetParentProcessId(ProcessHandle process); | 71 BASE_EXPORT ProcessId GetParentProcessId(ProcessHandle process); |
55 #endif | 72 #endif |
56 | 73 |
57 } // namespace base | 74 } // namespace base |
58 | 75 |
59 #endif // BASE_PROCESS_PROCESS_HANDLE_H_ | 76 #endif // BASE_PROCESS_PROCESS_HANDLE_H_ |
OLD | NEW |