Chromium Code Reviews| 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. | |
|
danakj
2015/06/17 17:17:16
Is it on android?
rickyz (no longer on Chrome)
2015/06/17 19:53:41
Yeah, I considered that to be part of Linux since
| |
| 38 const uint32 kInvalidUniqueId = 0; | |
| 39 | |
| 37 // Returns the id of the current process. | 40 // Returns the id of the current process. |
| 41 // Note that on some platforms, this is not guaranteed to be unique across | |
| 42 // processes (use GetUniqueIdForProcess if uniqueness is required). | |
| 38 BASE_EXPORT ProcessId GetCurrentProcId(); | 43 BASE_EXPORT ProcessId GetCurrentProcId(); |
| 39 | 44 |
| 45 // Returns a unique ID for the current process. The ID will be unique across all | |
| 46 // currently running processes within the chrome session, but note that IDs of | |
| 47 // terminated processes may be reused. This defaults to the process's process | |
| 48 // ID, but may return a different value if SetUniqueIdForProcess has been | |
| 49 // called. | |
| 50 BASE_EXPORT uint32 GetUniqueIdForProcess(); | |
| 51 | |
| 52 // Sets the unique ID for the current process. |unique_id| may not be | |
| 53 // kInvalidUniqueId. Not thread safe. | |
| 54 // WARNING: To avoid inconsistent results from GetUniqueIdForProcess, this | |
|
danakj
2015/06/17 17:17:16
Can you DCHECK that when SetUniqueId is called, Ge
rickyz (no longer on Chrome)
2015/06/17 19:53:41
It's not required to call SetUniqueId before GetUn
danakj
2015/06/17 19:56:23
What I'd like is for GetUniqueId to always return
| |
| 55 // should only be called very early after process startup - ideally as soon | |
| 56 // after process creation as possible. | |
| 57 BASE_EXPORT void SetUniqueIdForProcess(uint32 unique_id); | |
| 58 | |
| 40 // Returns the ProcessHandle of the current process. | 59 // Returns the ProcessHandle of the current process. |
| 41 BASE_EXPORT ProcessHandle GetCurrentProcessHandle(); | 60 BASE_EXPORT ProcessHandle GetCurrentProcessHandle(); |
| 42 | 61 |
| 43 // Returns the unique ID for the specified process. This is functionally the | 62 // Returns the process ID for the specified process. This is functionally the |
| 44 // same as Windows' GetProcessId(), but works on versions of Windows before | 63 // same as Windows' GetProcessId(), but works on versions of Windows before Win |
| 45 // Win XP SP1 as well. | 64 // XP SP1 as well. |
| 46 // DEPRECATED. New code should be using Process::Pid() instead. | 65 // DEPRECATED. New code should be using Process::Pid() instead. |
| 66 // Note that on some platforms, this is not guaranteed to be unique across | |
| 67 // processes. | |
| 47 BASE_EXPORT ProcessId GetProcId(ProcessHandle process); | 68 BASE_EXPORT ProcessId GetProcId(ProcessHandle process); |
| 48 | 69 |
| 49 #if defined(OS_POSIX) | 70 #if defined(OS_POSIX) |
| 50 // Returns the path to the executable of the given process. | 71 // Returns the path to the executable of the given process. |
| 51 BASE_EXPORT FilePath GetProcessExecutablePath(ProcessHandle process); | 72 BASE_EXPORT FilePath GetProcessExecutablePath(ProcessHandle process); |
| 52 | 73 |
| 53 // Returns the ID for the parent of the given process. | 74 // Returns the ID for the parent of the given process. |
| 54 BASE_EXPORT ProcessId GetParentProcessId(ProcessHandle process); | 75 BASE_EXPORT ProcessId GetParentProcessId(ProcessHandle process); |
| 55 #endif | 76 #endif |
| 56 | 77 |
| 57 } // namespace base | 78 } // namespace base |
| 58 | 79 |
| 59 #endif // BASE_PROCESS_PROCESS_HANDLE_H_ | 80 #endif // BASE_PROCESS_PROCESS_HANDLE_H_ |
| OLD | NEW |