Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: ipc/ipc_message.h

Issue 10667002: Make the serialization of IPC::Messages inside other IPC::Messages independent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ipc/ipc.gyp ('k') | ipc/ipc_message.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 void set_flags(uint32 f) {
153 header()->flags = f;
154 }
155
156 // This is used when deserializing nested messages. It sets the given header
darin (slow to review) 2012/06/22 21:42:16 nit: people often fail to update comments like thi
157 // values. The message should be empty.
158 void SetHeaderValues(int32 routing, uint32 type, uint32 flags);
159
160
152 template<class T, class S> 161 template<class T, class S>
153 static bool Dispatch(const Message* msg, T* obj, S* sender, 162 static bool Dispatch(const Message* msg, T* obj, S* sender,
154 void (T::*func)()) { 163 void (T::*func)()) {
155 (obj->*func)(); 164 (obj->*func)();
156 return true; 165 return true;
157 } 166 }
158 167
159 template<class T, class S> 168 template<class T, class S>
160 static bool Dispatch(const Message* msg, T* obj, S* sender, 169 static bool Dispatch(const Message* msg, T* obj, S* sender,
161 void (T::*func)() const) { 170 void (T::*func)() const) {
(...skipping 22 matching lines...) Expand all
184 // Find the end of the message data that starts at range_start. Returns NULL 193 // 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. 194 // 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) { 195 static const char* FindNext(const char* range_start, const char* range_end) {
187 return Pickle::FindNext(sizeof(Header), range_start, range_end); 196 return Pickle::FindNext(sizeof(Header), range_start, range_end);
188 } 197 }
189 198
190 #if defined(OS_POSIX) 199 #if defined(OS_POSIX)
191 // On POSIX, a message supports reading / writing FileDescriptor objects. 200 // 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. 201 // This is used to pass a file descriptor to the peer of an IPC channel.
193 202
194 // Add a descriptor to the end of the set. Returns false iff the set is full. 203 // Add a descriptor to the end of the set. Returns false if the set is full.
195 bool WriteFileDescriptor(const base::FileDescriptor& descriptor); 204 bool WriteFileDescriptor(const base::FileDescriptor& descriptor);
205
196 // Get a file descriptor from the message. Returns false on error. 206 // Get a file descriptor from the message. Returns false on error.
197 // iter: a Pickle iterator to the current location in the message. 207 // iter: a Pickle iterator to the current location in the message.
198 bool ReadFileDescriptor(PickleIterator* iter, 208 bool ReadFileDescriptor(PickleIterator* iter,
199 base::FileDescriptor* descriptor) const; 209 base::FileDescriptor* descriptor) const;
210
211 // Returns true if there are any file descriptors in this message.
212 bool HasFileDescriptors() const;
200 #endif 213 #endif
201 214
202 #ifdef IPC_MESSAGE_LOG_ENABLED 215 #ifdef IPC_MESSAGE_LOG_ENABLED
203 // Adds the outgoing time from Time::Now() at the end of the message and sets 216 // 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. 217 // a bit to indicate that it's been added.
205 void set_sent_time(int64 time); 218 void set_sent_time(int64 time);
206 int64 sent_time() const; 219 int64 sent_time() const;
207 220
208 void set_received_time(int64 time) const; 221 void set_received_time(int64 time) const;
209 int64 received_time() const { return received_time_; } 222 int64 received_time() const { return received_time_; }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 MSG_ROUTING_NONE = -2, 292 MSG_ROUTING_NONE = -2,
280 293
281 // indicates a general message not sent to a particular tab. 294 // indicates a general message not sent to a particular tab.
282 MSG_ROUTING_CONTROL = kint32max, 295 MSG_ROUTING_CONTROL = kint32max,
283 }; 296 };
284 297
285 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies 298 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies
286 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging 299 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging
287 300
288 #endif // IPC_IPC_MESSAGE_H_ 301 #endif // IPC_IPC_MESSAGE_H_
OLDNEW
« no previous file with comments | « ipc/ipc.gyp ('k') | ipc/ipc_message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698