Chromium Code Reviews| Index: base/process/process_handle.cc |
| diff --git a/base/process/process_handle.cc b/base/process/process_handle.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8b960283c90937b82bb784649892ac6fff93abf5 |
| --- /dev/null |
| +++ b/base/process/process_handle.cc |
| @@ -0,0 +1,40 @@ |
| +// 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.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/logging.h" |
| +#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.
|
| + |
| +namespace base { |
| + |
| +namespace { |
| +uint32 g_unique_id = kInvalidUniqueId; |
| + |
| +#ifndef NDEBUG |
| +// The process which set g_unique_id. |
| +uint32 g_procid; |
| +#endif |
| +} // namespace |
| + |
| +uint32 GetUniqueIdForProcess() { |
| + if (g_unique_id == kInvalidUniqueId) { |
| + return static_cast<uint32>(GetCurrentProcId()); |
| + } |
| + |
| +#ifndef NDEBUG |
| + // Make sure we are the same process that set g_procid. This check may have |
| + // false negatives (if a process ID was reused) but should have no false |
| + // positives. |
| + DCHECK_EQ(static_cast<uint32>(GetCurrentProcId()), g_procid); |
| +#endif |
| + return g_unique_id; |
| +} |
| + |
| +void SetUniqueIdForProcess(uint32 unique_id) { |
| + g_unique_id = unique_id; |
| +#ifndef NDEBUG |
| + g_procid = static_cast<uint32>(GetCurrentProcId()); |
| +#endif |
| +} |
| + |
| +} // namespace base |