| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // false otherwise. | 50 // false otherwise. |
| 51 virtual bool Send(Message* msg) = 0; | 51 virtual bool Send(Message* msg) = 0; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 enum PriorityValue { | 54 enum PriorityValue { |
| 55 PRIORITY_LOW = 1, | 55 PRIORITY_LOW = 1, |
| 56 PRIORITY_NORMAL, | 56 PRIORITY_NORMAL, |
| 57 PRIORITY_HIGH | 57 PRIORITY_HIGH |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 // Bit values used in the flags field. |
| 61 enum { |
| 62 PRIORITY_MASK = 0x0003, // Low 2 bits of store the priority value. |
| 63 SYNC_BIT = 0x0004, |
| 64 REPLY_BIT = 0x0008, |
| 65 REPLY_ERROR_BIT = 0x0010, |
| 66 UNBLOCK_BIT = 0x0020, |
| 67 PUMPING_MSGS_BIT = 0x0040, |
| 68 HAS_SENT_TIME_BIT = 0x0080, |
| 69 }; |
| 70 |
| 60 virtual ~Message(); | 71 virtual ~Message(); |
| 61 | 72 |
| 62 Message(); | 73 Message(); |
| 63 | 74 |
| 64 // Initialize a message with a user-defined type, priority value, and | 75 // Initialize a message with a user-defined type, priority value, and |
| 65 // destination WebView ID. | 76 // destination WebView ID. |
| 66 Message(int32 routing_id, uint32 type, PriorityValue priority); | 77 Message(int32 routing_id, uint32 type, PriorityValue priority); |
| 67 | 78 |
| 68 // Initializes a message from a const block of data. The data is not copied; | 79 // Initializes a message from a const block of data. The data is not copied; |
| 69 // instead the data is merely referenced by this message. Only const methods | 80 // instead the data is merely referenced by this message. Only const methods |
| 70 // should be used on the message when initialized this way. | 81 // should be used on the message when initialized this way. |
| 71 Message(const char* data, int data_len); | 82 Message(const char* data, int data_len); |
| 72 | 83 |
| 73 Message(const Message& other); | 84 Message(const Message& other); |
| 74 Message& operator=(const Message& other); | 85 Message& operator=(const Message& other); |
| 75 | 86 |
| 76 PriorityValue priority() const { | 87 PriorityValue priority() const { |
| 77 return static_cast<PriorityValue>(header()->flags & PRIORITY_MASK); | 88 return static_cast<PriorityValue>(header()->flags & PRIORITY_MASK); |
| 78 } | 89 } |
| 79 | 90 |
| 80 // True if this is a synchronous message. | 91 // True if this is a synchronous message. |
| 92 void set_sync() { |
| 93 header()->flags |= SYNC_BIT; |
| 94 } |
| 81 bool is_sync() const { | 95 bool is_sync() const { |
| 82 return (header()->flags & SYNC_BIT) != 0; | 96 return (header()->flags & SYNC_BIT) != 0; |
| 83 } | 97 } |
| 84 | 98 |
| 85 // Set this on a reply to a synchronous message. | 99 // Set this on a reply to a synchronous message. |
| 86 void set_reply() { | 100 void set_reply() { |
| 87 header()->flags |= REPLY_BIT; | 101 header()->flags |= REPLY_BIT; |
| 88 } | 102 } |
| 89 | 103 |
| 90 bool is_reply() const { | 104 bool is_reply() const { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 141 } |
| 128 | 142 |
| 129 int32 routing_id() const { | 143 int32 routing_id() const { |
| 130 return header()->routing; | 144 return header()->routing; |
| 131 } | 145 } |
| 132 | 146 |
| 133 void set_routing_id(int32 new_id) { | 147 void set_routing_id(int32 new_id) { |
| 134 header()->routing = new_id; | 148 header()->routing = new_id; |
| 135 } | 149 } |
| 136 | 150 |
| 151 uint32 flags() const { |
| 152 return header()->flags; |
| 153 } |
| 154 |
| 137 template<class T, class S> | 155 template<class T, class S> |
| 138 static bool Dispatch(const Message* msg, T* obj, S* sender, | 156 static bool Dispatch(const Message* msg, T* obj, S* sender, |
| 139 void (T::*func)()) { | 157 void (T::*func)()) { |
| 140 (obj->*func)(); | 158 (obj->*func)(); |
| 141 return true; | 159 return true; |
| 142 } | 160 } |
| 143 | 161 |
| 144 template<class T, class S> | 162 template<class T, class S> |
| 145 static bool Dispatch(const Message* msg, T* obj, S* sender, | 163 static bool Dispatch(const Message* msg, T* obj, S* sender, |
| 146 void (T::*func)() const) { | 164 void (T::*func)() const) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 LogData* sync_log_data() const { return log_data_; } | 220 LogData* sync_log_data() const { return log_data_; } |
| 203 void set_dont_log() const { dont_log_ = true; } | 221 void set_dont_log() const { dont_log_ = true; } |
| 204 bool dont_log() const { return dont_log_; } | 222 bool dont_log() const { return dont_log_; } |
| 205 #endif | 223 #endif |
| 206 | 224 |
| 207 protected: | 225 protected: |
| 208 friend class Channel; | 226 friend class Channel; |
| 209 friend class MessageReplyDeserializer; | 227 friend class MessageReplyDeserializer; |
| 210 friend class SyncMessage; | 228 friend class SyncMessage; |
| 211 | 229 |
| 212 void set_sync() { | |
| 213 header()->flags |= SYNC_BIT; | |
| 214 } | |
| 215 | |
| 216 // flags | |
| 217 enum { | |
| 218 PRIORITY_MASK = 0x0003, | |
| 219 SYNC_BIT = 0x0004, | |
| 220 REPLY_BIT = 0x0008, | |
| 221 REPLY_ERROR_BIT = 0x0010, | |
| 222 UNBLOCK_BIT = 0x0020, | |
| 223 PUMPING_MSGS_BIT= 0x0040, | |
| 224 HAS_SENT_TIME_BIT = 0x0080, | |
| 225 }; | |
| 226 | |
| 227 #pragma pack(push, 4) | 230 #pragma pack(push, 4) |
| 228 struct Header : Pickle::Header { | 231 struct Header : Pickle::Header { |
| 229 int32 routing; // ID of the view that this message is destined for | 232 int32 routing; // ID of the view that this message is destined for |
| 230 uint32 type; // specifies the user-defined message type | 233 uint32 type; // specifies the user-defined message type |
| 231 uint32 flags; // specifies control flags for the message | 234 uint32 flags; // specifies control flags for the message |
| 232 #if defined(OS_POSIX) | 235 #if defined(OS_POSIX) |
| 233 uint16 num_fds; // the number of descriptors included with this message | 236 uint16 num_fds; // the number of descriptors included with this message |
| 234 uint16 pad; // explicitly initialize this to appease valgrind | 237 uint16 pad; // explicitly initialize this to appease valgrind |
| 235 #endif | 238 #endif |
| 236 }; | 239 }; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 MSG_ROUTING_NONE = -2, | 282 MSG_ROUTING_NONE = -2, |
| 280 | 283 |
| 281 // indicates a general message not sent to a particular tab. | 284 // indicates a general message not sent to a particular tab. |
| 282 MSG_ROUTING_CONTROL = kint32max, | 285 MSG_ROUTING_CONTROL = kint32max, |
| 283 }; | 286 }; |
| 284 | 287 |
| 285 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies | 288 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies |
| 286 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging | 289 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging |
| 287 | 290 |
| 288 #endif // IPC_IPC_MESSAGE_H_ | 291 #endif // IPC_IPC_MESSAGE_H_ |
| OLD | NEW |