| OLD | NEW |
| 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/atomic_sequence_num.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 #include "ipc/ipc_message_attachment.h" | 10 #include "ipc/ipc_message_attachment.h" |
| 11 #include "ipc/ipc_message_attachment_set.h" | 11 #include "ipc/ipc_message_attachment_set.h" |
| 12 | 12 |
| 13 #if defined(OS_POSIX) | 13 #if defined(OS_POSIX) |
| 14 #include "base/file_descriptor_posix.h" | 14 #include "base/file_descriptor_posix.h" |
| 15 #include "ipc/ipc_platform_file_attachment_posix.h" | 15 #include "ipc/ipc_platform_file_attachment_posix.h" |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 base::StaticAtomicSequenceNumber g_ref_num; | 20 base::StaticAtomicSequenceNumber g_ref_num; |
| 21 | 21 |
| 22 // Create a reference number for identifying IPC messages in traces. The return | 22 // Create a reference number for identifying IPC messages in traces. The return |
| 23 // values has the reference number stored in the upper 24 bits, leaving the low | 23 // values has the reference number stored in the upper 24 bits, leaving the low |
| 24 // 8 bits set to 0 for use as flags. | 24 // 8 bits set to 0 for use as flags. |
| 25 inline uint32 GetRefNumUpper24() { | 25 inline uint32 GetRefNumUpper24() { |
| 26 base::debug::TraceLog* trace_log = base::debug::TraceLog::GetInstance(); | 26 base::trace_event::TraceLog* trace_log = |
| 27 base::trace_event::TraceLog::GetInstance(); |
| 27 uint32 pid = trace_log ? trace_log->process_id() : 0; | 28 uint32 pid = trace_log ? trace_log->process_id() : 0; |
| 28 uint32 count = g_ref_num.GetNext(); | 29 uint32 count = g_ref_num.GetNext(); |
| 29 // The 24 bit hash is composed of 14 bits of the count and 10 bits of the | 30 // The 24 bit hash is composed of 14 bits of the count and 10 bits of the |
| 30 // Process ID. With the current trace event buffer cap, the 14-bit count did | 31 // Process ID. With the current trace event buffer cap, the 14-bit count did |
| 31 // not appear to wrap during a trace. Note that it is not a big deal if | 32 // not appear to wrap during a trace. Note that it is not a big deal if |
| 32 // collisions occur, as this is only used for debugging and trace analysis. | 33 // collisions occur, as this is only used for debugging and trace analysis. |
| 33 return ((pid << 14) | (count & 0x3fff)) << 8; | 34 return ((pid << 14) | (count & 0x3fff)) << 8; |
| 34 } | 35 } |
| 35 | 36 |
| 36 } // namespace | 37 } // namespace |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 154 |
| 154 bool Message::HasAttachments() const { | 155 bool Message::HasAttachments() const { |
| 155 return attachment_set_.get() && !attachment_set_->empty(); | 156 return attachment_set_.get() && !attachment_set_->empty(); |
| 156 } | 157 } |
| 157 | 158 |
| 158 bool Message::HasMojoHandles() const { | 159 bool Message::HasMojoHandles() const { |
| 159 return attachment_set_.get() && 0 < attachment_set_->num_mojo_handles(); | 160 return attachment_set_.get() && 0 < attachment_set_->num_mojo_handles(); |
| 160 } | 161 } |
| 161 | 162 |
| 162 } // namespace IPC | 163 } // namespace IPC |
| OLD | NEW |