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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/pickle.h" | 12 #include "base/pickle.h" |
13 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
14 #include "ipc/ipc_export.h" | 14 #include "ipc/ipc_export.h" |
15 | 15 |
16 #if !defined(NDEBUG) | 16 #if !defined(NDEBUG) |
17 #define IPC_MESSAGE_LOG_ENABLED | 17 #define IPC_MESSAGE_LOG_ENABLED |
18 #endif | 18 #endif |
19 | 19 |
20 namespace IPC { | 20 namespace IPC { |
21 | 21 |
22 //------------------------------------------------------------------------------ | 22 //------------------------------------------------------------------------------ |
23 | 23 |
24 struct LogData; | 24 struct LogData; |
25 class MessageAttachment; | 25 class MessageAttachment; |
26 class MessageAttachmentSet; | 26 class MessageAttachmentSet; |
27 | 27 |
28 class IPC_EXPORT Message : public Pickle { | 28 class IPC_EXPORT Message : public base::Pickle { |
29 public: | 29 public: |
30 enum PriorityValue { | 30 enum PriorityValue { |
31 PRIORITY_LOW = 1, | 31 PRIORITY_LOW = 1, |
32 PRIORITY_NORMAL, | 32 PRIORITY_NORMAL, |
33 PRIORITY_HIGH | 33 PRIORITY_HIGH |
34 }; | 34 }; |
35 | 35 |
36 // Bit values used in the flags field. | 36 // Bit values used in the flags field. |
37 // Upper 24 bits of flags store a reference number, so this enum is limited to | 37 // Upper 24 bits of flags store a reference number, so this enum is limited to |
38 // 8 bits. | 38 // 8 bits. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 return true; | 156 return true; |
157 } | 157 } |
158 | 158 |
159 // Used for async messages with no parameters. | 159 // Used for async messages with no parameters. |
160 static void Log(std::string* name, const Message* msg, std::string* l) { | 160 static void Log(std::string* name, const Message* msg, std::string* l) { |
161 } | 161 } |
162 | 162 |
163 // Find the end of the message data that starts at range_start. Returns NULL | 163 // Find the end of the message data that starts at range_start. Returns NULL |
164 // if the entire message is not found in the given data range. | 164 // if the entire message is not found in the given data range. |
165 static const char* FindNext(const char* range_start, const char* range_end) { | 165 static const char* FindNext(const char* range_start, const char* range_end) { |
166 return Pickle::FindNext(sizeof(Header), range_start, range_end); | 166 return base::Pickle::FindNext(sizeof(Header), range_start, range_end); |
167 } | 167 } |
168 | 168 |
169 // WriteAttachment appends |attachment| to the end of the set. It returns | 169 // WriteAttachment appends |attachment| to the end of the set. It returns |
170 // false iff the set is full. | 170 // false iff the set is full. |
171 bool WriteAttachment(scoped_refptr<MessageAttachment> attachment); | 171 bool WriteAttachment(scoped_refptr<MessageAttachment> attachment); |
172 // ReadAttachment parses an attachment given the parsing state |iter| and | 172 // ReadAttachment parses an attachment given the parsing state |iter| and |
173 // writes it to |*attachment|. It returns true on success. | 173 // writes it to |*attachment|. It returns true on success. |
174 bool ReadAttachment(PickleIterator* iter, | 174 bool ReadAttachment(base::PickleIterator* iter, |
175 scoped_refptr<MessageAttachment>* attachment) const; | 175 scoped_refptr<MessageAttachment>* attachment) const; |
176 // Returns true if there are any attachment in this message. | 176 // Returns true if there are any attachment in this message. |
177 bool HasAttachments() const; | 177 bool HasAttachments() const; |
178 // Returns true if there are any MojoHandleAttachments in this message. | 178 // Returns true if there are any MojoHandleAttachments in this message. |
179 bool HasMojoHandles() const; | 179 bool HasMojoHandles() const; |
180 | 180 |
181 #ifdef IPC_MESSAGE_LOG_ENABLED | 181 #ifdef IPC_MESSAGE_LOG_ENABLED |
182 // Adds the outgoing time from Time::Now() at the end of the message and sets | 182 // Adds the outgoing time from Time::Now() at the end of the message and sets |
183 // a bit to indicate that it's been added. | 183 // a bit to indicate that it's been added. |
184 void set_sent_time(int64 time); | 184 void set_sent_time(int64 time); |
(...skipping 27 matching lines...) Expand all Loading... |
212 protected: | 212 protected: |
213 friend class Channel; | 213 friend class Channel; |
214 friend class ChannelMojo; | 214 friend class ChannelMojo; |
215 friend class ChannelNacl; | 215 friend class ChannelNacl; |
216 friend class ChannelPosix; | 216 friend class ChannelPosix; |
217 friend class ChannelWin; | 217 friend class ChannelWin; |
218 friend class MessageReplyDeserializer; | 218 friend class MessageReplyDeserializer; |
219 friend class SyncMessage; | 219 friend class SyncMessage; |
220 | 220 |
221 #pragma pack(push, 4) | 221 #pragma pack(push, 4) |
222 struct Header : Pickle::Header { | 222 struct Header : base::Pickle::Header { |
223 int32 routing; // ID of the view that this message is destined for | 223 int32 routing; // ID of the view that this message is destined for |
224 uint32 type; // specifies the user-defined message type | 224 uint32 type; // specifies the user-defined message type |
225 uint32 flags; // specifies control flags for the message | 225 uint32 flags; // specifies control flags for the message |
226 #if defined(OS_POSIX) | 226 #if defined(OS_POSIX) |
227 uint16 num_fds; // the number of descriptors included with this message | 227 uint16 num_fds; // the number of descriptors included with this message |
228 uint16 pad; // explicitly initialize this to appease valgrind | 228 uint16 pad; // explicitly initialize this to appease valgrind |
229 #endif | 229 #endif |
230 }; | 230 }; |
231 #pragma pack(pop) | 231 #pragma pack(pop) |
232 | 232 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 MSG_ROUTING_NONE = -2, | 274 MSG_ROUTING_NONE = -2, |
275 | 275 |
276 // indicates a general message not sent to a particular tab. | 276 // indicates a general message not sent to a particular tab. |
277 MSG_ROUTING_CONTROL = kint32max, | 277 MSG_ROUTING_CONTROL = kint32max, |
278 }; | 278 }; |
279 | 279 |
280 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies | 280 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies |
281 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging | 281 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging |
282 | 282 |
283 #endif // IPC_IPC_MESSAGE_H_ | 283 #endif // IPC_IPC_MESSAGE_H_ |
OLD | NEW |