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

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

Issue 1186873006: Add Get/SetUniqueIdForProcess. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to comments. 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
« no previous file with comments | « base/process/process_handle.h ('k') | content/zygote/zygote_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
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/basictypes.h"
6 #include "base/logging.h"
7 #include "base/process/process_handle.h"
8
9 namespace base {
10
11 namespace {
12 uint32 g_unique_id = kInvalidUniqueId;
13
14 #if DCHECK_IS_ON()
15 // The process which set g_unique_id.
16 uint32 g_procid;
17 #endif
18 } // namespace
19
20 uint32 GetUniqueIdForProcess() {
21 if (g_unique_id == kInvalidUniqueId) {
22 return static_cast<uint32>(GetCurrentProcId());
23 }
24
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);
danakj 2015/08/05 19:52:26 you'll have to wrap this in DCHECK_IS_ON() too, or
29 return g_unique_id;
30 }
31
32 void SetUniqueIdForProcess(uint32 unique_id) {
33 g_unique_id = unique_id;
34 #if DCHECK_IS_ON()
35 g_procid = static_cast<uint32>(GetCurrentProcId());
36 #endif
37 }
38
39 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process_handle.h ('k') | content/zygote/zygote_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698