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

Side by Side Diff: ipc/ipc_message.cc

Issue 10919023: Add async trace events to trace progress of IPC messages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add pid to IPC message refnum Created 8 years, 3 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 | Annotate | Revision Log
« ipc/ipc_message.h ('K') | « ipc/ipc_message.h ('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/logging.h" 8 #include "base/logging.h"
8 #include "build/build_config.h" 9 #include "build/build_config.h"
9 10
10 #if defined(OS_POSIX) 11 #if defined(OS_POSIX)
11 #include "ipc/file_descriptor_set_posix.h" 12 #include "ipc/file_descriptor_set_posix.h"
12 #endif 13 #endif
13 14
15 namespace {
16
17 base::subtle::Atomic32 g_ref_num = 0;
18
19 inline uint32 GetRefNumUpper24() {
jam 2012/08/31 23:07:55 nit: add a comment
jbates 2012/08/31 23:27:49 Done.
20 int32 pid = base::debug::TraceLog::GetInstance()->process_id();
21 int32 count = base::subtle::NoBarrier_AtomicIncrement(&g_ref_num, 1);
22 // The 24 bit hash is composed of 14 bits of the count and 10 bits of the
23 // Process ID. With the current trace event buffer cap, the 14-bit count did
24 // not appear to wrap during a trace. Note that it is not a big deal if
25 // collisions occur, as this is only used for debugging and trace analysis.
26 return ((pid << 14) | (count & 0x3fff)) << 8;
27 }
28
29 } // namespace
30
14 namespace IPC { 31 namespace IPC {
15 32
16 //------------------------------------------------------------------------------ 33 //------------------------------------------------------------------------------
17 34
18 Message::~Message() { 35 Message::~Message() {
19 } 36 }
20 37
21 Message::Message() 38 Message::Message()
22 : Pickle(sizeof(Header)) { 39 : Pickle(sizeof(Header)) {
23 header()->routing = header()->type = header()->flags = 0; 40 header()->routing = header()->type = 0;
41 header()->flags = GetRefNumUpper24();
jam 2012/08/31 23:07:55 Are you sure this works with the reference builds?
jbates 2012/08/31 23:27:49 The code that accesses flags in this file just che
jam 2012/09/02 00:35:18 you can try running tests which use the reference
24 #if defined(OS_POSIX) 42 #if defined(OS_POSIX)
25 header()->num_fds = 0; 43 header()->num_fds = 0;
26 header()->pad = 0; 44 header()->pad = 0;
27 #endif 45 #endif
28 InitLoggingVariables(); 46 InitLoggingVariables();
29 } 47 }
30 48
31 Message::Message(int32 routing_id, uint32 type, PriorityValue priority) 49 Message::Message(int32 routing_id, uint32 type, PriorityValue priority)
32 : Pickle(sizeof(Header)) { 50 : Pickle(sizeof(Header)) {
33 header()->routing = routing_id; 51 header()->routing = routing_id;
34 header()->type = type; 52 header()->type = type;
35 header()->flags = priority; 53 DCHECK((priority & 0xffffff00) == 0);
54 header()->flags = priority | GetRefNumUpper24();
36 #if defined(OS_POSIX) 55 #if defined(OS_POSIX)
37 header()->num_fds = 0; 56 header()->num_fds = 0;
38 header()->pad = 0; 57 header()->pad = 0;
39 #endif 58 #endif
40 InitLoggingVariables(); 59 InitLoggingVariables();
41 } 60 }
42 61
43 Message::Message(const char* data, int data_len) : Pickle(data, data_len) { 62 Message::Message(const char* data, int data_len) : Pickle(data, data_len) {
44 InitLoggingVariables(); 63 InitLoggingVariables();
45 } 64 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 149 }
131 150
132 void Message::EnsureFileDescriptorSet() { 151 void Message::EnsureFileDescriptorSet() {
133 if (file_descriptor_set_.get() == NULL) 152 if (file_descriptor_set_.get() == NULL)
134 file_descriptor_set_ = new FileDescriptorSet; 153 file_descriptor_set_ = new FileDescriptorSet;
135 } 154 }
136 155
137 #endif 156 #endif
138 157
139 } // namespace IPC 158 } // namespace IPC
OLDNEW
« ipc/ipc_message.h ('K') | « ipc/ipc_message.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698