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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 233 |
234 #define IPC_MESSAGE_CONTROL3(msg_class, type1, type2, type3) \ | 234 #define IPC_MESSAGE_CONTROL3(msg_class, type1, type2, type3) \ |
235 IPC_MESSAGE_DECL(ASYNC, CONTROL, msg_class, 3, 0, (type1, type2, type3), ()) | 235 IPC_MESSAGE_DECL(ASYNC, CONTROL, msg_class, 3, 0, (type1, type2, type3), ()) |
236 | 236 |
237 #define IPC_MESSAGE_CONTROL4(msg_class, type1, type2, type3, type4) \ | 237 #define IPC_MESSAGE_CONTROL4(msg_class, type1, type2, type3, type4) \ |
238 IPC_MESSAGE_DECL(ASYNC, CONTROL, msg_class, 4, 0, (type1, type2, type3, type4)
, ()) | 238 IPC_MESSAGE_DECL(ASYNC, CONTROL, msg_class, 4, 0, (type1, type2, type3, type4)
, ()) |
239 | 239 |
240 #define IPC_MESSAGE_CONTROL5(msg_class, type1, type2, type3, type4, type5) \ | 240 #define IPC_MESSAGE_CONTROL5(msg_class, type1, type2, type3, type4, type5) \ |
241 IPC_MESSAGE_DECL(ASYNC, CONTROL, msg_class, 5, 0, (type1, type2, type3, type4,
type5), ()) | 241 IPC_MESSAGE_DECL(ASYNC, CONTROL, msg_class, 5, 0, (type1, type2, type3, type4,
type5), ()) |
242 | 242 |
| 243 #define IPC_MESSAGE_CONTROL6(msg_class, type1, type2, type3, type4, type5, type6
) \ |
| 244 IPC_MESSAGE_DECL(ASYNC, CONTROL, msg_class, 6, 0, (type1, type2, type3, type4,
type5, type6), ()) |
| 245 |
243 #define IPC_MESSAGE_ROUTED0(msg_class) \ | 246 #define IPC_MESSAGE_ROUTED0(msg_class) \ |
244 IPC_MESSAGE_DECL(EMPTY, ROUTED, msg_class, 0, 0, (), ()) | 247 IPC_MESSAGE_DECL(EMPTY, ROUTED, msg_class, 0, 0, (), ()) |
245 | 248 |
246 #define IPC_MESSAGE_ROUTED1(msg_class, type1) \ | 249 #define IPC_MESSAGE_ROUTED1(msg_class, type1) \ |
247 IPC_MESSAGE_DECL(ASYNC, ROUTED, msg_class, 1, 0, (type1), ()) | 250 IPC_MESSAGE_DECL(ASYNC, ROUTED, msg_class, 1, 0, (type1), ()) |
248 | 251 |
249 #define IPC_MESSAGE_ROUTED2(msg_class, type1, type2) \ | 252 #define IPC_MESSAGE_ROUTED2(msg_class, type1, type2) \ |
250 IPC_MESSAGE_DECL(ASYNC, ROUTED, msg_class, 2, 0, (type1, type2), ()) | 253 IPC_MESSAGE_DECL(ASYNC, ROUTED, msg_class, 2, 0, (type1, type2), ()) |
251 | 254 |
252 #define IPC_MESSAGE_ROUTED3(msg_class, type1, type2, type3) \ | 255 #define IPC_MESSAGE_ROUTED3(msg_class, type1, type2, type3) \ |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 Schema::Param p; \ | 545 Schema::Param p; \ |
543 if (!Read(msg, &p)) \ | 546 if (!Read(msg, &p)) \ |
544 return false; \ | 547 return false; \ |
545 *a = p.a; \ | 548 *a = p.a; \ |
546 *b = p.b; \ | 549 *b = p.b; \ |
547 *c = p.c; \ | 550 *c = p.c; \ |
548 *d = p.d; \ | 551 *d = p.d; \ |
549 *e = p.e; \ | 552 *e = p.e; \ |
550 return true; \ | 553 return true; \ |
551 } | 554 } |
| 555 #define IPC_ASYNC_MESSAGE_METHODS_6 \ |
| 556 IPC_ASYNC_MESSAGE_METHODS_GENERIC \ |
| 557 template<class T, class S, typename TA, typename TB, typename TC, \ |
| 558 typename TD, typename TE, typename TF> \ |
| 559 static bool Dispatch(const Message* msg, T* obj, S* sender, \ |
| 560 void (T::*func)( \ |
| 561 const Message&, TA, TB, TC, TD, TE, TF)) { \ |
| 562 Schema::Param p; \ |
| 563 if (Read(msg, &p)) { \ |
| 564 (obj->*func)(*msg, p.a, p.b, p.c, p.d, p.e, p.f); \ |
| 565 return true; \ |
| 566 } \ |
| 567 return false; \ |
| 568 } \ |
| 569 template<typename TA, typename TB, typename TC, typename TD, typename TE, \ |
| 570 typename TF> \ |
| 571 static bool Read(const IPC::Message* msg, TA* a, TB* b, TC* c, TD* d, \ |
| 572 TE* e, TF* f) { \ |
| 573 Schema::Param p; \ |
| 574 if (!Read(msg, &p)) \ |
| 575 return false; \ |
| 576 *a = p.a; \ |
| 577 *b = p.b; \ |
| 578 *c = p.c; \ |
| 579 *d = p.d; \ |
| 580 *e = p.e; \ |
| 581 *f = p.f; \ |
| 582 return true; \ |
| 583 } |
552 | 584 |
553 // The following macros define the common set of methods provided by SYNC | 585 // The following macros define the common set of methods provided by SYNC |
554 // message classes. | 586 // message classes. |
555 #define IPC_SYNC_MESSAGE_METHODS_GENERIC \ | 587 #define IPC_SYNC_MESSAGE_METHODS_GENERIC \ |
556 template<class T, class S, class Method> \ | 588 template<class T, class S, class Method> \ |
557 static bool Dispatch(const Message* msg, T* obj, S* sender, Method func) { \ | 589 static bool Dispatch(const Message* msg, T* obj, S* sender, Method func) { \ |
558 Schema::SendParam send_params; \ | 590 Schema::SendParam send_params; \ |
559 bool ok = ReadSendParam(msg, &send_params); \ | 591 bool ok = ReadSendParam(msg, &send_params); \ |
560 return Schema::DispatchWithSendParams(ok, send_params, msg, obj, sender, \ | 592 return Schema::DispatchWithSendParams(ok, send_params, msg, obj, sender, \ |
561 func); \ | 593 func); \ |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 #endif // defined(IPC_MESSAGE_IMPL) | 870 #endif // defined(IPC_MESSAGE_IMPL) |
839 | 871 |
840 // Handle variable sized argument lists. These are usually invoked by token | 872 // Handle variable sized argument lists. These are usually invoked by token |
841 // pasting against the argument counts. | 873 // pasting against the argument counts. |
842 #define IPC_TYPE_IN_0() | 874 #define IPC_TYPE_IN_0() |
843 #define IPC_TYPE_IN_1(t1) const t1& arg1 | 875 #define IPC_TYPE_IN_1(t1) const t1& arg1 |
844 #define IPC_TYPE_IN_2(t1, t2) const t1& arg1, const t2& arg2 | 876 #define IPC_TYPE_IN_2(t1, t2) const t1& arg1, const t2& arg2 |
845 #define IPC_TYPE_IN_3(t1, t2, t3) const t1& arg1, const t2& arg2, cons
t t3& arg3 | 877 #define IPC_TYPE_IN_3(t1, t2, t3) const t1& arg1, const t2& arg2, cons
t t3& arg3 |
846 #define IPC_TYPE_IN_4(t1, t2, t3, t4) const t1& arg1, const t2& arg2, cons
t t3& arg3, const t4& arg4 | 878 #define IPC_TYPE_IN_4(t1, t2, t3, t4) const t1& arg1, const t2& arg2, cons
t t3& arg3, const t4& arg4 |
847 #define IPC_TYPE_IN_5(t1, t2, t3, t4, t5) const t1& arg1, const t2& arg2, cons
t t3& arg3, const t4& arg4, const t5& arg5 | 879 #define IPC_TYPE_IN_5(t1, t2, t3, t4, t5) const t1& arg1, const t2& arg2, cons
t t3& arg3, const t4& arg4, const t5& arg5 |
| 880 #define IPC_TYPE_IN_6(t1, t2, t3, t4, t5, t6) const t1& arg1, const t2& arg2,
const t3& arg3, const t4& arg4, const t5& arg5, const t6& arg6 |
848 | 881 |
849 #define IPC_TYPE_OUT_0() | 882 #define IPC_TYPE_OUT_0() |
850 #define IPC_TYPE_OUT_1(t1) t1* arg6 | 883 #define IPC_TYPE_OUT_1(t1) t1* arg6 |
851 #define IPC_TYPE_OUT_2(t1, t2) t1* arg6, t2* arg7 | 884 #define IPC_TYPE_OUT_2(t1, t2) t1* arg6, t2* arg7 |
852 #define IPC_TYPE_OUT_3(t1, t2, t3) t1* arg6, t2* arg7, t3* arg8 | 885 #define IPC_TYPE_OUT_3(t1, t2, t3) t1* arg6, t2* arg7, t3* arg8 |
853 #define IPC_TYPE_OUT_4(t1, t2, t3, t4) t1* arg6, t2* arg7, t3* arg8, t4* ar
g9 | 886 #define IPC_TYPE_OUT_4(t1, t2, t3, t4) t1* arg6, t2* arg7, t3* arg8, t4* ar
g9 |
854 | 887 |
855 #define IPC_TUPLE_IN_0() Tuple0 | 888 #define IPC_TUPLE_IN_0() Tuple0 |
856 #define IPC_TUPLE_IN_1(t1) Tuple1<t1> | 889 #define IPC_TUPLE_IN_1(t1) Tuple1<t1> |
857 #define IPC_TUPLE_IN_2(t1, t2) Tuple2<t1, t2> | 890 #define IPC_TUPLE_IN_2(t1, t2) Tuple2<t1, t2> |
858 #define IPC_TUPLE_IN_3(t1, t2, t3) Tuple3<t1, t2, t3> | 891 #define IPC_TUPLE_IN_3(t1, t2, t3) Tuple3<t1, t2, t3> |
859 #define IPC_TUPLE_IN_4(t1, t2, t3, t4) Tuple4<t1, t2, t3, t4> | 892 #define IPC_TUPLE_IN_4(t1, t2, t3, t4) Tuple4<t1, t2, t3, t4> |
860 #define IPC_TUPLE_IN_5(t1, t2, t3, t4, t5) Tuple5<t1, t2, t3, t4, t5> | 893 #define IPC_TUPLE_IN_5(t1, t2, t3, t4, t5) Tuple5<t1, t2, t3, t4, t5> |
| 894 #define IPC_TUPLE_IN_6(t1, t2, t3, t4, t5, t6) Tuple6<t1, t2, t3, t4, t5, t6> |
861 | 895 |
862 #define IPC_TUPLE_OUT_0() Tuple0 | 896 #define IPC_TUPLE_OUT_0() Tuple0 |
863 #define IPC_TUPLE_OUT_1(t1) Tuple1<t1&> | 897 #define IPC_TUPLE_OUT_1(t1) Tuple1<t1&> |
864 #define IPC_TUPLE_OUT_2(t1, t2) Tuple2<t1&, t2&> | 898 #define IPC_TUPLE_OUT_2(t1, t2) Tuple2<t1&, t2&> |
865 #define IPC_TUPLE_OUT_3(t1, t2, t3) Tuple3<t1&, t2&, t3&> | 899 #define IPC_TUPLE_OUT_3(t1, t2, t3) Tuple3<t1&, t2&, t3&> |
866 #define IPC_TUPLE_OUT_4(t1, t2, t3, t4) Tuple4<t1&, t2&, t3&, t4&> | 900 #define IPC_TUPLE_OUT_4(t1, t2, t3, t4) Tuple4<t1&, t2&, t3&, t4&> |
867 | 901 |
868 #define IPC_NAME_IN_0() MakeTuple() | 902 #define IPC_NAME_IN_0() MakeTuple() |
869 #define IPC_NAME_IN_1(t1) MakeRefTuple(arg1) | 903 #define IPC_NAME_IN_1(t1) MakeRefTuple(arg1) |
870 #define IPC_NAME_IN_2(t1, t2) MakeRefTuple(arg1, arg2) | 904 #define IPC_NAME_IN_2(t1, t2) MakeRefTuple(arg1, arg2) |
871 #define IPC_NAME_IN_3(t1, t2, t3) MakeRefTuple(arg1, arg2, arg3) | 905 #define IPC_NAME_IN_3(t1, t2, t3) MakeRefTuple(arg1, arg2, arg3) |
872 #define IPC_NAME_IN_4(t1, t2, t3, t4) MakeRefTuple(arg1, arg2, arg3, arg4) | 906 #define IPC_NAME_IN_4(t1, t2, t3, t4) MakeRefTuple(arg1, arg2, arg3, a
rg4) |
873 #define IPC_NAME_IN_5(t1, t2, t3, t4, t5) MakeRefTuple(arg1, arg2, arg3, arg4,
arg5) | 907 #define IPC_NAME_IN_5(t1, t2, t3, t4, t5) MakeRefTuple(arg1, arg2, arg3, a
rg4, arg5) |
| 908 #define IPC_NAME_IN_6(t1, t2, t3, t4, t5, t6) MakeRefTuple(arg1, arg2, arg3, a
rg4, arg5, arg6) |
874 | 909 |
875 #define IPC_NAME_OUT_0() MakeTuple() | 910 #define IPC_NAME_OUT_0() MakeTuple() |
876 #define IPC_NAME_OUT_1(t1) MakeRefTuple(*arg6) | 911 #define IPC_NAME_OUT_1(t1) MakeRefTuple(*arg6) |
877 #define IPC_NAME_OUT_2(t1, t2) MakeRefTuple(*arg6, *arg7) | 912 #define IPC_NAME_OUT_2(t1, t2) MakeRefTuple(*arg6, *arg7) |
878 #define IPC_NAME_OUT_3(t1, t2, t3) MakeRefTuple(*arg6, *arg7, *arg8) | 913 #define IPC_NAME_OUT_3(t1, t2, t3) MakeRefTuple(*arg6, *arg7, *arg8) |
879 #define IPC_NAME_OUT_4(t1, t2, t3, t4) MakeRefTuple(*arg6, *arg7, *arg8, *a
rg9) | 914 #define IPC_NAME_OUT_4(t1, t2, t3, t4) MakeRefTuple(*arg6, *arg7, *arg8, *a
rg9) |
880 | 915 |
881 // There are places where the syntax requires a comma if there are input args, | 916 // There are places where the syntax requires a comma if there are input args, |
882 // if there are input args and output args, or if there are input args or | 917 // if there are input args and output args, or if there are input args or |
883 // output args. These macros allow generation of the comma as needed; invoke | 918 // output args. These macros allow generation of the comma as needed; invoke |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 // equivalent without the #ifdef, VS2013 contains a bug where it is | 1049 // equivalent without the #ifdef, VS2013 contains a bug where it is |
1015 // over-aggressive in optimizing out #includes. Putting the #ifdef is a | 1050 // over-aggressive in optimizing out #includes. Putting the #ifdef is a |
1016 // workaround for this bug. See http://goo.gl/eGt2Fb for more details. | 1051 // workaround for this bug. See http://goo.gl/eGt2Fb for more details. |
1017 // This can be removed once VS2013 is fixed. | 1052 // This can be removed once VS2013 is fixed. |
1018 #ifdef IPC_MESSAGE_START | 1053 #ifdef IPC_MESSAGE_START |
1019 // Clean up IPC_MESSAGE_START in this unguarded section so that the | 1054 // Clean up IPC_MESSAGE_START in this unguarded section so that the |
1020 // XXX_messages.h files need not do so themselves. This makes the | 1055 // XXX_messages.h files need not do so themselves. This makes the |
1021 // XXX_messages.h files easier to write. | 1056 // XXX_messages.h files easier to write. |
1022 #undef IPC_MESSAGE_START | 1057 #undef IPC_MESSAGE_START |
1023 #endif | 1058 #endif |
OLD | NEW |