| 6 |
| 7 | #include <stdint.h> |
| 8 |
| 9 | #include "base/logging.h" |
| 10 | #include "build/build_config.h" |
| 11 |
| 12 | namespace base { |
| 13 |
| 14 | namespace { |
| 15 | ProcessId g_pid_outside_of_namespace = kNullProcessId; |
| 16 | } // namespace |
| 17 |
| 18 | std::ostream& operator<<(std::ostream& os, const UniqueProcId& obj) { |
| 19 | os << obj.GetUnsafeValue(); |
| 20 | return os; |
| 21 | } |
| 22 |
| 23 | UniqueProcId GetUniqueIdForProcess() { |
| 24 | // Used for logging. Must not use LogMessage or any of the macros that call |
| 25 | // into it. |
| 26 | return (g_pid_outside_of_namespace != kNullProcessId) |
| 27 | ? UniqueProcId(g_pid_outside_of_namespace) |
| 28 | : UniqueProcId(GetCurrentProcId()); |
| 29 | } |
| 30 |
| 31 | #if defined(OS_LINUX) || defined(OS_AIX) |
| 32 |
| 33 | void InitUniqueIdForProcessInPidNamespace(ProcessId pid_outside_of_namespace) { |
| 34 | DCHECK(pid_outside_of_namespace != kNullProcessId); |
| 35 | g_pid_outside_of_namespace = pid_outside_of_namespace; |
| 36 | } |
| 37 |
| 38 | #endif |
| 39 |
| 40 | } // namespace base |
| 41 |