Index: base/process/process_handle.h |
diff --git a/base/process/process_handle.h b/base/process/process_handle.h |
index 77f2c585cfcc71087596855fa6f83ac643ce9a6c..6a8f8d0972ba5eecae02a9cae27dc9c8ba035734 100644 |
--- a/base/process/process_handle.h |
+++ b/base/process/process_handle.h |
@@ -5,12 +5,13 @@ |
#ifndef BASE_PROCESS_PROCESS_HANDLE_H_ |
#define BASE_PROCESS_PROCESS_HANDLE_H_ |
+#include <stdint.h> |
danakj
2015/08/05 19:52:26
You want base/basictypes.h, instead of these.
rickyz (no longer on Chrome)
2015/08/13 23:16:55
Is that still the case? https://code.google.com/p/
|
+#include <sys/types.h> |
+ |
#include "base/base_export.h" |
-#include "base/basictypes.h" |
#include "base/files/file_path.h" |
#include "build/build_config.h" |
-#include <sys/types.h> |
#if defined(OS_WIN) |
#include <windows.h> |
#endif |
@@ -34,16 +35,37 @@ const ProcessHandle kNullProcessHandle = 0; |
const ProcessId kNullProcessId = 0; |
#endif // defined(OS_WIN) |
+// This is not a valid process ID on Linux (including Android), Mac, or Windows. |
+const uint32_t kInvalidUniqueId = 0; |
danakj
2015/08/05 19:52:26
Does this need to be in the header? Can it move to
rickyz (no longer on Chrome)
2015/08/13 23:16:55
Don't think so, moved it into the anon namespace i
|
+ |
// Returns the id of the current process. |
+// Note that on some platforms, this is not guaranteed to be unique across |
danakj
2015/08/05 19:52:26
Who would ever want to use this one?
rickyz (no longer on Chrome)
2015/08/13 23:16:55
GetCurrentProcId is still useful for APIs that nee
|
+// processes (use GetUniqueIdForProcess if uniqueness is required). |
BASE_EXPORT ProcessId GetCurrentProcId(); |
+// Returns a unique ID for the current process. The ID will be unique across all |
+// currently running processes within the chrome session, but note that IDs of |
+// terminated processes may be reused. This defaults to the process's process |
+// ID, but may return a different value if SetUniqueIdForProcess has been |
+// called. |
+BASE_EXPORT uint32_t GetUniqueIdForProcess(); |
+ |
+// Sets the unique ID for the current process. |unique_id| may not be |
+// kInvalidUniqueId. Not thread safe. |
+// WARNING: To avoid inconsistent results from GetUniqueIdForProcess, this |
+// should only be called very early after process startup - ideally as soon |
+// after process creation as possible. |
+BASE_EXPORT void SetUniqueIdForProcess(uint32_t unique_id); |
+ |
// Returns the ProcessHandle of the current process. |
BASE_EXPORT ProcessHandle GetCurrentProcessHandle(); |
-// Returns the unique ID for the specified process. This is functionally the |
-// same as Windows' GetProcessId(), but works on versions of Windows before |
-// Win XP SP1 as well. |
+// Returns the process ID for the specified process. This is functionally the |
+// same as Windows' GetProcessId(), but works on versions of Windows before Win |
+// XP SP1 as well. |
// DEPRECATED. New code should be using Process::Pid() instead. |
+// Note that on some platforms, this is not guaranteed to be unique across |
danakj
2015/08/05 19:52:26
Does this mean Process:Pid() can be non-unique (al
rickyz (no longer on Chrome)
2015/08/13 23:16:55
It does, but as mentioned above, there are situati
danakj
2015/09/15 18:06:39
i think i'm not understanding something: if you're
|
+// processes. |
BASE_EXPORT ProcessId GetProcId(ProcessHandle process); |
#if defined(OS_POSIX) |