| 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 <limits.h> | 7 #include <limits.h> |
| 8 | 8 |
| 9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 namespace IPC { | 43 namespace IPC { |
| 44 | 44 |
| 45 //------------------------------------------------------------------------------ | 45 //------------------------------------------------------------------------------ |
| 46 | 46 |
| 47 Message::~Message() { | 47 Message::~Message() { |
| 48 } | 48 } |
| 49 | 49 |
| 50 Message::Message() : base::Pickle(sizeof(Header)) { | 50 Message::Message() : base::Pickle(sizeof(Header)) { |
| 51 header()->routing = header()->type = 0; | 51 header()->routing = header()->type = 0; |
| 52 header()->flags = GetRefNumUpper24(); | 52 header()->flags = GetRefNumUpper24(); |
| 53 header()->qos_type = 'u'; |
| 54 header()->qos_target = 0; |
| 55 header()->ebs_enabled = false; |
| 53 #if defined(OS_MACOSX) | 56 #if defined(OS_MACOSX) |
| 54 header()->num_brokered_attachments = 0; | 57 header()->num_brokered_attachments = 0; |
| 55 #endif | 58 #endif |
| 56 #if defined(OS_POSIX) | 59 #if defined(OS_POSIX) |
| 57 header()->num_fds = 0; | 60 header()->num_fds = 0; |
| 58 header()->pad = 0; | 61 header()->pad = 0; |
| 59 #endif | 62 #endif |
| 60 Init(); | 63 Init(); |
| 61 } | 64 } |
| 62 | 65 |
| 63 Message::Message(int32_t routing_id, uint32_t type, PriorityValue priority) | 66 Message::Message(int32_t routing_id, uint32_t type, PriorityValue priority) |
| 64 : base::Pickle(sizeof(Header)) { | 67 : base::Pickle(sizeof(Header)) { |
| 65 header()->routing = routing_id; | 68 header()->routing = routing_id; |
| 66 header()->type = type; | 69 header()->type = type; |
| 67 DCHECK((priority & 0xffffff00) == 0); | 70 DCHECK((priority & 0xffffff00) == 0); |
| 68 header()->flags = priority | GetRefNumUpper24(); | 71 header()->flags = priority | GetRefNumUpper24(); |
| 72 header()->qos_type = 'u'; |
| 73 header()->qos_target = 0; |
| 74 header()->ebs_enabled = false; |
| 69 #if defined(OS_MACOSX) | 75 #if defined(OS_MACOSX) |
| 70 header()->num_brokered_attachments = 0; | 76 header()->num_brokered_attachments = 0; |
| 71 #endif | 77 #endif |
| 72 #if defined(OS_POSIX) | 78 #if defined(OS_POSIX) |
| 73 header()->num_fds = 0; | 79 header()->num_fds = 0; |
| 74 header()->pad = 0; | 80 header()->pad = 0; |
| 75 #endif | 81 #endif |
| 76 Init(); | 82 Init(); |
| 77 } | 83 } |
| 78 | 84 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 104 return *this; | 110 return *this; |
| 105 } | 111 } |
| 106 | 112 |
| 107 void Message::SetHeaderValues(int32_t routing, uint32_t type, uint32_t flags) { | 113 void Message::SetHeaderValues(int32_t routing, uint32_t type, uint32_t flags) { |
| 108 // This should only be called when the message is already empty. | 114 // This should only be called when the message is already empty. |
| 109 DCHECK(payload_size() == 0); | 115 DCHECK(payload_size() == 0); |
| 110 | 116 |
| 111 header()->routing = routing; | 117 header()->routing = routing; |
| 112 header()->type = type; | 118 header()->type = type; |
| 113 header()->flags = flags; | 119 header()->flags = flags; |
| 120 header()->qos_type = 'u'; |
| 121 header()->qos_target = 0; |
| 122 header()->ebs_enabled = false; |
| 114 } | 123 } |
| 115 | 124 |
| 116 void Message::EnsureMessageAttachmentSet() { | 125 void Message::EnsureMessageAttachmentSet() { |
| 117 if (attachment_set_.get() == NULL) | 126 if (attachment_set_.get() == NULL) |
| 118 attachment_set_ = new MessageAttachmentSet; | 127 attachment_set_ = new MessageAttachmentSet; |
| 119 } | 128 } |
| 120 | 129 |
| 121 #ifdef IPC_MESSAGE_LOG_ENABLED | 130 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 122 void Message::set_sent_time(int64_t time) { | 131 void Message::set_sent_time(int64_t time) { |
| 123 DCHECK((header()->flags & HAS_SENT_TIME_BIT) == 0); | 132 DCHECK((header()->flags & HAS_SENT_TIME_BIT) == 0); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 bool Message::HasMojoHandles() const { | 299 bool Message::HasMojoHandles() const { |
| 291 return attachment_set_.get() && attachment_set_->num_mojo_handles() > 0; | 300 return attachment_set_.get() && attachment_set_->num_mojo_handles() > 0; |
| 292 } | 301 } |
| 293 | 302 |
| 294 bool Message::HasBrokerableAttachments() const { | 303 bool Message::HasBrokerableAttachments() const { |
| 295 return attachment_set_.get() && | 304 return attachment_set_.get() && |
| 296 attachment_set_->num_brokerable_attachments() > 0; | 305 attachment_set_->num_brokerable_attachments() > 0; |
| 297 } | 306 } |
| 298 | 307 |
| 299 } // namespace IPC | 308 } // namespace IPC |
| OLD | NEW |