OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 #define IPC_STRUCT_BEGIN(struct_name) \ | 187 #define IPC_STRUCT_BEGIN(struct_name) \ |
188 struct struct_name; \ | 188 struct struct_name; \ |
189 IPC_STRUCT_TRAITS_BEGIN(struct_name) \ | 189 IPC_STRUCT_TRAITS_BEGIN(struct_name) \ |
190 IPC_STRUCT_TRAITS_END() \ | 190 IPC_STRUCT_TRAITS_END() \ |
191 struct struct_name : IPC::NoParams { \ | 191 struct struct_name : IPC::NoParams { \ |
192 struct_name(); \ | 192 struct_name(); \ |
193 ~struct_name(); | 193 ~struct_name(); |
194 #define IPC_STRUCT_MEMBER(type, name) type name; | 194 #define IPC_STRUCT_MEMBER(type, name) type name; |
195 #define IPC_STRUCT_END() }; | 195 #define IPC_STRUCT_END() }; |
196 | 196 |
| 197 // Override this to force message classes to be exported. |
| 198 #ifndef IPC_MESSAGE_EXPORT |
| 199 #define IPC_MESSAGE_EXPORT |
| 200 #endif |
| 201 |
197 // Message macros collect specific numbers of arguments and funnel them into | 202 // Message macros collect specific numbers of arguments and funnel them into |
198 // the common message generation macro. These should never be redefined. | 203 // the common message generation macro. These should never be redefined. |
199 #define IPC_MESSAGE_CONTROL0(msg_class) \ | 204 #define IPC_MESSAGE_CONTROL0(msg_class) \ |
200 IPC_MESSAGE_DECL(EMPTY, CONTROL, msg_class, 0, 0, (), ()) | 205 IPC_MESSAGE_DECL(EMPTY, CONTROL, msg_class, 0, 0, (), ()) |
201 | 206 |
202 #define IPC_MESSAGE_CONTROL1(msg_class, type1) \ | 207 #define IPC_MESSAGE_CONTROL1(msg_class, type1) \ |
203 IPC_MESSAGE_DECL(ASYNC, CONTROL, msg_class, 1, 0, (type1), ()) | 208 IPC_MESSAGE_DECL(ASYNC, CONTROL, msg_class, 1, 0, (type1), ()) |
204 | 209 |
205 #define IPC_MESSAGE_CONTROL2(msg_class, type1, type2) \ | 210 #define IPC_MESSAGE_CONTROL2(msg_class, type1, type2) \ |
206 IPC_MESSAGE_DECL(ASYNC, CONTROL, msg_class, 2, 0, (type1, type2), ()) | 211 IPC_MESSAGE_DECL(ASYNC, CONTROL, msg_class, 2, 0, (type1, type2), ()) |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 | 410 |
406 #define IPC_SYNC_MESSAGE_ROUTED5_2(msg_class, type1_in, type2_in, type3_in, type
4_in, type5_in, type1_out, type2_out) \ | 411 #define IPC_SYNC_MESSAGE_ROUTED5_2(msg_class, type1_in, type2_in, type3_in, type
4_in, type5_in, type1_out, type2_out) \ |
407 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 5, 2, (type1_in, type2_in, type3_in,
type4_in, type5_in), (type1_out, type2_out)) | 412 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 5, 2, (type1_in, type2_in, type3_in,
type4_in, type5_in), (type1_out, type2_out)) |
408 | 413 |
409 #define IPC_SYNC_MESSAGE_ROUTED5_3(msg_class, type1_in, type2_in, type3_in, type
4_in, type5_in, type1_out, type2_out, type3_out) \ | 414 #define IPC_SYNC_MESSAGE_ROUTED5_3(msg_class, type1_in, type2_in, type3_in, type
4_in, type5_in, type1_out, type2_out, type3_out) \ |
410 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 5, 3, (type1_in, type2_in, type3_in,
type4_in, type5_in), (type1_out, type2_out, type3_out)) | 415 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 5, 3, (type1_in, type2_in, type3_in,
type4_in, type5_in), (type1_out, type2_out, type3_out)) |
411 | 416 |
412 #define IPC_SYNC_MESSAGE_ROUTED5_4(msg_class, type1_in, type2_in, type3_in, type
4_in, type5_in, type1_out, type2_out, type3_out, type4_out) \ | 417 #define IPC_SYNC_MESSAGE_ROUTED5_4(msg_class, type1_in, type2_in, type3_in, type
4_in, type5_in, type1_out, type2_out, type3_out, type4_out) \ |
413 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 5, 4, (type1_in, type2_in, type3_in,
type4_in, type5_in), (type1_out, type2_out, type3_out, type4_out)) | 418 IPC_MESSAGE_DECL(SYNC, ROUTED, msg_class, 5, 4, (type1_in, type2_in, type3_in,
type4_in, type5_in), (type1_out, type2_out, type3_out, type4_out)) |
414 | 419 |
| 420 // The following macros define the common set of methods provided by ASYNC |
| 421 // message classes. |
| 422 #define IPC_ASYNC_MESSAGE_METHODS_GENERIC \ |
| 423 template<class T, class S, class Method> \ |
| 424 static bool Dispatch(const Message* msg, T* obj, S* sender, Method func) { \ |
| 425 Schema::Param p; \ |
| 426 if (Read(msg, &p)) { \ |
| 427 DispatchToMethod(obj, func, p); \ |
| 428 return true; \ |
| 429 } \ |
| 430 return false; \ |
| 431 } |
| 432 #define IPC_ASYNC_MESSAGE_METHODS_1 \ |
| 433 IPC_ASYNC_MESSAGE_METHODS_GENERIC \ |
| 434 template<class T, class S, typename TA> \ |
| 435 static bool Dispatch(const Message* msg, T* obj, S* sender, \ |
| 436 void (T::*func)(const Message&, TA)) { \ |
| 437 Schema::Param p; \ |
| 438 if (Read(msg, &p)) { \ |
| 439 (obj->*func)(*msg, p.a); \ |
| 440 return true; \ |
| 441 } \ |
| 442 return false; \ |
| 443 } |
| 444 #define IPC_ASYNC_MESSAGE_METHODS_2 \ |
| 445 IPC_ASYNC_MESSAGE_METHODS_GENERIC \ |
| 446 template<class T, class S, typename TA, typename TB> \ |
| 447 static bool Dispatch(const Message* msg, T* obj, S* sender, \ |
| 448 void (T::*func)(const Message&, TA, TB)) { \ |
| 449 Schema::Param p; \ |
| 450 if (Read(msg, &p)) { \ |
| 451 (obj->*func)(*msg, p.a, p.b); \ |
| 452 return true; \ |
| 453 } \ |
| 454 return false; \ |
| 455 } \ |
| 456 template<typename TA, typename TB> \ |
| 457 static bool Read(const IPC::Message* msg, TA* a, TB* b) { \ |
| 458 Schema::Param p; \ |
| 459 if (!Read(msg, &p)) \ |
| 460 return false; \ |
| 461 *a = p.a; \ |
| 462 *b = p.b; \ |
| 463 return true; \ |
| 464 } |
| 465 #define IPC_ASYNC_MESSAGE_METHODS_3 \ |
| 466 IPC_ASYNC_MESSAGE_METHODS_GENERIC \ |
| 467 template<class T, class S, typename TA, typename TB, typename TC> \ |
| 468 static bool Dispatch(const Message* msg, T* obj, S* sender, \ |
| 469 void (T::*func)(const Message&, TA, TB, TC)) { \ |
| 470 Schema::Param p; \ |
| 471 if (Read(msg, &p)) { \ |
| 472 (obj->*func)(*msg, p.a, p.b, p.c); \ |
| 473 return true; \ |
| 474 } \ |
| 475 return false; \ |
| 476 } \ |
| 477 template<typename TA, typename TB, typename TC> \ |
| 478 static bool Read(const IPC::Message* msg, TA* a, TB* b, TC* c) { \ |
| 479 Schema::Param p; \ |
| 480 if (!Read(msg, &p)) \ |
| 481 return false; \ |
| 482 *a = p.a; \ |
| 483 *b = p.b; \ |
| 484 *c = p.c; \ |
| 485 return true; \ |
| 486 } |
| 487 #define IPC_ASYNC_MESSAGE_METHODS_4 \ |
| 488 IPC_ASYNC_MESSAGE_METHODS_GENERIC \ |
| 489 template<class T, class S, typename TA, typename TB, typename TC, \ |
| 490 typename TD> \ |
| 491 static bool Dispatch(const Message* msg, T* obj, S* sender, \ |
| 492 void (T::*func)(const Message&, TA, TB, TC, TD)) { \ |
| 493 Schema::Param p; \ |
| 494 if (Read(msg, &p)) { \ |
| 495 (obj->*func)(*msg, p.a, p.b, p.c, p.d); \ |
| 496 return true; \ |
| 497 } \ |
| 498 return false; \ |
| 499 } \ |
| 500 template<typename TA, typename TB, typename TC, typename TD> \ |
| 501 static bool Read(const IPC::Message* msg, TA* a, TB* b, TC* c, TD* d) { \ |
| 502 Schema::Param p; \ |
| 503 if (!Read(msg, &p)) \ |
| 504 return false; \ |
| 505 *a = p.a; \ |
| 506 *b = p.b; \ |
| 507 *c = p.c; \ |
| 508 *d = p.d; \ |
| 509 return true; \ |
| 510 } |
| 511 #define IPC_ASYNC_MESSAGE_METHODS_5 \ |
| 512 IPC_ASYNC_MESSAGE_METHODS_GENERIC \ |
| 513 template<class T, class S, typename TA, typename TB, typename TC, \ |
| 514 typename TD, typename TE> \ |
| 515 static bool Dispatch(const Message* msg, T* obj, S* sender, \ |
| 516 void (T::*func)(const Message&, TA, TB, TC, TD, TE)) { \ |
| 517 Schema::Param p; \ |
| 518 if (Read(msg, &p)) { \ |
| 519 (obj->*func)(*msg, p.a, p.b, p.c, p.d, p.e); \ |
| 520 return true; \ |
| 521 } \ |
| 522 return false; \ |
| 523 } \ |
| 524 template<typename TA, typename TB, typename TC, typename TD, typename TE> \ |
| 525 static bool Read(const IPC::Message* msg, TA* a, TB* b, TC* c, TD* d, \ |
| 526 TE* e) { \ |
| 527 Schema::Param p; \ |
| 528 if (!Read(msg, &p)) \ |
| 529 return false; \ |
| 530 *a = p.a; \ |
| 531 *b = p.b; \ |
| 532 *c = p.c; \ |
| 533 *d = p.d; \ |
| 534 *e = p.e; \ |
| 535 return true; \ |
| 536 } |
| 537 |
| 538 // The following macros define the common set of methods provided by SYNC |
| 539 // message classes. |
| 540 #define IPC_SYNC_MESSAGE_METHODS_GENERIC \ |
| 541 template<class T, class S, class Method> \ |
| 542 static bool Dispatch(const Message* msg, T* obj, S* sender, Method func) { \ |
| 543 Schema::SendParam send_params; \ |
| 544 bool ok = ReadSendParam(msg, &send_params); \ |
| 545 return Schema::DispatchWithSendParams(ok, send_params, msg, obj, sender, \ |
| 546 func); \ |
| 547 } \ |
| 548 template<class T, class Method> \ |
| 549 static bool DispatchDelayReply(const Message* msg, T* obj, Method func) { \ |
| 550 Schema::SendParam send_params; \ |
| 551 bool ok = ReadSendParam(msg, &send_params); \ |
| 552 return Schema::DispatchDelayReplyWithSendParams(ok, send_params, msg, \ |
| 553 obj, func); \ |
| 554 } |
| 555 #define IPC_SYNC_MESSAGE_METHODS_0 \ |
| 556 IPC_SYNC_MESSAGE_METHODS_GENERIC |
| 557 #define IPC_SYNC_MESSAGE_METHODS_1 \ |
| 558 IPC_SYNC_MESSAGE_METHODS_GENERIC \ |
| 559 template<typename TA> \ |
| 560 static void WriteReplyParams(Message* reply, TA a) { \ |
| 561 Schema::WriteReplyParams(reply, a); \ |
| 562 } |
| 563 #define IPC_SYNC_MESSAGE_METHODS_2 \ |
| 564 IPC_SYNC_MESSAGE_METHODS_GENERIC \ |
| 565 template<typename TA, typename TB> \ |
| 566 static void WriteReplyParams(Message* reply, TA a, TB b) { \ |
| 567 Schema::WriteReplyParams(reply, a, b); \ |
| 568 } |
| 569 #define IPC_SYNC_MESSAGE_METHODS_3 \ |
| 570 IPC_SYNC_MESSAGE_METHODS_GENERIC \ |
| 571 template<typename TA, typename TB, typename TC> \ |
| 572 static void WriteReplyParams(Message* reply, TA a, TB b, TC c) { \ |
| 573 Schema::WriteReplyParams(reply, a, b, c); \ |
| 574 } |
| 575 #define IPC_SYNC_MESSAGE_METHODS_4 \ |
| 576 IPC_SYNC_MESSAGE_METHODS_GENERIC \ |
| 577 template<typename TA, typename TB, typename TC, typename TD> \ |
| 578 static void WriteReplyParams(Message* reply, TA a, TB b, TC c, TD d) { \ |
| 579 Schema::WriteReplyParams(reply, a, b, c, d); \ |
| 580 } |
| 581 #define IPC_SYNC_MESSAGE_METHODS_5 \ |
| 582 IPC_SYNC_MESSAGE_METHODS_GENERIC \ |
| 583 template<typename TA, typename TB, typename TC, typename TD, typename TE> \ |
| 584 static void WriteReplyParams(Message* reply, TA a, TB b, TC c, TD d, TE e) { \ |
| 585 Schema::WriteReplyParams(reply, a, b, c, d, e); \ |
| 586 } |
| 587 |
415 // Common message macro which dispatches into one of the 6 (sync x kind) | 588 // Common message macro which dispatches into one of the 6 (sync x kind) |
416 // routines. There is a way that these 6 cases can be lumped together, | 589 // routines. There is a way that these 6 cases can be lumped together, |
417 // but the macros get very complicated in that case. | 590 // but the macros get very complicated in that case. |
418 // Note: intended be redefined to generate other information. | 591 // Note: intended be redefined to generate other information. |
419 #define IPC_MESSAGE_DECL(sync, kind, msg_class, \ | 592 #define IPC_MESSAGE_DECL(sync, kind, msg_class, \ |
420 in_cnt, out_cnt, in_list, out_list) \ | 593 in_cnt, out_cnt, in_list, out_list) \ |
421 IPC_##sync##_##kind##_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ | 594 IPC_##sync##_##kind##_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ |
422 IPC_MESSAGE_EXTRA(sync, kind, msg_class, in_cnt, out_cnt, in_list, out_list) | 595 IPC_MESSAGE_EXTRA(sync, kind, msg_class, in_cnt, out_cnt, in_list, out_list) |
423 | 596 |
424 #define IPC_EMPTY_CONTROL_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ | 597 #define IPC_EMPTY_CONTROL_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ |
425 class msg_class : public IPC::Message { \ | 598 class msg_class : public IPC::Message { \ |
426 public: \ | 599 public: \ |
| 600 typedef IPC::Message Schema; \ |
427 enum { ID = IPC_MESSAGE_ID() }; \ | 601 enum { ID = IPC_MESSAGE_ID() }; \ |
428 msg_class() : IPC::Message(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL) {} \ | 602 msg_class() : IPC::Message(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL) {} \ |
429 }; | 603 }; |
430 | 604 |
431 #define IPC_EMPTY_ROUTED_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ | 605 #define IPC_EMPTY_ROUTED_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ |
432 class msg_class : public IPC::Message { \ | 606 class msg_class : public IPC::Message { \ |
433 public: \ | 607 public: \ |
| 608 typedef IPC::Message Schema; \ |
434 enum { ID = IPC_MESSAGE_ID() }; \ | 609 enum { ID = IPC_MESSAGE_ID() }; \ |
435 msg_class(int32 routing_id) \ | 610 msg_class(int32 routing_id) \ |
436 : IPC::Message(routing_id, ID, PRIORITY_NORMAL) {} \ | 611 : IPC::Message(routing_id, ID, PRIORITY_NORMAL) {} \ |
437 }; | 612 }; |
438 | 613 |
439 #define IPC_ASYNC_CONTROL_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ | 614 #define IPC_ASYNC_CONTROL_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ |
440 class msg_class : \ | 615 class IPC_MESSAGE_EXPORT msg_class : public IPC::Message { \ |
441 public IPC::MessageWithTuple<IPC_TUPLE_IN_##in_cnt in_list> { \ | |
442 public: \ | 616 public: \ |
| 617 typedef IPC::MessageSchema<IPC_TUPLE_IN_##in_cnt in_list> Schema; \ |
| 618 typedef Schema::Param Param; \ |
443 enum { ID = IPC_MESSAGE_ID() }; \ | 619 enum { ID = IPC_MESSAGE_ID() }; \ |
444 msg_class(IPC_TYPE_IN_##in_cnt in_list); \ | 620 msg_class(IPC_TYPE_IN_##in_cnt in_list); \ |
445 virtual ~msg_class(); \ | 621 virtual ~msg_class(); \ |
| 622 static bool Read(const Message* msg, Schema::Param* p); \ |
446 static void Log(std::string* name, const Message* msg, std::string* l); \ | 623 static void Log(std::string* name, const Message* msg, std::string* l); \ |
| 624 IPC_ASYNC_MESSAGE_METHODS_##in_cnt \ |
447 }; | 625 }; |
448 | 626 |
449 #define IPC_ASYNC_ROUTED_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ | 627 #define IPC_ASYNC_ROUTED_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ |
450 class msg_class : \ | 628 class IPC_MESSAGE_EXPORT msg_class : public IPC::Message { \ |
451 public IPC::MessageWithTuple<IPC_TUPLE_IN_##in_cnt in_list> { \ | |
452 public: \ | 629 public: \ |
| 630 typedef IPC::MessageSchema<IPC_TUPLE_IN_##in_cnt in_list> Schema; \ |
| 631 typedef Schema::Param Param; \ |
453 enum { ID = IPC_MESSAGE_ID() }; \ | 632 enum { ID = IPC_MESSAGE_ID() }; \ |
454 msg_class(int32 routing_id IPC_COMMA_##in_cnt \ | 633 msg_class(int32 routing_id IPC_COMMA_##in_cnt \ |
455 IPC_TYPE_IN_##in_cnt in_list); \ | 634 IPC_TYPE_IN_##in_cnt in_list); \ |
456 virtual ~msg_class(); \ | 635 virtual ~msg_class(); \ |
| 636 static bool Read(const Message* msg, Schema::Param* p); \ |
457 static void Log(std::string* name, const Message* msg, std::string* l); \ | 637 static void Log(std::string* name, const Message* msg, std::string* l); \ |
| 638 IPC_ASYNC_MESSAGE_METHODS_##in_cnt \ |
458 }; | 639 }; |
459 | 640 |
460 #define IPC_SYNC_CONTROL_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ | 641 #define IPC_SYNC_CONTROL_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ |
461 class msg_class : \ | 642 class IPC_MESSAGE_EXPORT msg_class : public IPC::SyncMessage { \ |
462 public IPC::MessageWithReply<IPC_TUPLE_IN_##in_cnt in_list, \ | |
463 IPC_TUPLE_OUT_##out_cnt out_list> { \ | |
464 public: \ | 643 public: \ |
| 644 typedef IPC::SyncMessageSchema<IPC_TUPLE_IN_##in_cnt in_list, \ |
| 645 IPC_TUPLE_OUT_##out_cnt out_list> Schema; \ |
| 646 typedef Schema::ReplyParam ReplyParam; \ |
| 647 typedef Schema::SendParam SendParam; \ |
465 enum { ID = IPC_MESSAGE_ID() }; \ | 648 enum { ID = IPC_MESSAGE_ID() }; \ |
466 msg_class(IPC_TYPE_IN_##in_cnt in_list \ | 649 msg_class(IPC_TYPE_IN_##in_cnt in_list \ |
467 IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \ | 650 IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \ |
468 IPC_TYPE_OUT_##out_cnt out_list); \ | 651 IPC_TYPE_OUT_##out_cnt out_list); \ |
469 virtual ~msg_class(); \ | 652 virtual ~msg_class(); \ |
| 653 static bool ReadSendParam(const Message* msg, Schema::SendParam* p); \ |
| 654 static bool ReadReplyParam( \ |
| 655 const Message* msg, \ |
| 656 TupleTypes<ReplyParam>::ValueTuple* p); \ |
470 static void Log(std::string* name, const Message* msg, std::string* l); \ | 657 static void Log(std::string* name, const Message* msg, std::string* l); \ |
| 658 IPC_SYNC_MESSAGE_METHODS_##out_cnt \ |
471 }; | 659 }; |
472 | 660 |
473 #define IPC_SYNC_ROUTED_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ | 661 #define IPC_SYNC_ROUTED_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ |
474 class msg_class : \ | 662 class IPC_MESSAGE_EXPORT msg_class : public IPC::SyncMessage { \ |
475 public IPC::MessageWithReply<IPC_TUPLE_IN_##in_cnt in_list, \ | |
476 IPC_TUPLE_OUT_##out_cnt out_list> { \ | |
477 public: \ | 663 public: \ |
| 664 typedef IPC::SyncMessageSchema<IPC_TUPLE_IN_##in_cnt in_list, \ |
| 665 IPC_TUPLE_OUT_##out_cnt out_list> Schema; \ |
| 666 typedef Schema::ReplyParam ReplyParam; \ |
| 667 typedef Schema::SendParam SendParam; \ |
478 enum { ID = IPC_MESSAGE_ID() }; \ | 668 enum { ID = IPC_MESSAGE_ID() }; \ |
479 msg_class(int32 routing_id \ | 669 msg_class(int32 routing_id \ |
480 IPC_COMMA_OR_##in_cnt(IPC_COMMA_##out_cnt) \ | 670 IPC_COMMA_OR_##in_cnt(IPC_COMMA_##out_cnt) \ |
481 IPC_TYPE_IN_##in_cnt in_list \ | 671 IPC_TYPE_IN_##in_cnt in_list \ |
482 IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \ | 672 IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \ |
483 IPC_TYPE_OUT_##out_cnt out_list); \ | 673 IPC_TYPE_OUT_##out_cnt out_list); \ |
484 virtual ~msg_class(); \ | 674 virtual ~msg_class(); \ |
| 675 static bool ReadSendParam(const Message* msg, Schema::SendParam* p); \ |
| 676 static bool ReadReplyParam( \ |
| 677 const Message* msg, \ |
| 678 TupleTypes<ReplyParam>::ValueTuple* p); \ |
485 static void Log(std::string* name, const Message* msg, std::string* l); \ | 679 static void Log(std::string* name, const Message* msg, std::string* l); \ |
| 680 IPC_SYNC_MESSAGE_METHODS_##out_cnt \ |
486 }; | 681 }; |
487 | 682 |
488 #if defined(IPC_MESSAGE_IMPL) | 683 #if defined(IPC_MESSAGE_IMPL) |
489 | 684 |
490 // "Implementation" inclusion produces constructors, destructors, and | 685 // "Implementation" inclusion produces constructors, destructors, and |
491 // logging functions, except for the no-arg special cases, where the | 686 // logging functions, except for the no-arg special cases, where the |
492 // implementation occurs in the declaration, and there is no special | 687 // implementation occurs in the declaration, and there is no special |
493 // logging function. | 688 // logging function. |
494 #define IPC_MESSAGE_EXTRA(sync, kind, msg_class, \ | 689 #define IPC_MESSAGE_EXTRA(sync, kind, msg_class, \ |
495 in_cnt, out_cnt, in_list, out_list) \ | 690 in_cnt, out_cnt, in_list, out_list) \ |
496 IPC_##sync##_##kind##_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \ | 691 IPC_##sync##_##kind##_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \ |
497 IPC_##sync##_MESSAGE_LOG(msg_class) | 692 IPC_##sync##_MESSAGE_LOG(msg_class) |
498 | 693 |
499 #define IPC_EMPTY_CONTROL_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) | 694 #define IPC_EMPTY_CONTROL_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) |
500 #define IPC_EMPTY_ROUTED_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) | 695 #define IPC_EMPTY_ROUTED_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) |
501 | 696 |
502 #define IPC_ASYNC_CONTROL_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \ | 697 #define IPC_ASYNC_CONTROL_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \ |
503 msg_class::msg_class(IPC_TYPE_IN_##in_cnt in_list) : \ | 698 msg_class::msg_class(IPC_TYPE_IN_##in_cnt in_list) : \ |
504 IPC::MessageWithTuple<IPC_TUPLE_IN_##in_cnt in_list> \ | 699 IPC::Message(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL) { \ |
505 (MSG_ROUTING_CONTROL, ID, IPC_NAME_IN_##in_cnt in_list) \ | 700 Schema::Write(this, IPC_NAME_IN_##in_cnt in_list); \ |
506 {} \ | 701 } \ |
507 msg_class::~msg_class() {} | 702 msg_class::~msg_class() {} \ |
| 703 bool msg_class::Read(const Message* msg, Schema::Param* p) { \ |
| 704 return Schema::Read(msg, p); \ |
| 705 } |
508 | 706 |
509 #define IPC_ASYNC_ROUTED_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \ | 707 #define IPC_ASYNC_ROUTED_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \ |
510 msg_class::msg_class(int32 routing_id IPC_COMMA_##in_cnt \ | 708 msg_class::msg_class(int32 routing_id IPC_COMMA_##in_cnt \ |
511 IPC_TYPE_IN_##in_cnt in_list) : \ | 709 IPC_TYPE_IN_##in_cnt in_list) : \ |
512 IPC::MessageWithTuple<IPC_TUPLE_IN_##in_cnt in_list> \ | 710 IPC::Message(routing_id, ID, PRIORITY_NORMAL) { \ |
513 (routing_id, ID, IPC_NAME_IN_##in_cnt in_list) \ | 711 Schema::Write(this, IPC_NAME_IN_##in_cnt in_list); \ |
514 {} \ | 712 } \ |
515 msg_class::~msg_class() {} | 713 msg_class::~msg_class() {} \ |
| 714 bool msg_class::Read(const Message* msg, Schema::Param* p) { \ |
| 715 return Schema::Read(msg, p); \ |
| 716 } |
516 | 717 |
517 #define IPC_SYNC_CONTROL_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \ | 718 #define IPC_SYNC_CONTROL_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \ |
518 msg_class::msg_class(IPC_TYPE_IN_##in_cnt in_list \ | 719 msg_class::msg_class(IPC_TYPE_IN_##in_cnt in_list \ |
519 IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \ | 720 IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \ |
520 IPC_TYPE_OUT_##out_cnt out_list) : \ | 721 IPC_TYPE_OUT_##out_cnt out_list) : \ |
521 IPC::MessageWithReply<IPC_TUPLE_IN_##in_cnt in_list, \ | 722 IPC::SyncMessage(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL, \ |
522 IPC_TUPLE_OUT_##out_cnt out_list> \ | 723 new IPC::ParamDeserializer<Schema::ReplyParam>( \ |
523 (MSG_ROUTING_CONTROL, ID, \ | 724 IPC_NAME_OUT_##out_cnt out_list)) { \ |
524 IPC_NAME_IN_##in_cnt in_list, \ | 725 Schema::Write(this, IPC_NAME_IN_##in_cnt in_list); \ |
525 IPC_NAME_OUT_##out_cnt out_list) \ | 726 } \ |
526 {} \ | 727 msg_class::~msg_class() {} \ |
527 msg_class::~msg_class() {} | 728 bool msg_class::ReadSendParam(const Message* msg, Schema::SendParam* p) { \ |
| 729 return Schema::ReadSendParam(msg, p); \ |
| 730 } \ |
| 731 bool msg_class::ReadReplyParam(const Message* msg, \ |
| 732 TupleTypes<ReplyParam>::ValueTuple* p) { \ |
| 733 return Schema::ReadReplyParam(msg, p); \ |
| 734 } |
528 | 735 |
529 #define IPC_SYNC_ROUTED_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \ | 736 #define IPC_SYNC_ROUTED_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \ |
530 msg_class::msg_class(int32 routing_id \ | 737 msg_class::msg_class(int32 routing_id \ |
531 IPC_COMMA_OR_##in_cnt(IPC_COMMA_##out_cnt) \ | 738 IPC_COMMA_OR_##in_cnt(IPC_COMMA_##out_cnt) \ |
532 IPC_TYPE_IN_##in_cnt in_list \ | 739 IPC_TYPE_IN_##in_cnt in_list \ |
533 IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \ | 740 IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \ |
534 IPC_TYPE_OUT_##out_cnt out_list) : \ | 741 IPC_TYPE_OUT_##out_cnt out_list) : \ |
535 IPC::MessageWithReply<IPC_TUPLE_IN_##in_cnt in_list, \ | 742 IPC::SyncMessage(routing_id, ID, PRIORITY_NORMAL, \ |
536 IPC_TUPLE_OUT_##out_cnt out_list> \ | 743 new IPC::ParamDeserializer<Schema::ReplyParam>( \ |
537 (routing_id, ID, \ | 744 IPC_NAME_OUT_##out_cnt out_list)) { \ |
538 IPC_NAME_IN_##in_cnt in_list, \ | 745 Schema::Write(this, IPC_NAME_IN_##in_cnt in_list); \ |
539 IPC_NAME_OUT_##out_cnt out_list) \ | 746 } \ |
540 {} \ | 747 msg_class::~msg_class() {} \ |
541 msg_class::~msg_class() {} | 748 bool msg_class::ReadSendParam(const Message* msg, Schema::SendParam* p) { \ |
| 749 return Schema::ReadSendParam(msg, p); \ |
| 750 } \ |
| 751 bool msg_class::ReadReplyParam(const Message* msg, \ |
| 752 TupleTypes<ReplyParam>::ValueTuple* p) { \ |
| 753 return Schema::ReadReplyParam(msg, p); \ |
| 754 } |
542 | 755 |
543 #define IPC_EMPTY_MESSAGE_LOG(msg_class) | 756 #define IPC_EMPTY_MESSAGE_LOG(msg_class) |
544 | 757 |
545 #define IPC_ASYNC_MESSAGE_LOG(msg_class) \ | 758 #define IPC_ASYNC_MESSAGE_LOG(msg_class) \ |
546 void msg_class::Log(std::string* name, \ | 759 void msg_class::Log(std::string* name, \ |
547 const Message* msg, \ | 760 const Message* msg, \ |
548 std::string* l) { \ | 761 std::string* l) { \ |
549 if (name) \ | 762 if (name) \ |
550 *name = #msg_class; \ | 763 *name = #msg_class; \ |
551 if (!msg || !l) \ | 764 if (!msg || !l) \ |
552 return; \ | 765 return; \ |
553 Param p; \ | 766 Schema::Param p; \ |
554 if (Read(msg, &p)) \ | 767 if (Schema::Read(msg, &p)) \ |
555 IPC::LogParam(p, l); \ | 768 IPC::LogParam(p, l); \ |
556 } | 769 } |
557 | 770 |
558 #define IPC_SYNC_MESSAGE_LOG(msg_class) \ | 771 #define IPC_SYNC_MESSAGE_LOG(msg_class) \ |
559 void msg_class::Log(std::string* name, \ | 772 void msg_class::Log(std::string* name, \ |
560 const Message* msg, \ | 773 const Message* msg, \ |
561 std::string* l) { \ | 774 std::string* l) { \ |
562 if (name) \ | 775 if (name) \ |
563 *name = #msg_class; \ | 776 *name = #msg_class; \ |
564 if (!msg || !l) \ | 777 if (!msg || !l) \ |
565 return; \ | 778 return; \ |
566 if (msg->is_sync()) { \ | 779 if (msg->is_sync()) { \ |
567 TupleTypes<SendParam>::ValueTuple p; \ | 780 TupleTypes<Schema::SendParam>::ValueTuple p; \ |
568 if (ReadSendParam(msg, &p)) \ | 781 if (Schema::ReadSendParam(msg, &p)) \ |
569 IPC::LogParam(p, l); \ | 782 IPC::LogParam(p, l); \ |
570 AddOutputParamsToLog(msg, l); \ | 783 AddOutputParamsToLog(msg, l); \ |
571 } else { \ | 784 } else { \ |
572 TupleTypes<ReplyParam>::ValueTuple p; \ | 785 TupleTypes<Schema::ReplyParam>::ValueTuple p; \ |
573 if (ReadReplyParam(msg, &p)) \ | 786 if (Schema::ReadReplyParam(msg, &p)) \ |
574 IPC::LogParam(p, l); \ | 787 IPC::LogParam(p, l); \ |
575 } \ | 788 } \ |
576 } | 789 } |
577 | 790 |
578 #elif defined(IPC_MESSAGE_MACROS_LOG_ENABLED) | 791 #elif defined(IPC_MESSAGE_MACROS_LOG_ENABLED) |
579 | 792 |
580 #ifndef IPC_LOG_TABLE_CREATED | 793 #ifndef IPC_LOG_TABLE_CREATED |
581 #define IPC_LOG_TABLE_CREATED | 794 #define IPC_LOG_TABLE_CREATED |
582 | 795 |
583 #include "base/hash_tables.h" | 796 #include "base/hash_tables.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 | 928 |
716 #define IPC_BEGIN_MESSAGE_MAP(class_name, msg) \ | 929 #define IPC_BEGIN_MESSAGE_MAP(class_name, msg) \ |
717 { \ | 930 { \ |
718 typedef class_name _IpcMessageHandlerClass; \ | 931 typedef class_name _IpcMessageHandlerClass; \ |
719 const IPC::Message& ipc_message__ = msg; \ | 932 const IPC::Message& ipc_message__ = msg; \ |
720 bool msg_is_ok__ = true; \ | 933 bool msg_is_ok__ = true; \ |
721 switch (ipc_message__.type()) { \ | 934 switch (ipc_message__.type()) { \ |
722 | 935 |
723 #define IPC_MESSAGE_FORWARD(msg_class, obj, member_func) \ | 936 #define IPC_MESSAGE_FORWARD(msg_class, obj, member_func) \ |
724 case msg_class::ID: \ | 937 case msg_class::ID: \ |
725 msg_is_ok__ = msg_class::Dispatch(&ipc_message__, obj, this, &member_func);
\ | 938 msg_is_ok__ = msg_class::Dispatch(&ipc_message__, obj, this, \ |
| 939 &member_func); \ |
726 break; | 940 break; |
727 | 941 |
728 #define IPC_MESSAGE_HANDLER(msg_class, member_func) \ | 942 #define IPC_MESSAGE_HANDLER(msg_class, member_func) \ |
729 IPC_MESSAGE_FORWARD(msg_class, this, _IpcMessageHandlerClass::member_func) | 943 IPC_MESSAGE_FORWARD(msg_class, this, _IpcMessageHandlerClass::member_func) |
730 | 944 |
731 #define IPC_MESSAGE_FORWARD_DELAY_REPLY(msg_class, obj, member_func) \ | 945 #define IPC_MESSAGE_FORWARD_DELAY_REPLY(msg_class, obj, member_func) \ |
732 case msg_class::ID: \ | 946 case msg_class::ID: \ |
733 msg_is_ok__ = msg_class::DispatchDelayReply(&ipc_message__, obj, &member_fun
c); \ | 947 msg_is_ok__ = msg_class::DispatchDelayReply(&ipc_message__, obj, \ |
| 948 &member_func); \ |
734 break; | 949 break; |
735 | 950 |
736 #define IPC_MESSAGE_HANDLER_DELAY_REPLY(msg_class, member_func) \ | 951 #define IPC_MESSAGE_HANDLER_DELAY_REPLY(msg_class, member_func) \ |
737 IPC_MESSAGE_FORWARD_DELAY_REPLY(msg_class, this, \ | 952 IPC_MESSAGE_FORWARD_DELAY_REPLY(msg_class, this, \ |
738 _IpcMessageHandlerClass::member_func) | 953 _IpcMessageHandlerClass::member_func) |
739 | 954 |
740 #define IPC_MESSAGE_HANDLER_GENERIC(msg_class, code) \ | 955 #define IPC_MESSAGE_HANDLER_GENERIC(msg_class, code) \ |
741 case msg_class::ID: \ | 956 case msg_class::ID: \ |
742 code; \ | 957 code; \ |
743 break; | 958 break; |
(...skipping 26 matching lines...) Expand all Loading... |
770 // This corresponds to an enum value from IPCMessageStart. | 985 // This corresponds to an enum value from IPCMessageStart. |
771 #define IPC_MESSAGE_CLASS(message) \ | 986 #define IPC_MESSAGE_CLASS(message) \ |
772 IPC_MESSAGE_ID_CLASS(message.type()) | 987 IPC_MESSAGE_ID_CLASS(message.type()) |
773 | 988 |
774 #endif // IPC_IPC_MESSAGE_MACROS_H_ | 989 #endif // IPC_IPC_MESSAGE_MACROS_H_ |
775 | 990 |
776 // Clean up IPC_MESSAGE_START in this unguarded section so that the | 991 // Clean up IPC_MESSAGE_START in this unguarded section so that the |
777 // XXX_messages.h files need not do so themselves. This makes the | 992 // XXX_messages.h files need not do so themselves. This makes the |
778 // XXX_messages.h files easier to write. | 993 // XXX_messages.h files easier to write. |
779 #undef IPC_MESSAGE_START | 994 #undef IPC_MESSAGE_START |
OLD | NEW |