| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } | 142 } |
| 143 | 143 |
| 144 void set_routing_id(int32 new_id) { | 144 void set_routing_id(int32 new_id) { |
| 145 header()->routing = new_id; | 145 header()->routing = new_id; |
| 146 } | 146 } |
| 147 | 147 |
| 148 uint32 flags() const { | 148 uint32 flags() const { |
| 149 return header()->flags; | 149 return header()->flags; |
| 150 } | 150 } |
| 151 | 151 |
| 152 // Sets all the given header values. The message should be empty at this |
| 153 // call. |
| 154 void SetHeaderValues(int32 routing, uint32 type, uint32 flags); |
| 155 |
| 152 template<class T, class S> | 156 template<class T, class S> |
| 153 static bool Dispatch(const Message* msg, T* obj, S* sender, | 157 static bool Dispatch(const Message* msg, T* obj, S* sender, |
| 154 void (T::*func)()) { | 158 void (T::*func)()) { |
| 155 (obj->*func)(); | 159 (obj->*func)(); |
| 156 return true; | 160 return true; |
| 157 } | 161 } |
| 158 | 162 |
| 159 template<class T, class S> | 163 template<class T, class S> |
| 160 static bool Dispatch(const Message* msg, T* obj, S* sender, | 164 static bool Dispatch(const Message* msg, T* obj, S* sender, |
| 161 void (T::*func)() const) { | 165 void (T::*func)() const) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 184 // Find the end of the message data that starts at range_start. Returns NULL | 188 // Find the end of the message data that starts at range_start. Returns NULL |
| 185 // if the entire message is not found in the given data range. | 189 // if the entire message is not found in the given data range. |
| 186 static const char* FindNext(const char* range_start, const char* range_end) { | 190 static const char* FindNext(const char* range_start, const char* range_end) { |
| 187 return Pickle::FindNext(sizeof(Header), range_start, range_end); | 191 return Pickle::FindNext(sizeof(Header), range_start, range_end); |
| 188 } | 192 } |
| 189 | 193 |
| 190 #if defined(OS_POSIX) | 194 #if defined(OS_POSIX) |
| 191 // On POSIX, a message supports reading / writing FileDescriptor objects. | 195 // On POSIX, a message supports reading / writing FileDescriptor objects. |
| 192 // This is used to pass a file descriptor to the peer of an IPC channel. | 196 // This is used to pass a file descriptor to the peer of an IPC channel. |
| 193 | 197 |
| 194 // Add a descriptor to the end of the set. Returns false iff the set is full. | 198 // Add a descriptor to the end of the set. Returns false if the set is full. |
| 195 bool WriteFileDescriptor(const base::FileDescriptor& descriptor); | 199 bool WriteFileDescriptor(const base::FileDescriptor& descriptor); |
| 200 |
| 196 // Get a file descriptor from the message. Returns false on error. | 201 // Get a file descriptor from the message. Returns false on error. |
| 197 // iter: a Pickle iterator to the current location in the message. | 202 // iter: a Pickle iterator to the current location in the message. |
| 198 bool ReadFileDescriptor(PickleIterator* iter, | 203 bool ReadFileDescriptor(PickleIterator* iter, |
| 199 base::FileDescriptor* descriptor) const; | 204 base::FileDescriptor* descriptor) const; |
| 205 |
| 206 // Returns true if there are any file descriptors in this message. |
| 207 bool HasFileDescriptors() const; |
| 200 #endif | 208 #endif |
| 201 | 209 |
| 202 #ifdef IPC_MESSAGE_LOG_ENABLED | 210 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 203 // Adds the outgoing time from Time::Now() at the end of the message and sets | 211 // Adds the outgoing time from Time::Now() at the end of the message and sets |
| 204 // a bit to indicate that it's been added. | 212 // a bit to indicate that it's been added. |
| 205 void set_sent_time(int64 time); | 213 void set_sent_time(int64 time); |
| 206 int64 sent_time() const; | 214 int64 sent_time() const; |
| 207 | 215 |
| 208 void set_received_time(int64 time) const; | 216 void set_received_time(int64 time) const; |
| 209 int64 received_time() const { return received_time_; } | 217 int64 received_time() const { return received_time_; } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 MSG_ROUTING_NONE = -2, | 287 MSG_ROUTING_NONE = -2, |
| 280 | 288 |
| 281 // indicates a general message not sent to a particular tab. | 289 // indicates a general message not sent to a particular tab. |
| 282 MSG_ROUTING_CONTROL = kint32max, | 290 MSG_ROUTING_CONTROL = kint32max, |
| 283 }; | 291 }; |
| 284 | 292 |
| 285 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies | 293 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies |
| 286 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging | 294 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging |
| 287 | 295 |
| 288 #endif // IPC_IPC_MESSAGE_H_ | 296 #endif // IPC_IPC_MESSAGE_H_ |
| OLD | NEW |