| 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. | |
| 186 // | 183 // |
| 187 // The handler function will look like: | 184 // The handler function will look like: |
| 188 // void OnSyncMessageName(const type1& in1, IPC::Message* reply_msg); | 185 // void OnSyncMessageName(const type1& in1, IPC::Message* reply_msg); |
| 189 // | 186 // |
| 190 // Receiver stashes the IPC::Message* pointer, and when it's ready, it does: | 187 // Receiver stashes the IPC::Message* pointer, and when it's ready, it does: |
| 191 // ViewHostMsg_SyncMessageName::WriteReplyParams(reply_msg, out1, out2); | 188 // ViewHostMsg_SyncMessageName::WriteReplyParams(reply_msg, out1, out2); |
| 192 // Send(reply_msg); | 189 // Send(reply_msg); |
| 193 | 190 |
| 194 // Files that want to export their ipc messages should do | 191 // Files that want to export their ipc messages should do |
| 195 // #undef IPC_MESSAGE_EXPORT | 192 // #undef IPC_MESSAGE_EXPORT |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 if (!msg_class::DispatchDelayReply(&ipc_message__, obj, param__, \ | 364 if (!msg_class::DispatchDelayReply(&ipc_message__, obj, param__, \ |
| 368 &member_func)) \ | 365 &member_func)) \ |
| 369 ipc_message__.set_dispatch_error(); \ | 366 ipc_message__.set_dispatch_error(); \ |
| 370 } \ | 367 } \ |
| 371 break; | 368 break; |
| 372 | 369 |
| 373 #define IPC_MESSAGE_HANDLER_DELAY_REPLY(msg_class, member_func) \ | 370 #define IPC_MESSAGE_HANDLER_DELAY_REPLY(msg_class, member_func) \ |
| 374 IPC_MESSAGE_FORWARD_DELAY_REPLY(msg_class, this, \ | 371 IPC_MESSAGE_FORWARD_DELAY_REPLY(msg_class, this, \ |
| 375 _IpcMessageHandlerClass::member_func) | 372 _IpcMessageHandlerClass::member_func) |
| 376 | 373 |
| 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 | |
| 391 // TODO(jar): fix chrome frame to always supply |code| argument. | 374 // TODO(jar): fix chrome frame to always supply |code| argument. |
| 392 #define IPC_MESSAGE_HANDLER_GENERIC(msg_class, code) \ | 375 #define IPC_MESSAGE_HANDLER_GENERIC(msg_class, code) \ |
| 393 case msg_class::ID: { \ | 376 case msg_class::ID: { \ |
| 394 /* TRACK_RUN_IN_THIS_SCOPED_REGION(code); TODO(jar) */ \ | 377 /* TRACK_RUN_IN_THIS_SCOPED_REGION(code); TODO(jar) */ \ |
| 395 code; \ | 378 code; \ |
| 396 } \ | 379 } \ |
| 397 break; | 380 break; |
| 398 | 381 |
| 399 #define IPC_REPLY_HANDLER(func) \ | 382 #define IPC_REPLY_HANDLER(func) \ |
| 400 case IPC_REPLY_ID: { \ | 383 case IPC_REPLY_ID: { \ |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c, d, e), (f, g, h)) | 542 IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c, d, e), (f, g, h)) |
| 560 #define IPC_SYNC_MESSAGE_ROUTED5_4(msg, a, b, c, d, e, f, g, h, i) \ | 543 #define IPC_SYNC_MESSAGE_ROUTED5_4(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)) | 544 IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c, d, e), (f, g, h, i)) |
| 562 | 545 |
| 563 #endif // IPC_IPC_MESSAGE_MACROS_H_ | 546 #endif // IPC_IPC_MESSAGE_MACROS_H_ |
| 564 | 547 |
| 565 // Clean up IPC_MESSAGE_START in this unguarded section so that the | 548 // Clean up IPC_MESSAGE_START in this unguarded section so that the |
| 566 // XXX_messages.h files need not do so themselves. This makes the | 549 // XXX_messages.h files need not do so themselves. This makes the |
| 567 // XXX_messages.h files easier to write. | 550 // XXX_messages.h files easier to write. |
| 568 #undef IPC_MESSAGE_START | 551 #undef IPC_MESSAGE_START |
| OLD | NEW |