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

Side by Side Diff: ipc/ipc_message_macros.h

Issue 5978003: Make IPC::Channel::Listener:OnMessageReceived have a return value indicating ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years 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_fuzzing_tests.cc ('k') | ipc/ipc_send_fds_test.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // This header is meant to be included in multiple passes, hence no traditional 5 // This header is meant to be included in multiple passes, hence no traditional
6 // header guard. 6 // header guard.
7 // 7 //
8 // In your XXX_messages_internal.h file, before defining any messages do: 8 // In your XXX_messages_internal.h file, before defining any messages do:
9 // #define IPC_MESSAGE_START XMsgStart 9 // #define IPC_MESSAGE_START XMsgStart
10 // XMstStart value is from the IPCMessageStart enum in ipc_message_utils.h, and 10 // XMstStart value is from the IPCMessageStart enum in ipc_message_utils.h, and
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 static void Log(std::string* name, const Message* msg, std::string* l); \ 1156 static void Log(std::string* name, const Message* msg, std::string* l); \
1157 }; \ 1157 }; \
1158 IPC_SYNC_MESSAGE_ROUTED5_4_EXTRA(msg_class, type1_in, type2_in, type3_in, type 4_in, type5_in, type1_out, type2_out, type3_out, type4_out) 1158 IPC_SYNC_MESSAGE_ROUTED5_4_EXTRA(msg_class, type1_in, type2_in, type3_in, type 4_in, type5_in, type1_out, type2_out, type3_out, type4_out)
1159 1159
1160 1160
1161 1161
1162 // Message crackers and handlers. 1162 // Message crackers and handlers.
1163 // Prefer to use the IPC_BEGIN_MESSAGE_MAP_EX to the older macros since they 1163 // Prefer to use the IPC_BEGIN_MESSAGE_MAP_EX to the older macros since they
1164 // allow you to detect when a message could not be de-serialized. Usage: 1164 // allow you to detect when a message could not be de-serialized. Usage:
1165 // 1165 //
1166 // void MyClass::OnMessageReceived(const IPC::Message& msg) { 1166 // bool MyClass::OnMessageReceived(const IPC::Message& msg) {
1167 // bool handled = true;
1167 // bool msg_is_good = false; 1168 // bool msg_is_good = false;
1168 // IPC_BEGIN_MESSAGE_MAP_EX(MyClass, msg, msg_is_good) 1169 // IPC_BEGIN_MESSAGE_MAP_EX(MyClass, msg, msg_is_good)
1169 // IPC_MESSAGE_HANDLER(MsgClassOne, OnMsgClassOne) 1170 // IPC_MESSAGE_HANDLER(MsgClassOne, OnMsgClassOne)
1170 // ...more handlers here ... 1171 // ...more handlers here ...
1171 // IPC_MESSAGE_HANDLER(MsgClassTen, OnMsgClassTen) 1172 // IPC_MESSAGE_HANDLER(MsgClassTen, OnMsgClassTen)
1173 // IPC_MESSAGE_UNHANDLED(handled = false)
1172 // IPC_END_MESSAGE_MAP_EX() 1174 // IPC_END_MESSAGE_MAP_EX()
1173 // if (!msg_is_good) { 1175 // if (!msg_is_good) {
1174 // // Signal error here or terminate offending process. 1176 // // Signal error here or terminate offending process.
1175 // } 1177 // }
1178 // return handled;
1176 // } 1179 // }
1177 1180
1178 1181
1179 #define IPC_DEFINE_MESSAGE_MAP(class_name) \
1180 void class_name::OnMessageReceived(const IPC::Message& msg) \
1181 IPC_BEGIN_MESSAGE_MAP(class_name, msg)
1182
1183 #define IPC_BEGIN_MESSAGE_MAP_EX(class_name, msg, msg_is_ok) \ 1182 #define IPC_BEGIN_MESSAGE_MAP_EX(class_name, msg, msg_is_ok) \
1184 { \ 1183 { \
1185 typedef class_name _IpcMessageHandlerClass; \ 1184 typedef class_name _IpcMessageHandlerClass; \
1186 const IPC::Message& ipc_message__ = msg; \ 1185 const IPC::Message& ipc_message__ = msg; \
1187 bool& msg_is_ok__ = msg_is_ok; \ 1186 bool& msg_is_ok__ = msg_is_ok; \
1188 switch (ipc_message__.type()) { \ 1187 switch (ipc_message__.type()) { \
1189 1188
1190 #define IPC_BEGIN_MESSAGE_MAP(class_name, msg) \ 1189 #define IPC_BEGIN_MESSAGE_MAP(class_name, msg) \
1191 { \ 1190 { \
1192 typedef class_name _IpcMessageHandlerClass; \ 1191 typedef class_name _IpcMessageHandlerClass; \
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 } \ 1236 } \
1238 } 1237 }
1239 1238
1240 #define IPC_END_MESSAGE_MAP_EX() \ 1239 #define IPC_END_MESSAGE_MAP_EX() \
1241 } \ 1240 } \
1242 } 1241 }
1243 1242
1244 // This corresponds to an enum value from IPCMessageStart. 1243 // This corresponds to an enum value from IPCMessageStart.
1245 #define IPC_MESSAGE_CLASS(message) \ 1244 #define IPC_MESSAGE_CLASS(message) \
1246 message.type() >> 16 1245 message.type() >> 16
OLDNEW
« no previous file with comments | « ipc/ipc_fuzzing_tests.cc ('k') | ipc/ipc_send_fds_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698