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 #ifndef IPC_IPC_MESSAGE_H_ | 5 #ifndef IPC_IPC_MESSAGE_H_ |
6 #define IPC_IPC_MESSAGE_H_ | 6 #define IPC_IPC_MESSAGE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/pickle.h" | 15 #include "base/pickle.h" |
16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "ipc/attachment_broker.h" | |
19 #include "ipc/brokerable_attachment.h" | 18 #include "ipc/brokerable_attachment.h" |
20 #include "ipc/ipc_export.h" | 19 #include "ipc/ipc_export.h" |
21 | 20 |
22 #if !defined(NDEBUG) | 21 #if !defined(NDEBUG) |
23 #define IPC_MESSAGE_LOG_ENABLED | 22 #define IPC_MESSAGE_LOG_ENABLED |
24 #endif | 23 #endif |
25 | 24 |
26 namespace IPC { | 25 namespace IPC { |
27 | 26 |
28 namespace internal { | 27 namespace internal { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 bool message_found; | 183 bool message_found; |
185 // Only filled in if |message_found| is true. | 184 // Only filled in if |message_found| is true. |
186 // The start address is passed into FindNext() by the caller, so isn't | 185 // The start address is passed into FindNext() by the caller, so isn't |
187 // repeated in this struct. The end address of the pickle should be used to | 186 // repeated in this struct. The end address of the pickle should be used to |
188 // construct a base::Pickle. | 187 // construct a base::Pickle. |
189 const char* pickle_end; | 188 const char* pickle_end; |
190 // Only filled in if |message_found| is true. | 189 // Only filled in if |message_found| is true. |
191 // The end address of the message should be used to determine the start | 190 // The end address of the message should be used to determine the start |
192 // address of the next message. | 191 // address of the next message. |
193 const char* message_end; | 192 const char* message_end; |
194 // If the message has brokerable attachments, this vector will contain the | |
195 // ids of the brokerable attachments. The caller of FindNext() is | |
196 // responsible for adding the attachments to the message. | |
197 std::vector<BrokerableAttachment::AttachmentId> attachment_ids; | |
198 }; | 193 }; |
199 | 194 |
200 struct SerializedAttachmentIds { | |
201 void* buffer; | |
202 size_t size; | |
203 }; | |
204 // Creates a buffer that contains a serialization of the ids of the brokerable | |
205 // attachments of the message. This buffer is intended to be sent over the IPC | |
206 // channel immediately after the pickled message. The caller takes ownership | |
207 // of the buffer. | |
208 // This method should only be called if the message has brokerable | |
209 // attachments. | |
210 SerializedAttachmentIds SerializedIdsOfBrokerableAttachments(); | |
211 | |
212 // |info| is an output parameter and must not be nullptr. | 195 // |info| is an output parameter and must not be nullptr. |
213 static void FindNext(const char* range_start, | 196 static void FindNext(const char* range_start, |
214 const char* range_end, | 197 const char* range_end, |
215 NextMessageInfo* info); | 198 NextMessageInfo* info); |
216 | 199 |
217 // Adds a placeholder brokerable attachment that must be replaced before the | |
218 // message can be dispatched. | |
219 bool AddPlaceholderBrokerableAttachmentWithId( | |
220 BrokerableAttachment::AttachmentId id); | |
221 | |
222 // WriteAttachment appends |attachment| to the end of the set. It returns | 200 // WriteAttachment appends |attachment| to the end of the set. It returns |
223 // false iff the set is full. | 201 // false iff the set is full. |
224 bool WriteAttachment( | 202 bool WriteAttachment( |
225 scoped_refptr<base::Pickle::Attachment> attachment) override; | 203 scoped_refptr<base::Pickle::Attachment> attachment) override; |
226 // ReadAttachment parses an attachment given the parsing state |iter| and | 204 // ReadAttachment parses an attachment given the parsing state |iter| and |
227 // writes it to |*attachment|. It returns true on success. | 205 // writes it to |*attachment|. It returns true on success. |
228 bool ReadAttachment( | 206 bool ReadAttachment( |
229 base::PickleIterator* iter, | 207 base::PickleIterator* iter, |
230 scoped_refptr<base::Pickle::Attachment>* attachment) const override; | 208 scoped_refptr<base::Pickle::Attachment>* attachment) const override; |
231 // Returns true if there are any attachment in this message. | 209 // Returns true if there are any attachment in this message. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 friend class ChannelWin; | 244 friend class ChannelWin; |
267 friend class internal::ChannelReader; | 245 friend class internal::ChannelReader; |
268 friend class MessageReplyDeserializer; | 246 friend class MessageReplyDeserializer; |
269 friend class SyncMessage; | 247 friend class SyncMessage; |
270 | 248 |
271 #pragma pack(push, 4) | 249 #pragma pack(push, 4) |
272 struct Header : base::Pickle::Header { | 250 struct Header : base::Pickle::Header { |
273 int32_t routing; // ID of the view that this message is destined for | 251 int32_t routing; // ID of the view that this message is destined for |
274 uint32_t type; // specifies the user-defined message type | 252 uint32_t type; // specifies the user-defined message type |
275 uint32_t flags; // specifies control flags for the message | 253 uint32_t flags; // specifies control flags for the message |
276 #if USE_ATTACHMENT_BROKER | |
277 // The number of brokered attachments included with this message. The | |
278 // ids of the brokered attachment ids are sent immediately after the pickled | |
279 // message, before the next pickled message is sent. | |
280 uint32_t num_brokered_attachments; | |
281 #endif | |
282 #if defined(OS_POSIX) | 254 #if defined(OS_POSIX) |
283 uint16_t num_fds; // the number of descriptors included with this message | 255 uint16_t num_fds; // the number of descriptors included with this message |
284 uint16_t pad; // explicitly initialize this to appease valgrind | 256 uint16_t pad; // explicitly initialize this to appease valgrind |
285 #endif | 257 #endif |
286 }; | 258 }; |
287 #pragma pack(pop) | 259 #pragma pack(pop) |
288 | 260 |
289 Header* header() { | 261 Header* header() { |
290 return headerT<Header>(); | 262 return headerT<Header>(); |
291 } | 263 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 MSG_ROUTING_NONE = -2, | 309 MSG_ROUTING_NONE = -2, |
338 | 310 |
339 // indicates a general message not sent to a particular tab. | 311 // indicates a general message not sent to a particular tab. |
340 MSG_ROUTING_CONTROL = INT32_MAX, | 312 MSG_ROUTING_CONTROL = INT32_MAX, |
341 }; | 313 }; |
342 | 314 |
343 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies | 315 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies |
344 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging | 316 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging |
345 | 317 |
346 #endif // IPC_IPC_MESSAGE_H_ | 318 #endif // IPC_IPC_MESSAGE_H_ |
OLD | NEW |