OLD | NEW |
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 the first pass, IPC_MESSAGE_MACROS_ENUMS should be defined, which will | 8 // In the first pass, IPC_MESSAGE_MACROS_ENUMS should be defined, which will |
9 // create enums for each of the messages defined with the IPC_MESSAGE_* macros. | 9 // create enums for each of the messages defined with the IPC_MESSAGE_* macros. |
10 // | 10 // |
(...skipping 23 matching lines...) Expand all Loading... |
34 // | 34 // |
35 // The handler function will look like: | 35 // The handler function will look like: |
36 // void OnSyncMessageName(const type1& in1, IPC::Message* reply_msg); | 36 // void OnSyncMessageName(const type1& in1, IPC::Message* reply_msg); |
37 // | 37 // |
38 // Receiver stashes the IPC::Message* pointer, and when it's ready, it does: | 38 // Receiver stashes the IPC::Message* pointer, and when it's ready, it does: |
39 // ViewHostMsg_SyncMessageName::WriteReplyParams(reply_msg, out1, out2); | 39 // ViewHostMsg_SyncMessageName::WriteReplyParams(reply_msg, out1, out2); |
40 // Send(reply_msg); | 40 // Send(reply_msg); |
41 | 41 |
42 #include "chrome/common/ipc_message_utils.h" | 42 #include "chrome/common/ipc_message_utils.h" |
43 | 43 |
| 44 |
| 45 #ifndef MESSAGES_INTERNAL_FILE |
| 46 #error This file should only be included by X_messages.h, which needs to define
MESSAGES_INTERNAL_FILE first. |
| 47 #endif |
| 48 |
| 49 #ifndef IPC_MESSAGE_MACROS_INCLUDE_BLOCK |
| 50 #define IPC_MESSAGE_MACROS_INCLUDE_BLOCK |
| 51 |
| 52 // Multi-pass include of X_messages_internal.h. Preprocessor magic allows |
| 53 // us to use 1 header to define the enums and classes for our render messages. |
| 54 #define IPC_MESSAGE_MACROS_ENUMS |
| 55 #include MESSAGES_INTERNAL_FILE |
| 56 |
| 57 #define IPC_MESSAGE_MACROS_CLASSES |
| 58 #include MESSAGES_INTERNAL_FILE |
| 59 |
| 60 #ifdef IPC_MESSAGE_MACROS_LOG_ENABLED |
| 61 #define IPC_MESSAGE_MACROS_LOG |
| 62 #include MESSAGES_INTERNAL_FILE |
| 63 #endif |
| 64 |
| 65 #undef MESSAGES_INTERNAL_FILE |
| 66 #undef IPC_MESSAGE_MACROS_INCLUDE_BLOCK |
| 67 |
| 68 #endif |
| 69 |
| 70 |
44 // Undefine the macros from the previous pass (if any). | 71 // Undefine the macros from the previous pass (if any). |
45 #undef IPC_BEGIN_MESSAGES | 72 #undef IPC_BEGIN_MESSAGES |
46 #undef IPC_END_MESSAGES | 73 #undef IPC_END_MESSAGES |
47 #undef IPC_MESSAGE_CONTROL0 | 74 #undef IPC_MESSAGE_CONTROL0 |
48 #undef IPC_MESSAGE_CONTROL1 | 75 #undef IPC_MESSAGE_CONTROL1 |
49 #undef IPC_MESSAGE_CONTROL2 | 76 #undef IPC_MESSAGE_CONTROL2 |
50 #undef IPC_MESSAGE_CONTROL3 | 77 #undef IPC_MESSAGE_CONTROL3 |
51 #undef IPC_MESSAGE_CONTROL4 | 78 #undef IPC_MESSAGE_CONTROL4 |
52 #undef IPC_MESSAGE_CONTROL5 | 79 #undef IPC_MESSAGE_CONTROL5 |
53 #undef IPC_MESSAGE_ROUTED0 | 80 #undef IPC_MESSAGE_ROUTED0 |
54 #undef IPC_MESSAGE_ROUTED1 | 81 #undef IPC_MESSAGE_ROUTED1 |
55 #undef IPC_MESSAGE_ROUTED2 | 82 #undef IPC_MESSAGE_ROUTED2 |
56 #undef IPC_MESSAGE_ROUTED3 | 83 #undef IPC_MESSAGE_ROUTED3 |
57 #undef IPC_MESSAGE_ROUTED4 | 84 #undef IPC_MESSAGE_ROUTED4 |
58 #undef IPC_MESSAGE_ROUTED5 | 85 #undef IPC_MESSAGE_ROUTED5 |
59 #undef IPC_MESSAGE_ROUTED6 | 86 #undef IPC_MESSAGE_ROUTED6 |
60 #undef IPC_MESSAGE_EMPTY | |
61 #undef IPC_SYNC_MESSAGE_CONTROL0_0 | 87 #undef IPC_SYNC_MESSAGE_CONTROL0_0 |
62 #undef IPC_SYNC_MESSAGE_CONTROL0_1 | 88 #undef IPC_SYNC_MESSAGE_CONTROL0_1 |
63 #undef IPC_SYNC_MESSAGE_CONTROL0_2 | 89 #undef IPC_SYNC_MESSAGE_CONTROL0_2 |
64 #undef IPC_SYNC_MESSAGE_CONTROL0_3 | 90 #undef IPC_SYNC_MESSAGE_CONTROL0_3 |
65 #undef IPC_SYNC_MESSAGE_CONTROL1_0 | 91 #undef IPC_SYNC_MESSAGE_CONTROL1_0 |
66 #undef IPC_SYNC_MESSAGE_CONTROL1_1 | 92 #undef IPC_SYNC_MESSAGE_CONTROL1_1 |
67 #undef IPC_SYNC_MESSAGE_CONTROL1_2 | 93 #undef IPC_SYNC_MESSAGE_CONTROL1_2 |
68 #undef IPC_SYNC_MESSAGE_CONTROL1_3 | 94 #undef IPC_SYNC_MESSAGE_CONTROL1_3 |
69 #undef IPC_SYNC_MESSAGE_CONTROL2_0 | 95 #undef IPC_SYNC_MESSAGE_CONTROL2_0 |
70 #undef IPC_SYNC_MESSAGE_CONTROL2_1 | 96 #undef IPC_SYNC_MESSAGE_CONTROL2_1 |
(...skipping 16 matching lines...) Expand all Loading... |
87 #undef IPC_SYNC_MESSAGE_ROUTED2_1 | 113 #undef IPC_SYNC_MESSAGE_ROUTED2_1 |
88 #undef IPC_SYNC_MESSAGE_ROUTED2_2 | 114 #undef IPC_SYNC_MESSAGE_ROUTED2_2 |
89 #undef IPC_SYNC_MESSAGE_ROUTED2_3 | 115 #undef IPC_SYNC_MESSAGE_ROUTED2_3 |
90 #undef IPC_SYNC_MESSAGE_ROUTED3_0 | 116 #undef IPC_SYNC_MESSAGE_ROUTED3_0 |
91 #undef IPC_SYNC_MESSAGE_ROUTED3_1 | 117 #undef IPC_SYNC_MESSAGE_ROUTED3_1 |
92 #undef IPC_SYNC_MESSAGE_ROUTED3_2 | 118 #undef IPC_SYNC_MESSAGE_ROUTED3_2 |
93 #undef IPC_SYNC_MESSAGE_ROUTED3_3 | 119 #undef IPC_SYNC_MESSAGE_ROUTED3_3 |
94 #undef IPC_SYNC_MESSAGE_ROUTED4_0 | 120 #undef IPC_SYNC_MESSAGE_ROUTED4_0 |
95 #undef IPC_SYNC_MESSAGE_ROUTED4_1 | 121 #undef IPC_SYNC_MESSAGE_ROUTED4_1 |
96 | 122 |
| 123 |
97 #if defined(IPC_MESSAGE_MACROS_ENUMS) | 124 #if defined(IPC_MESSAGE_MACROS_ENUMS) |
98 #undef IPC_MESSAGE_MACROS_ENUMS | 125 #undef IPC_MESSAGE_MACROS_ENUMS |
99 | 126 |
100 // TODO(jabdelmalek): we're using the lowest 12 bits of type for the message | 127 // TODO(jabdelmalek): we're using the lowest 12 bits of type for the message |
101 // id, and the highest 4 bits for the channel type. This constrains us to | 128 // id, and the highest 4 bits for the channel type. This constrains us to |
102 // 16 channel types (currently using 8) and 4K messages per type. Should | 129 // 16 channel types (currently using 8) and 4K messages per type. Should |
103 // really make type be 32 bits, but then we break automation with older Chrome | 130 // really make type be 32 bits, but then we break automation with older Chrome |
104 // builds.. | 131 // builds.. |
105 #define IPC_BEGIN_MESSAGES(label, start) \ | 132 |
| 133 #define IPC_BEGIN_MESSAGES(label) \ |
106 enum label##MsgType { \ | 134 enum label##MsgType { \ |
107 label##Start = start << 12, \ | 135 label##Start = label##MsgStart << 12, \ |
108 label##PreStart = (start << 12) - 1, // Do this so that automation messages k
eep the same id as before | 136 label##PreStart = (label##MsgStart << 12) - 1, // Do this so that automation
messages keep the same id as before |
109 | 137 |
110 #define IPC_END_MESSAGES(label) \ | 138 #define IPC_END_MESSAGES(label) \ |
111 label##End \ | 139 label##End \ |
112 }; | 140 }; |
113 | 141 |
114 #define IPC_MESSAGE_CONTROL0(msg_class) \ | 142 #define IPC_MESSAGE_CONTROL0(msg_class) \ |
115 msg_class##__ID, | 143 msg_class##__ID, |
116 | 144 |
117 #define IPC_MESSAGE_CONTROL1(msg_class, type1) \ | 145 #define IPC_MESSAGE_CONTROL1(msg_class, type1) \ |
118 msg_class##__ID, | 146 msg_class##__ID, |
(...skipping 24 matching lines...) Expand all Loading... |
143 | 171 |
144 #define IPC_MESSAGE_ROUTED4(msg_class, type1, type2, type3, type4) \ | 172 #define IPC_MESSAGE_ROUTED4(msg_class, type1, type2, type3, type4) \ |
145 msg_class##__ID, | 173 msg_class##__ID, |
146 | 174 |
147 #define IPC_MESSAGE_ROUTED5(msg_class, type1, type2, type3, type4, type5) \ | 175 #define IPC_MESSAGE_ROUTED5(msg_class, type1, type2, type3, type4, type5) \ |
148 msg_class##__ID, | 176 msg_class##__ID, |
149 | 177 |
150 #define IPC_MESSAGE_ROUTED6(msg_class, type1, type2, type3, type4, type5, type6)
\ | 178 #define IPC_MESSAGE_ROUTED6(msg_class, type1, type2, type3, type4, type5, type6)
\ |
151 msg_class##__ID, | 179 msg_class##__ID, |
152 | 180 |
153 #define IPC_MESSAGE_EMPTY(msg_class) \ | |
154 msg_class##__ID, | |
155 | |
156 #define IPC_SYNC_MESSAGE_CONTROL0_0(msg_class) \ | 181 #define IPC_SYNC_MESSAGE_CONTROL0_0(msg_class) \ |
157 msg_class##__ID, | 182 msg_class##__ID, |
158 | 183 |
159 #define IPC_SYNC_MESSAGE_CONTROL0_1(msg_class, type1_out) \ | 184 #define IPC_SYNC_MESSAGE_CONTROL0_1(msg_class, type1_out) \ |
160 msg_class##__ID, | 185 msg_class##__ID, |
161 | 186 |
162 #define IPC_SYNC_MESSAGE_CONTROL0_2(msg_class, type1_out, type2_out) \ | 187 #define IPC_SYNC_MESSAGE_CONTROL0_2(msg_class, type1_out, type2_out) \ |
163 msg_class##__ID, | 188 msg_class##__ID, |
164 | 189 |
165 #define IPC_SYNC_MESSAGE_CONTROL0_3(msg_class, type1_out, type2_out, type3_out)
\ | 190 #define IPC_SYNC_MESSAGE_CONTROL0_3(msg_class, type1_out, type2_out, type3_out)
\ |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 } \ | 359 } \ |
335 } | 360 } |
336 | 361 |
337 #define IPC_END_MESSAGE_MAP_EX() \ | 362 #define IPC_END_MESSAGE_MAP_EX() \ |
338 } \ | 363 } \ |
339 } | 364 } |
340 | 365 |
341 #elif defined(IPC_MESSAGE_MACROS_LOG) | 366 #elif defined(IPC_MESSAGE_MACROS_LOG) |
342 #undef IPC_MESSAGE_MACROS_LOG | 367 #undef IPC_MESSAGE_MACROS_LOG |
343 | 368 |
344 #define IPC_BEGIN_MESSAGES(label, start) \ | 369 #define IPC_BEGIN_MESSAGES(label) \ |
345 void label##MsgLog(uint16 type, std::wstring* name, const IPC::Message* msg, s
td::wstring* params) { \ | 370 void label##MsgLog(uint16 type, std::wstring* name, const IPC::Message* msg, s
td::wstring* params) { \ |
346 switch (type) { | 371 switch (type) { |
347 | 372 |
348 #define IPC_END_MESSAGES(label) \ | 373 #define IPC_END_MESSAGES(label) \ |
349 default: \ | 374 default: \ |
350 if (name) \ | 375 if (name) \ |
351 *name = L"[UNKNOWN " L ## #label L" MSG"; \ | 376 *name = L"[UNKNOWN " L ## #label L" MSG"; \ |
352 } \ | 377 } \ |
353 } | 378 } |
354 | 379 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 | 417 |
393 #define IPC_MESSAGE_ROUTED4(msg_class, type1, type2, type3, type4) \ | 418 #define IPC_MESSAGE_ROUTED4(msg_class, type1, type2, type3, type4) \ |
394 IPC_MESSAGE_LOG(msg_class) | 419 IPC_MESSAGE_LOG(msg_class) |
395 | 420 |
396 #define IPC_MESSAGE_ROUTED5(msg_class, type1, type2, type3, type4, type5) \ | 421 #define IPC_MESSAGE_ROUTED5(msg_class, type1, type2, type3, type4, type5) \ |
397 IPC_MESSAGE_LOG(msg_class) | 422 IPC_MESSAGE_LOG(msg_class) |
398 | 423 |
399 #define IPC_MESSAGE_ROUTED6(msg_class, type1, type2, type3, type4, type5, type6)
\ | 424 #define IPC_MESSAGE_ROUTED6(msg_class, type1, type2, type3, type4, type5, type6)
\ |
400 IPC_MESSAGE_LOG(msg_class) | 425 IPC_MESSAGE_LOG(msg_class) |
401 | 426 |
402 #define IPC_MESSAGE_EMPTY(msg_class) \ | |
403 IPC_MESSAGE_LOG(msg_class) | |
404 | |
405 #define IPC_SYNC_MESSAGE_CONTROL0_0(msg_class) \ | 427 #define IPC_SYNC_MESSAGE_CONTROL0_0(msg_class) \ |
406 IPC_MESSAGE_LOG(msg_class) | 428 IPC_MESSAGE_LOG(msg_class) |
407 | 429 |
408 #define IPC_SYNC_MESSAGE_CONTROL0_1(msg_class, type1_out) \ | 430 #define IPC_SYNC_MESSAGE_CONTROL0_1(msg_class, type1_out) \ |
409 IPC_MESSAGE_LOG(msg_class) | 431 IPC_MESSAGE_LOG(msg_class) |
410 | 432 |
411 #define IPC_SYNC_MESSAGE_CONTROL0_2(msg_class, type1_out, type2_out) \ | 433 #define IPC_SYNC_MESSAGE_CONTROL0_2(msg_class, type1_out, type2_out) \ |
412 IPC_MESSAGE_LOG(msg_class) | 434 IPC_MESSAGE_LOG(msg_class) |
413 | 435 |
414 #define IPC_SYNC_MESSAGE_CONTROL0_3(msg_class, type1_out, type2_out, type3_out)
\ | 436 #define IPC_SYNC_MESSAGE_CONTROL0_3(msg_class, type1_out, type2_out, type3_out)
\ |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 | 525 |
504 #define IPC_SYNC_MESSAGE_ROUTED4_0(msg_class, type1_in, type2_in, type3_in, type
4_in) \ | 526 #define IPC_SYNC_MESSAGE_ROUTED4_0(msg_class, type1_in, type2_in, type3_in, type
4_in) \ |
505 IPC_MESSAGE_LOG(msg_class) | 527 IPC_MESSAGE_LOG(msg_class) |
506 | 528 |
507 #define IPC_SYNC_MESSAGE_ROUTED4_1(msg_class, type1_in, type2_in, type3_in, type
4_in, type1_out) \ | 529 #define IPC_SYNC_MESSAGE_ROUTED4_1(msg_class, type1_in, type2_in, type3_in, type
4_in, type1_out) \ |
508 IPC_MESSAGE_LOG(msg_class) | 530 IPC_MESSAGE_LOG(msg_class) |
509 | 531 |
510 #elif defined(IPC_MESSAGE_MACROS_CLASSES) | 532 #elif defined(IPC_MESSAGE_MACROS_CLASSES) |
511 #undef IPC_MESSAGE_MACROS_CLASSES | 533 #undef IPC_MESSAGE_MACROS_CLASSES |
512 | 534 |
513 #define IPC_BEGIN_MESSAGES(label, start) | 535 #define IPC_BEGIN_MESSAGES(label) |
514 #define IPC_END_MESSAGES(label) | 536 #define IPC_END_MESSAGES(label) |
515 | 537 |
516 #define IPC_MESSAGE_CONTROL0(msg_class) \ | 538 #define IPC_MESSAGE_CONTROL0(msg_class) \ |
517 class msg_class : public IPC::Message { \ | 539 class msg_class : public IPC::Message { \ |
518 public: \ | 540 public: \ |
519 enum { ID = msg_class##__ID }; \ | 541 enum { ID = msg_class##__ID }; \ |
520 msg_class() \ | 542 msg_class() \ |
521 : IPC::Message(MSG_ROUTING_CONTROL, \ | 543 : IPC::Message(MSG_ROUTING_CONTROL, \ |
522 ID, \ | 544 ID, \ |
523 PRIORITY_NORMAL) {} \ | 545 PRIORITY_NORMAL) {} \ |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 public: \ | 670 public: \ |
649 enum { ID = msg_class##__ID }; \ | 671 enum { ID = msg_class##__ID }; \ |
650 msg_class(int32 routing_id, const type1& arg1, const type2& arg2, \ | 672 msg_class(int32 routing_id, const type1& arg1, const type2& arg2, \ |
651 const type3& arg3, const type4& arg4, const type5& arg5, \ | 673 const type3& arg3, const type4& arg4, const type5& arg5, \ |
652 const type6& arg6) \ | 674 const type6& arg6) \ |
653 : IPC::MessageWithTuple< Tuple6<type1, type2, type3, type4, type5, \ | 675 : IPC::MessageWithTuple< Tuple6<type1, type2, type3, type4, type5, \ |
654 type6> >( \ | 676 type6> >( \ |
655 routing_id, ID, MakeTuple(arg1, arg2, arg3, arg4, arg5, arg6)) {} \ | 677 routing_id, ID, MakeTuple(arg1, arg2, arg3, arg4, arg5, arg6)) {} \ |
656 }; | 678 }; |
657 | 679 |
658 // Dummy class for now, just to give us the ID field. | |
659 #define IPC_MESSAGE_EMPTY(msg_class) \ | |
660 class msg_class { \ | |
661 public: \ | |
662 enum { ID = msg_class##__ID }; \ | |
663 static void Log(const IPC::Message* msg, std::wstring* l) {} \ | |
664 }; | |
665 | |
666 #define IPC_SYNC_MESSAGE_CONTROL0_0(msg_class) \ | 680 #define IPC_SYNC_MESSAGE_CONTROL0_0(msg_class) \ |
667 class msg_class : public IPC::MessageWithReply<Tuple0, Tuple0 > { \ | 681 class msg_class : public IPC::MessageWithReply<Tuple0, Tuple0 > { \ |
668 public: \ | 682 public: \ |
669 enum { ID = msg_class##__ID }; \ | 683 enum { ID = msg_class##__ID }; \ |
670 msg_class() \ | 684 msg_class() \ |
671 : IPC::MessageWithReply<Tuple0, Tuple0 >( \ | 685 : IPC::MessageWithReply<Tuple0, Tuple0 >( \ |
672 MSG_ROUTING_CONTROL, ID, \ | 686 MSG_ROUTING_CONTROL, ID, \ |
673 MakeTuple(), MakeTuple()) {} \ | 687 MakeTuple(), MakeTuple()) {} \ |
674 }; | 688 }; |
675 | 689 |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 public: \ | 1077 public: \ |
1064 enum { ID = msg_class##__ID }; \ | 1078 enum { ID = msg_class##__ID }; \ |
1065 msg_class(int routing_id, const type1_in& arg1, const type2_in& arg2, const
type3_in& arg3, const type4_in& arg4, type1_out* arg6) \ | 1079 msg_class(int routing_id, const type1_in& arg1, const type2_in& arg2, const
type3_in& arg3, const type4_in& arg4, type1_out* arg6) \ |
1066 : IPC::MessageWithReply<Tuple4<type1_in, type2_in, type3_in, type4_in>,
\ | 1080 : IPC::MessageWithReply<Tuple4<type1_in, type2_in, type3_in, type4_in>,
\ |
1067 Tuple1<type1_out&> >(routing_id, ID, \ | 1081 Tuple1<type1_out&> >(routing_id, ID, \ |
1068 MakeTuple(arg1, arg2, arg3, arg4), MakeRefTuple(*arg6)) {} \ | 1082 MakeTuple(arg1, arg2, arg3, arg4), MakeRefTuple(*arg6)) {} \ |
1069 }; | 1083 }; |
1070 | 1084 |
1071 #endif // #if defined() | 1085 #endif // #if defined() |
1072 | 1086 |
OLD | NEW |