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