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

Side by Side Diff: base/process/process_handle.h

Issue 1186873006: Add Get/SetUniqueIdForProcess. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 unified diff | Download patch
OLDNEW
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
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 globally unique ID for the current process. This defaults to the
mdempsky 2015/06/15 21:53:09 I think "globally" might be misinterpretable. It
rickyz (no longer on Chrome) 2015/06/15 22:09:47 Ah, good point, changed.
44 // process process ID, but may return a different value if SetUniqueIdForProcess
mdempsky 2015/06/15 21:53:09 Should "process process ID" be "process's process
rickyz (no longer on Chrome) 2015/06/15 22:09:46 Done.
45 // has been called.
46 BASE_EXPORT uint32 GetUniqueIdForProcess();
47
48 // Sets the unique ID for the current process. |unique_id| may not be
49 // kInvalidUniqueId.
50 // WARNING: To avoid inconsistent results from GetUniqueIdForProcess, this
51 // should only be called very early after process startup - ideally immediately
52 // after fork.
53 BASE_EXPORT void SetUniqueIdForProcess(uint32 unique_id);
54
40 // Returns the ProcessHandle of the current process. 55 // Returns the ProcessHandle of the current process.
41 BASE_EXPORT ProcessHandle GetCurrentProcessHandle(); 56 BASE_EXPORT ProcessHandle GetCurrentProcessHandle();
42 57
43 // Returns the unique ID for the specified process. This is functionally the 58 // Returns the unique ID for the specified process. This is functionally the
44 // same as Windows' GetProcessId(), but works on versions of Windows before 59 // same as Windows' GetProcessId(), but works on versions of Windows before
45 // Win XP SP1 as well. 60 // Win XP SP1 as well.
46 // DEPRECATED. New code should be using Process::Pid() instead. 61 // DEPRECATED. New code should be using Process::Pid() instead.
47 BASE_EXPORT ProcessId GetProcId(ProcessHandle process); 62 BASE_EXPORT ProcessId GetProcId(ProcessHandle process);
48 63
49 #if defined(OS_POSIX) 64 #if defined(OS_POSIX)
50 // Returns the path to the executable of the given process. 65 // Returns the path to the executable of the given process.
51 BASE_EXPORT FilePath GetProcessExecutablePath(ProcessHandle process); 66 BASE_EXPORT FilePath GetProcessExecutablePath(ProcessHandle process);
52 67
53 // Returns the ID for the parent of the given process. 68 // Returns the ID for the parent of the given process.
54 BASE_EXPORT ProcessId GetParentProcessId(ProcessHandle process); 69 BASE_EXPORT ProcessId GetParentProcessId(ProcessHandle process);
55 #endif 70 #endif
56 71
57 } // namespace base 72 } // namespace base
58 73
59 #endif // BASE_PROCESS_PROCESS_HANDLE_H_ 74 #endif // BASE_PROCESS_PROCESS_HANDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698