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" |
(...skipping 16 matching lines...) Expand all Loading... |
27 class FileDescriptorSet; | 27 class FileDescriptorSet; |
28 | 28 |
29 namespace IPC { | 29 namespace IPC { |
30 | 30 |
31 //------------------------------------------------------------------------------ | 31 //------------------------------------------------------------------------------ |
32 | 32 |
33 struct LogData; | 33 struct LogData; |
34 | 34 |
35 class IPC_EXPORT Message : public Pickle { | 35 class IPC_EXPORT Message : public Pickle { |
36 public: | 36 public: |
37 enum PriorityValue { | |
38 PRIORITY_LOW = 1, | |
39 PRIORITY_NORMAL, | |
40 PRIORITY_HIGH | |
41 }; | |
42 | |
43 // Bit values used in the flags field. | 37 // Bit values used in the flags field. |
44 // Upper 24 bits of flags store a reference number, so this enum is limited to | 38 // Upper 24 bits of flags store a reference number, so this enum is limited to |
45 // 8 bits. | 39 // 8 bits. |
46 enum { | 40 enum { |
47 PRIORITY_MASK = 0x03, // Low 2 bits of store the priority value. | 41 UNUSED = 0x03, // Low 2 bits are not used. |
48 SYNC_BIT = 0x04, | 42 SYNC_BIT = 0x04, |
49 REPLY_BIT = 0x08, | 43 REPLY_BIT = 0x08, |
50 REPLY_ERROR_BIT = 0x10, | 44 REPLY_ERROR_BIT = 0x10, |
51 UNBLOCK_BIT = 0x20, | 45 UNBLOCK_BIT = 0x20, |
52 PUMPING_MSGS_BIT = 0x40, | 46 PUMPING_MSGS_BIT = 0x40, |
53 HAS_SENT_TIME_BIT = 0x80, | 47 HAS_SENT_TIME_BIT = 0x80, |
54 }; | 48 }; |
55 | 49 |
56 virtual ~Message(); | 50 virtual ~Message(); |
57 | 51 |
58 Message(); | 52 Message(); |
59 | 53 |
60 // Initialize a message with a user-defined type, priority value, and | 54 // Initialize a message with routing ID and a user-defined type. |
61 // destination WebView ID. | 55 Message(int32 routing_id, uint32 type); |
62 Message(int32 routing_id, uint32 type, PriorityValue priority); | |
63 | 56 |
64 // Initializes a message from a const block of data. The data is not copied; | 57 // Initializes a message from a const block of data. The data is not copied; |
65 // instead the data is merely referenced by this message. Only const methods | 58 // instead the data is merely referenced by this message. Only const methods |
66 // should be used on the message when initialized this way. | 59 // should be used on the message when initialized this way. |
67 Message(const char* data, int data_len); | 60 Message(const char* data, size_t data_len); |
68 | 61 |
69 Message(const Message& other); | 62 Message(const Message& other); |
70 Message& operator=(const Message& other); | 63 Message& operator=(const Message& other); |
71 | 64 |
72 PriorityValue priority() const { | |
73 return static_cast<PriorityValue>(header()->flags & PRIORITY_MASK); | |
74 } | |
75 | |
76 // True if this is a synchronous message. | 65 // True if this is a synchronous message. |
77 void set_sync() { | 66 void set_sync() { |
78 header()->flags |= SYNC_BIT; | 67 header()->flags |= SYNC_BIT; |
79 } | 68 } |
80 bool is_sync() const { | 69 bool is_sync() const { |
81 return (header()->flags & SYNC_BIT) != 0; | 70 return (header()->flags & SYNC_BIT) != 0; |
82 } | 71 } |
83 | 72 |
84 // Set this on a reply to a synchronous message. | 73 // Set this on a reply to a synchronous message. |
85 void set_reply() { | 74 void set_reply() { |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 MSG_ROUTING_NONE = -2, | 273 MSG_ROUTING_NONE = -2, |
285 | 274 |
286 // indicates a general message not sent to a particular tab. | 275 // indicates a general message not sent to a particular tab. |
287 MSG_ROUTING_CONTROL = kint32max, | 276 MSG_ROUTING_CONTROL = kint32max, |
288 }; | 277 }; |
289 | 278 |
290 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies | 279 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies |
291 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging | 280 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging |
292 | 281 |
293 #endif // IPC_IPC_MESSAGE_H_ | 282 #endif // IPC_IPC_MESSAGE_H_ |
OLD | NEW |