Index: ipc/ipc_message.cc |
diff --git a/ipc/ipc_message.cc b/ipc/ipc_message.cc |
index 9908bc7a001bd2ce3770ec1e789d8fbb4c133b20..5cb12ad733398499f47887dcb04937a33c146ba1 100644 |
--- a/ipc/ipc_message.cc |
+++ b/ipc/ipc_message.cc |
@@ -4,6 +4,7 @@ |
#include "ipc/ipc_message.h" |
+#include "base/atomicops.h" |
#include "base/logging.h" |
#include "build/build_config.h" |
@@ -11,6 +12,22 @@ |
#include "ipc/file_descriptor_set_posix.h" |
#endif |
+namespace { |
+ |
+base::subtle::Atomic32 g_ref_num = 0; |
+ |
+inline uint32 GetRefNumUpper24() { |
jam
2012/08/31 23:07:55
nit: add a comment
jbates
2012/08/31 23:27:49
Done.
|
+ int32 pid = base::debug::TraceLog::GetInstance()->process_id(); |
+ int32 count = base::subtle::NoBarrier_AtomicIncrement(&g_ref_num, 1); |
+ // The 24 bit hash is composed of 14 bits of the count and 10 bits of the |
+ // Process ID. With the current trace event buffer cap, the 14-bit count did |
+ // not appear to wrap during a trace. Note that it is not a big deal if |
+ // collisions occur, as this is only used for debugging and trace analysis. |
+ return ((pid << 14) | (count & 0x3fff)) << 8; |
+} |
+ |
+} // namespace |
+ |
namespace IPC { |
//------------------------------------------------------------------------------ |
@@ -20,7 +37,8 @@ Message::~Message() { |
Message::Message() |
: Pickle(sizeof(Header)) { |
- header()->routing = header()->type = header()->flags = 0; |
+ header()->routing = header()->type = 0; |
+ 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
|
#if defined(OS_POSIX) |
header()->num_fds = 0; |
header()->pad = 0; |
@@ -32,7 +50,8 @@ Message::Message(int32 routing_id, uint32 type, PriorityValue priority) |
: Pickle(sizeof(Header)) { |
header()->routing = routing_id; |
header()->type = type; |
- header()->flags = priority; |
+ DCHECK((priority & 0xffffff00) == 0); |
+ header()->flags = priority | GetRefNumUpper24(); |
#if defined(OS_POSIX) |
header()->num_fds = 0; |
header()->pad = 0; |