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

Side by Side Diff: ipc/ipc_message.h

Issue 283623002: Add support for passing an arbitrary parameter to an IPC message handler. The motivation is for Web… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 6 years, 7 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 | « content/renderer/render_widget_unittest.cc ('k') | ipc/ipc_message_macros.h » ('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 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } 134 }
135 135
136 uint32 flags() const { 136 uint32 flags() const {
137 return header()->flags; 137 return header()->flags;
138 } 138 }
139 139
140 // Sets all the given header values. The message should be empty at this 140 // Sets all the given header values. The message should be empty at this
141 // call. 141 // call.
142 void SetHeaderValues(int32 routing, uint32 type, uint32 flags); 142 void SetHeaderValues(int32 routing, uint32 type, uint32 flags);
143 143
144 template<class T, class S> 144 template<class T, class S, class P>
145 static bool Dispatch(const Message* msg, T* obj, S* sender, 145 static bool Dispatch(const Message* msg, T* obj, S* sender, P* parameter,
146 void (T::*func)()) { 146 void (T::*func)()) {
147 (obj->*func)(); 147 (obj->*func)();
148 return true; 148 return true;
149 } 149 }
150 150
151 template<class T, class S> 151 template<class T, class S, class P>
152 static bool Dispatch(const Message* msg, T* obj, S* sender, 152 static bool Dispatch(const Message* msg, T* obj, S* sender, P* parameter,
153 void (T::*func)() const) { 153 void (T::*func)(P*)) {
154 (obj->*func)(); 154 (obj->*func)(parameter);
155 return true;
156 }
157
158 template<class T, class S>
159 static bool Dispatch(const Message* msg, T* obj, S* sender,
160 void (T::*func)(const Message&)) {
161 (obj->*func)(*msg);
162 return true;
163 }
164
165 template<class T, class S>
166 static bool Dispatch(const Message* msg, T* obj, S* sender,
167 void (T::*func)(const Message&) const) {
168 (obj->*func)(*msg);
169 return true; 155 return true;
170 } 156 }
171 157
172 // Used for async messages with no parameters. 158 // Used for async messages with no parameters.
173 static void Log(std::string* name, const Message* msg, std::string* l) { 159 static void Log(std::string* name, const Message* msg, std::string* l) {
174 } 160 }
175 161
176 // Find the end of the message data that starts at range_start. Returns NULL 162 // Find the end of the message data that starts at range_start. Returns NULL
177 // if the entire message is not found in the given data range. 163 // if the entire message is not found in the given data range.
178 static const char* FindNext(const char* range_start, const char* range_end) { 164 static const char* FindNext(const char* range_start, const char* range_end) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 MSG_ROUTING_NONE = -2, 272 MSG_ROUTING_NONE = -2,
287 273
288 // indicates a general message not sent to a particular tab. 274 // indicates a general message not sent to a particular tab.
289 MSG_ROUTING_CONTROL = kint32max, 275 MSG_ROUTING_CONTROL = kint32max,
290 }; 276 };
291 277
292 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies 278 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies
293 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging 279 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging
294 280
295 #endif // IPC_IPC_MESSAGE_H_ 281 #endif // IPC_IPC_MESSAGE_H_
OLDNEW
« no previous file with comments | « content/renderer/render_widget_unittest.cc ('k') | ipc/ipc_message_macros.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698