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

Side by Side Diff: ipc/ipc_message.cc

Issue 177123004: Use StaticAtomicSequenceNumber instead of subtle::Atomic32 in IPCMessage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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 | « AUTHORS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "ipc/ipc_message.h" 5 #include "ipc/ipc_message.h"
6 6
7 #include "base/atomicops.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 10
11 #if defined(OS_POSIX) 11 #if defined(OS_POSIX)
12 #include "ipc/file_descriptor_set_posix.h" 12 #include "ipc/file_descriptor_set_posix.h"
13 #endif 13 #endif
14 14
15 namespace { 15 namespace {
16 16
17 base::subtle::Atomic32 g_ref_num = 0; 17 base::StaticAtomicSequenceNumber g_ref_num;
18 18
19 // Create a reference number for identifying IPC messages in traces. The return 19 // Create a reference number for identifying IPC messages in traces. The return
20 // values has the reference number stored in the upper 24 bits, leaving the low 20 // values has the reference number stored in the upper 24 bits, leaving the low
21 // 8 bits set to 0 for use as flags. 21 // 8 bits set to 0 for use as flags.
22 inline uint32 GetRefNumUpper24() { 22 inline uint32 GetRefNumUpper24() {
23 base::debug::TraceLog* trace_log = base::debug::TraceLog::GetInstance(); 23 base::debug::TraceLog* trace_log = base::debug::TraceLog::GetInstance();
24 int32 pid = trace_log ? trace_log->process_id() : 0; 24 int32 pid = trace_log ? trace_log->process_id() : 0;
25 int32 count = base::subtle::NoBarrier_AtomicIncrement(&g_ref_num, 1); 25 int32 count = g_ref_num.GetNext();
tulloch 2014/02/24 19:38:10 Note that now `g_ref_num` counts from 0 instead of
26 // The 24 bit hash is composed of 14 bits of the count and 10 bits of the 26 // The 24 bit hash is composed of 14 bits of the count and 10 bits of the
27 // Process ID. With the current trace event buffer cap, the 14-bit count did 27 // Process ID. With the current trace event buffer cap, the 14-bit count did
28 // not appear to wrap during a trace. Note that it is not a big deal if 28 // not appear to wrap during a trace. Note that it is not a big deal if
29 // collisions occur, as this is only used for debugging and trace analysis. 29 // collisions occur, as this is only used for debugging and trace analysis.
30 return ((pid << 14) | (count & 0x3fff)) << 8; 30 return ((pid << 14) | (count & 0x3fff)) << 8;
31 } 31 }
32 32
33 } // namespace 33 } // namespace
34 34
35 namespace IPC { 35 namespace IPC {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 153 }
154 154
155 void Message::EnsureFileDescriptorSet() { 155 void Message::EnsureFileDescriptorSet() {
156 if (file_descriptor_set_.get() == NULL) 156 if (file_descriptor_set_.get() == NULL)
157 file_descriptor_set_ = new FileDescriptorSet; 157 file_descriptor_set_ = new FileDescriptorSet;
158 } 158 }
159 159
160 #endif 160 #endif
161 161
162 } // namespace IPC 162 } // namespace IPC
OLDNEW
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698