Chromium Code Reviews| 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 // Defining IPC Messages | 5 // Defining IPC Messages |
| 6 // | 6 // |
| 7 // Your IPC messages will be defined by macros inside of an XXX_messages.h | 7 // Your IPC messages will be defined by macros inside of an XXX_messages.h |
| 8 // header file. Most of the time, the system can automatically generate all | 8 // header file. Most of the time, the system can automatically generate all |
| 9 // of messaging mechanism from these definitions, but sometimes some manual | 9 // of messaging mechanism from these definitions, but sometimes some manual |
| 10 // coding is required. In these cases, you will also have an XXX_messages.cc | 10 // coding is required. In these cases, you will also have an XXX_messages.cc |
| (...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 926 IPC_DECLTYPE(param) param__ = param; \ | 926 IPC_DECLTYPE(param) param__ = param; \ |
| 927 const IPC::Message& ipc_message__ = msg; \ | 927 const IPC::Message& ipc_message__ = msg; \ |
| 928 bool& msg_is_ok__ = msg_is_ok; \ | 928 bool& msg_is_ok__ = msg_is_ok; \ |
| 929 switch (ipc_message__.type()) { | 929 switch (ipc_message__.type()) { |
| 930 | 930 |
| 931 #define IPC_MESSAGE_FORWARD(msg_class, obj, member_func) \ | 931 #define IPC_MESSAGE_FORWARD(msg_class, obj, member_func) \ |
| 932 case msg_class::ID: { \ | 932 case msg_class::ID: { \ |
| 933 TRACK_RUN_IN_IPC_HANDLER(member_func); \ | 933 TRACK_RUN_IN_IPC_HANDLER(member_func); \ |
| 934 msg_is_ok__ = msg_class::Dispatch(&ipc_message__, obj, this, \ | 934 msg_is_ok__ = msg_class::Dispatch(&ipc_message__, obj, this, \ |
| 935 param__, &member_func); \ | 935 param__, &member_func); \ |
| 936 if (!msg_is_ok__) \ | |
| 937 const_cast<IPC::Message&>(ipc_message__).set_dispatch_error(); \ | |
|
Tom Sepez
2014/05/15 19:57:42
What if we wanted to avoid the const cast by makin
jam
2014/05/15 21:19:34
actually, i can simplify this more now by making d
| |
| 936 } \ | 938 } \ |
| 937 break; | 939 break; |
| 938 | 940 |
| 939 #define IPC_MESSAGE_HANDLER(msg_class, member_func) \ | 941 #define IPC_MESSAGE_HANDLER(msg_class, member_func) \ |
| 940 IPC_MESSAGE_FORWARD(msg_class, this, _IpcMessageHandlerClass::member_func) | 942 IPC_MESSAGE_FORWARD(msg_class, this, _IpcMessageHandlerClass::member_func) |
| 941 | 943 |
| 942 #define IPC_MESSAGE_FORWARD_DELAY_REPLY(msg_class, obj, member_func) \ | 944 #define IPC_MESSAGE_FORWARD_DELAY_REPLY(msg_class, obj, member_func) \ |
| 943 case msg_class::ID: { \ | 945 case msg_class::ID: { \ |
| 944 TRACK_RUN_IN_IPC_HANDLER(member_func); \ | 946 TRACK_RUN_IN_IPC_HANDLER(member_func); \ |
| 945 msg_is_ok__ = msg_class::DispatchDelayReply(&ipc_message__, obj, \ | 947 msg_is_ok__ = msg_class::DispatchDelayReply(&ipc_message__, obj, \ |
| 946 param__, &member_func); \ | 948 param__, &member_func); \ |
| 949 if (!msg_is_ok__) \ | |
| 950 const_cast<IPC::Message&>(ipc_message__).set_dispatch_error(); \ | |
| 947 } \ | 951 } \ |
| 948 break; | 952 break; |
| 949 | 953 |
| 950 #define IPC_MESSAGE_HANDLER_DELAY_REPLY(msg_class, member_func) \ | 954 #define IPC_MESSAGE_HANDLER_DELAY_REPLY(msg_class, member_func) \ |
| 951 IPC_MESSAGE_FORWARD_DELAY_REPLY(msg_class, this, \ | 955 IPC_MESSAGE_FORWARD_DELAY_REPLY(msg_class, this, \ |
| 952 _IpcMessageHandlerClass::member_func) | 956 _IpcMessageHandlerClass::member_func) |
| 953 | 957 |
| 954 // TODO(jar): fix chrome frame to always supply |code| argument. | 958 // TODO(jar): fix chrome frame to always supply |code| argument. |
| 955 #define IPC_MESSAGE_HANDLER_GENERIC(msg_class, code) \ | 959 #define IPC_MESSAGE_HANDLER_GENERIC(msg_class, code) \ |
| 956 case msg_class::ID: { \ | 960 case msg_class::ID: { \ |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 997 // equivalent without the #ifdef, VS2013 contains a bug where it is | 1001 // equivalent without the #ifdef, VS2013 contains a bug where it is |
| 998 // over-aggressive in optimizing out #includes. Putting the #ifdef is a | 1002 // over-aggressive in optimizing out #includes. Putting the #ifdef is a |
| 999 // workaround for this bug. See http://goo.gl/eGt2Fb for more details. | 1003 // workaround for this bug. See http://goo.gl/eGt2Fb for more details. |
| 1000 // This can be removed once VS2013 is fixed. | 1004 // This can be removed once VS2013 is fixed. |
| 1001 #ifdef IPC_MESSAGE_START | 1005 #ifdef IPC_MESSAGE_START |
| 1002 // Clean up IPC_MESSAGE_START in this unguarded section so that the | 1006 // Clean up IPC_MESSAGE_START in this unguarded section so that the |
| 1003 // XXX_messages.h files need not do so themselves. This makes the | 1007 // XXX_messages.h files need not do so themselves. This makes the |
| 1004 // XXX_messages.h files easier to write. | 1008 // XXX_messages.h files easier to write. |
| 1005 #undef IPC_MESSAGE_START | 1009 #undef IPC_MESSAGE_START |
| 1006 #endif | 1010 #endif |
| OLD | NEW |