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" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "ipc/ipc_message_attachment.h" | 12 #include "ipc/ipc_message_attachment.h" |
13 #include "ipc/ipc_message_attachment_set.h" | 13 #include "ipc/ipc_message_attachment_set.h" |
| 14 #include "ipc/placeholder_brokerable_attachment.h" |
14 | 15 |
15 #if defined(OS_POSIX) | 16 #if defined(OS_POSIX) |
16 #include "base/file_descriptor_posix.h" | 17 #include "base/file_descriptor_posix.h" |
17 #include "ipc/ipc_platform_file_attachment_posix.h" | 18 #include "ipc/ipc_platform_file_attachment_posix.h" |
18 #endif | 19 #endif |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 base::StaticAtomicSequenceNumber g_ref_num; | 23 base::StaticAtomicSequenceNumber g_ref_num; |
23 | 24 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 } | 174 } |
174 info->message_end = | 175 info->message_end = |
175 pickle_end + num_attachments * BrokerableAttachment::kNonceSize; | 176 pickle_end + num_attachments * BrokerableAttachment::kNonceSize; |
176 #else | 177 #else |
177 info->message_end = pickle_end; | 178 info->message_end = pickle_end; |
178 #endif // USE_ATTACHMENT_BROKER | 179 #endif // USE_ATTACHMENT_BROKER |
179 | 180 |
180 info->message_found = true; | 181 info->message_found = true; |
181 } | 182 } |
182 | 183 |
| 184 bool Message::AddPlaceholderBrokerableAttachmentWithId( |
| 185 BrokerableAttachment::AttachmentId id) { |
| 186 scoped_refptr<PlaceholderBrokerableAttachment> attachment( |
| 187 new PlaceholderBrokerableAttachment(id)); |
| 188 return attachment_set()->AddAttachment(attachment); |
| 189 } |
| 190 |
183 bool Message::WriteAttachment(scoped_refptr<MessageAttachment> attachment) { | 191 bool Message::WriteAttachment(scoped_refptr<MessageAttachment> attachment) { |
184 // We write the index of the descriptor so that we don't have to | 192 // We write the index of the descriptor so that we don't have to |
185 // keep the current descriptor as extra decoding state when deserialising. | 193 // keep the current descriptor as extra decoding state when deserialising. |
186 WriteInt(attachment_set()->size()); | 194 WriteInt(attachment_set()->size()); |
187 return attachment_set()->AddAttachment(attachment); | 195 return attachment_set()->AddAttachment(attachment); |
188 } | 196 } |
189 | 197 |
190 bool Message::ReadAttachment( | 198 bool Message::ReadAttachment( |
191 base::PickleIterator* iter, | 199 base::PickleIterator* iter, |
192 scoped_refptr<MessageAttachment>* attachment) const { | 200 scoped_refptr<MessageAttachment>* attachment) const { |
(...skipping 16 matching lines...) Expand all Loading... |
209 bool Message::HasMojoHandles() const { | 217 bool Message::HasMojoHandles() const { |
210 return attachment_set_.get() && attachment_set_->num_mojo_handles() > 0; | 218 return attachment_set_.get() && attachment_set_->num_mojo_handles() > 0; |
211 } | 219 } |
212 | 220 |
213 bool Message::HasBrokerableAttachments() const { | 221 bool Message::HasBrokerableAttachments() const { |
214 return attachment_set_.get() && | 222 return attachment_set_.get() && |
215 attachment_set_->num_brokerable_attachments() > 0; | 223 attachment_set_->num_brokerable_attachments() > 0; |
216 } | 224 } |
217 | 225 |
218 } // namespace IPC | 226 } // namespace IPC |
OLD | NEW |