Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
|
jln (very slow on Chromium)
2015/06/16 22:59:01
New file, so remove (c) and use 2015
rickyz (no longer on Chrome)
2015/06/17 00:50:34
Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/logging.h" | |
| 6 #include "base/process/process_handle.h" | |
|
jln (very slow on Chromium)
2015/06/16 22:59:01
Don't forget basictypes.h
rickyz (no longer on Chrome)
2015/06/17 00:50:34
Done.
| |
| 7 | |
| 8 namespace base { | |
| 9 | |
| 10 namespace { | |
| 11 uint32 g_unique_id = kInvalidUniqueId; | |
| 12 | |
| 13 #ifndef NDEBUG | |
| 14 // The process which set g_unique_id. | |
| 15 uint32 g_procid; | |
| 16 #endif | |
| 17 } // namespace | |
| 18 | |
| 19 uint32 GetUniqueIdForProcess() { | |
| 20 if (g_unique_id == kInvalidUniqueId) { | |
| 21 return static_cast<uint32>(GetCurrentProcId()); | |
| 22 } | |
| 23 | |
| 24 #ifndef NDEBUG | |
| 25 // Make sure we are the same process that set g_procid. This check may have | |
| 26 // false negatives (if a process ID was reused) but should have no false | |
| 27 // positives. | |
| 28 DCHECK_EQ(static_cast<uint32>(GetCurrentProcId()), g_procid); | |
| 29 #endif | |
| 30 return g_unique_id; | |
| 31 } | |
| 32 | |
| 33 void SetUniqueIdForProcess(uint32 unique_id) { | |
| 34 g_unique_id = unique_id; | |
| 35 #ifndef NDEBUG | |
| 36 g_procid = static_cast<uint32>(GetCurrentProcId()); | |
| 37 #endif | |
| 38 } | |
| 39 | |
| 40 } // namespace base | |
| OLD | NEW |