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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 // void OnSyncMessageName(const type1& in1, type2* out1, type3* out2) | 173 // void OnSyncMessageName(const type1& in1, type2* out1, type3* out2) |
174 // | 174 // |
175 // A caller can also send a synchronous message, while the receiver can respond | 175 // A caller can also send a synchronous message, while the receiver can respond |
176 // at a later time. This is transparent from the sender's side. The receiver | 176 // at a later time. This is transparent from the sender's side. The receiver |
177 // needs to use a different handler that takes in a IPC::Message* as the output | 177 // needs to use a different handler that takes in a IPC::Message* as the output |
178 // type, stash the message, and when it has the data it can Send the message. | 178 // type, stash the message, and when it has the data it can Send the message. |
179 // | 179 // |
180 // Use the IPC_MESSAGE_HANDLER_DELAY_REPLY macro instead of IPC_MESSAGE_HANDLER | 180 // Use the IPC_MESSAGE_HANDLER_DELAY_REPLY macro instead of IPC_MESSAGE_HANDLER |
181 // IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_SyncMessageName, | 181 // IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_SyncMessageName, |
182 // OnSyncMessageName) | 182 // OnSyncMessageName) |
| 183 // Unlike IPC_MESSAGE_HANDLER which works with IPC_BEGIN_MESSAGE_MAP as well as |
| 184 // IPC_BEGIN_MESSAGE_MAP_WITH_PARAM, one needs to use |
| 185 // IPC_MESSAGE_HANDLER_WITH_PARAM_DELAY_REPLY to properly handle the param. |
183 // | 186 // |
184 // The handler function will look like: | 187 // The handler function will look like: |
185 // void OnSyncMessageName(const type1& in1, IPC::Message* reply_msg); | 188 // void OnSyncMessageName(const type1& in1, IPC::Message* reply_msg); |
186 // | 189 // |
187 // Receiver stashes the IPC::Message* pointer, and when it's ready, it does: | 190 // Receiver stashes the IPC::Message* pointer, and when it's ready, it does: |
188 // ViewHostMsg_SyncMessageName::WriteReplyParams(reply_msg, out1, out2); | 191 // ViewHostMsg_SyncMessageName::WriteReplyParams(reply_msg, out1, out2); |
189 // Send(reply_msg); | 192 // Send(reply_msg); |
190 | 193 |
191 // Files that want to export their ipc messages should do | 194 // Files that want to export their ipc messages should do |
192 // #undef IPC_MESSAGE_EXPORT | 195 // #undef IPC_MESSAGE_EXPORT |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 if (!msg_class::DispatchDelayReply(&ipc_message__, obj, param__, \ | 367 if (!msg_class::DispatchDelayReply(&ipc_message__, obj, param__, \ |
365 &member_func)) \ | 368 &member_func)) \ |
366 ipc_message__.set_dispatch_error(); \ | 369 ipc_message__.set_dispatch_error(); \ |
367 } \ | 370 } \ |
368 break; | 371 break; |
369 | 372 |
370 #define IPC_MESSAGE_HANDLER_DELAY_REPLY(msg_class, member_func) \ | 373 #define IPC_MESSAGE_HANDLER_DELAY_REPLY(msg_class, member_func) \ |
371 IPC_MESSAGE_FORWARD_DELAY_REPLY(msg_class, this, \ | 374 IPC_MESSAGE_FORWARD_DELAY_REPLY(msg_class, this, \ |
372 _IpcMessageHandlerClass::member_func) | 375 _IpcMessageHandlerClass::member_func) |
373 | 376 |
| 377 #define IPC_MESSAGE_FORWARD_WITH_PARAM_DELAY_REPLY(msg_class, obj, \ |
| 378 member_func) \ |
| 379 case msg_class::ID: { \ |
| 380 TRACK_RUN_IN_THIS_SCOPED_REGION(member_func); \ |
| 381 if (!msg_class::DispatchWithParamDelayReply(&ipc_message__, obj, param__, \ |
| 382 &member_func)) \ |
| 383 ipc_message__.set_dispatch_error(); \ |
| 384 } \ |
| 385 break; |
| 386 |
| 387 #define IPC_MESSAGE_HANDLER_WITH_PARAM_DELAY_REPLY(msg_class, member_func) \ |
| 388 IPC_MESSAGE_FORWARD_WITH_PARAM_DELAY_REPLY( \ |
| 389 msg_class, this, _IpcMessageHandlerClass::member_func) |
| 390 |
374 // TODO(jar): fix chrome frame to always supply |code| argument. | 391 // TODO(jar): fix chrome frame to always supply |code| argument. |
375 #define IPC_MESSAGE_HANDLER_GENERIC(msg_class, code) \ | 392 #define IPC_MESSAGE_HANDLER_GENERIC(msg_class, code) \ |
376 case msg_class::ID: { \ | 393 case msg_class::ID: { \ |
377 /* TRACK_RUN_IN_THIS_SCOPED_REGION(code); TODO(jar) */ \ | 394 /* TRACK_RUN_IN_THIS_SCOPED_REGION(code); TODO(jar) */ \ |
378 code; \ | 395 code; \ |
379 } \ | 396 } \ |
380 break; | 397 break; |
381 | 398 |
382 #define IPC_REPLY_HANDLER(func) \ | 399 #define IPC_REPLY_HANDLER(func) \ |
383 case IPC_REPLY_ID: { \ | 400 case IPC_REPLY_ID: { \ |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c, d, e), (f, g, h)) | 559 IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c, d, e), (f, g, h)) |
543 #define IPC_SYNC_MESSAGE_ROUTED5_4(msg, a, b, c, d, e, f, g, h, i) \ | 560 #define IPC_SYNC_MESSAGE_ROUTED5_4(msg, a, b, c, d, e, f, g, h, i) \ |
544 IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c, d, e), (f, g, h, i)) | 561 IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c, d, e), (f, g, h, i)) |
545 | 562 |
546 #endif // IPC_IPC_MESSAGE_MACROS_H_ | 563 #endif // IPC_IPC_MESSAGE_MACROS_H_ |
547 | 564 |
548 // Clean up IPC_MESSAGE_START in this unguarded section so that the | 565 // Clean up IPC_MESSAGE_START in this unguarded section so that the |
549 // XXX_messages.h files need not do so themselves. This makes the | 566 // XXX_messages.h files need not do so themselves. This makes the |
550 // XXX_messages.h files easier to write. | 567 // XXX_messages.h files easier to write. |
551 #undef IPC_MESSAGE_START | 568 #undef IPC_MESSAGE_START |
OLD | NEW |