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" |
(...skipping 28 matching lines...) Expand all Loading... |
39 namespace IPC { | 39 namespace IPC { |
40 | 40 |
41 //------------------------------------------------------------------------------ | 41 //------------------------------------------------------------------------------ |
42 | 42 |
43 Message::~Message() { | 43 Message::~Message() { |
44 } | 44 } |
45 | 45 |
46 Message::Message() : base::Pickle(sizeof(Header)) { | 46 Message::Message() : base::Pickle(sizeof(Header)) { |
47 header()->routing = header()->type = 0; | 47 header()->routing = header()->type = 0; |
48 header()->flags = GetRefNumUpper24(); | 48 header()->flags = GetRefNumUpper24(); |
| 49 #if USE_ATTACHMENT_BROKER |
| 50 header()->num_brokered_attachments = 0; |
| 51 #endif |
49 #if defined(OS_POSIX) | 52 #if defined(OS_POSIX) |
50 header()->num_fds = 0; | 53 header()->num_fds = 0; |
51 header()->pad = 0; | 54 header()->pad = 0; |
52 #endif | 55 #endif |
53 Init(); | 56 Init(); |
54 } | 57 } |
55 | 58 |
56 Message::Message(int32 routing_id, uint32 type, PriorityValue priority) | 59 Message::Message(int32 routing_id, uint32 type, PriorityValue priority) |
57 : base::Pickle(sizeof(Header)) { | 60 : base::Pickle(sizeof(Header)) { |
58 header()->routing = routing_id; | 61 header()->routing = routing_id; |
59 header()->type = type; | 62 header()->type = type; |
60 DCHECK((priority & 0xffffff00) == 0); | 63 DCHECK((priority & 0xffffff00) == 0); |
61 header()->flags = priority | GetRefNumUpper24(); | 64 header()->flags = priority | GetRefNumUpper24(); |
| 65 #if USE_ATTACHMENT_BROKER |
| 66 header()->num_brokered_attachments = 0; |
| 67 #endif |
62 #if defined(OS_POSIX) | 68 #if defined(OS_POSIX) |
63 header()->num_fds = 0; | 69 header()->num_fds = 0; |
64 header()->pad = 0; | 70 header()->pad = 0; |
65 #endif | 71 #endif |
66 Init(); | 72 Init(); |
67 } | 73 } |
68 | 74 |
69 Message::Message(const char* data, int data_len) | 75 Message::Message(const char* data, int data_len) |
70 : base::Pickle(data, data_len) { | 76 : base::Pickle(data, data_len) { |
71 Init(); | 77 Init(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 130 |
125 void Message::set_received_time(int64 time) const { | 131 void Message::set_received_time(int64 time) const { |
126 received_time_ = time; | 132 received_time_ = time; |
127 } | 133 } |
128 #endif | 134 #endif |
129 | 135 |
130 bool Message::WriteAttachment(scoped_refptr<MessageAttachment> attachment) { | 136 bool Message::WriteAttachment(scoped_refptr<MessageAttachment> attachment) { |
131 // We write the index of the descriptor so that we don't have to | 137 // We write the index of the descriptor so that we don't have to |
132 // keep the current descriptor as extra decoding state when deserialising. | 138 // keep the current descriptor as extra decoding state when deserialising. |
133 WriteInt(attachment_set()->size()); | 139 WriteInt(attachment_set()->size()); |
| 140 |
| 141 #if USE_ATTACHMENT_BROKER |
| 142 if (attachment->GetType() == MessageAttachment::TYPE_BROKERABLE_ATTACHMENT) |
| 143 header()->num_brokered_attachments += 1; |
| 144 #endif |
| 145 |
134 return attachment_set()->AddAttachment(attachment); | 146 return attachment_set()->AddAttachment(attachment); |
135 } | 147 } |
136 | 148 |
137 bool Message::ReadAttachment( | 149 bool Message::ReadAttachment( |
138 base::PickleIterator* iter, | 150 base::PickleIterator* iter, |
139 scoped_refptr<MessageAttachment>* attachment) const { | 151 scoped_refptr<MessageAttachment>* attachment) const { |
140 int descriptor_index; | 152 int descriptor_index; |
141 if (!iter->ReadInt(&descriptor_index)) | 153 if (!iter->ReadInt(&descriptor_index)) |
142 return false; | 154 return false; |
143 | 155 |
(...skipping 12 matching lines...) Expand all Loading... |
156 bool Message::HasMojoHandles() const { | 168 bool Message::HasMojoHandles() const { |
157 return attachment_set_.get() && attachment_set_->num_mojo_handles() > 0; | 169 return attachment_set_.get() && attachment_set_->num_mojo_handles() > 0; |
158 } | 170 } |
159 | 171 |
160 bool Message::HasBrokerableAttachments() const { | 172 bool Message::HasBrokerableAttachments() const { |
161 return attachment_set_.get() && | 173 return attachment_set_.get() && |
162 attachment_set_->num_brokerable_attachments() > 0; | 174 attachment_set_->num_brokerable_attachments() > 0; |
163 } | 175 } |
164 | 176 |
165 } // namespace IPC | 177 } // namespace IPC |
OLD | NEW |