Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2594)

Unified Diff: base/process/process_handle.h

Issue 1186873006: Add Get/SetUniqueIdForProcess. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/process/BUILD.gn ('k') | base/process/process_handle.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process/process_handle.h
diff --git a/base/process/process_handle.h b/base/process/process_handle.h
index 77f2c585cfcc71087596855fa6f83ac643ce9a6c..0e667c882396c4ea9f9ed8aed0f0142fc8714729 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>
+#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
@@ -35,15 +36,36 @@ const ProcessId kNullProcessId = 0;
#endif // defined(OS_WIN)
// Returns the id of the current process.
+// Note that on some platforms, this is not guaranteed to be unique across
+// 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 IDs of terminated
+// processes may be reused. This returns an opaque value that is different from
+// a process's PID.
+BASE_EXPORT uint32_t GetUniqueIdForProcess();
+
+#if defined(OS_LINUX)
+// When a process is started in a different PID namespace from the browser
+// process, this function must be called with the process's PID in the browser's
+// PID namespace in order to initialize its unique ID. 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 InitUniqueIdForProcessInPidNamespace(
+ ProcessId pid_outside_of_namespace);
+#endif
+
// 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
+// processes.
BASE_EXPORT ProcessId GetProcId(ProcessHandle process);
#if defined(OS_POSIX)
« no previous file with comments | « base/process/BUILD.gn ('k') | base/process/process_handle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698