| 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // #undef IPC_MESSAGE_EXPORT | 187 // #undef IPC_MESSAGE_EXPORT |
| 188 // #define IPC_MESSAGE_EXPORT VISIBILITY_MACRO | 188 // #define IPC_MESSAGE_EXPORT VISIBILITY_MACRO |
| 189 // after including this header, but before using any of the macros below. | 189 // after including this header, but before using any of the macros below. |
| 190 // (This needs to be before the include guard.) | 190 // (This needs to be before the include guard.) |
| 191 #undef IPC_MESSAGE_EXPORT | 191 #undef IPC_MESSAGE_EXPORT |
| 192 #define IPC_MESSAGE_EXPORT | 192 #define IPC_MESSAGE_EXPORT |
| 193 | 193 |
| 194 #ifndef IPC_IPC_MESSAGE_MACROS_H_ | 194 #ifndef IPC_IPC_MESSAGE_MACROS_H_ |
| 195 #define IPC_IPC_MESSAGE_MACROS_H_ | 195 #define IPC_IPC_MESSAGE_MACROS_H_ |
| 196 | 196 |
| 197 #include <stdint.h> |
| 198 |
| 197 #include "base/profiler/scoped_profile.h" | 199 #include "base/profiler/scoped_profile.h" |
| 198 #include "ipc/ipc_message_utils.h" | 200 #include "ipc/ipc_message_utils.h" |
| 199 #include "ipc/param_traits_macros.h" | 201 #include "ipc/param_traits_macros.h" |
| 200 | 202 |
| 201 #if defined(IPC_MESSAGE_IMPL) | 203 #if defined(IPC_MESSAGE_IMPL) |
| 202 #include "ipc/ipc_message_utils_impl.h" | 204 #include "ipc/ipc_message_utils_impl.h" |
| 203 #endif | 205 #endif |
| 204 | 206 |
| 205 // Convenience macro for defining structs without inheritance. Should not need | 207 // Convenience macro for defining structs without inheritance. Should not need |
| 206 // to be subsequently redefined. | 208 // to be subsequently redefined. |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 enum { ID = IPC_MESSAGE_ID() }; \ | 586 enum { ID = IPC_MESSAGE_ID() }; \ |
| 585 msg_class() : IPC::Message(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL) {} \ | 587 msg_class() : IPC::Message(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL) {} \ |
| 586 static void Log(std::string* name, const Message* msg, std::string* l); \ | 588 static void Log(std::string* name, const Message* msg, std::string* l); \ |
| 587 }; | 589 }; |
| 588 | 590 |
| 589 #define IPC_EMPTY_ROUTED_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ | 591 #define IPC_EMPTY_ROUTED_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ |
| 590 class IPC_MESSAGE_EXPORT msg_class : public IPC::Message { \ | 592 class IPC_MESSAGE_EXPORT msg_class : public IPC::Message { \ |
| 591 public: \ | 593 public: \ |
| 592 typedef IPC::Message Schema; \ | 594 typedef IPC::Message Schema; \ |
| 593 enum { ID = IPC_MESSAGE_ID() }; \ | 595 enum { ID = IPC_MESSAGE_ID() }; \ |
| 594 msg_class(int32 routing_id) \ | 596 msg_class(int32_t routing_id) \ |
| 595 : IPC::Message(routing_id, ID, PRIORITY_NORMAL) {} \ | 597 : IPC::Message(routing_id, ID, PRIORITY_NORMAL) {} \ |
| 596 static void Log(std::string* name, const Message* msg, std::string* l); \ | 598 static void Log(std::string* name, const Message* msg, std::string* l); \ |
| 597 }; | 599 }; |
| 598 | 600 |
| 599 #define IPC_ASYNC_CONTROL_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ | 601 #define IPC_ASYNC_CONTROL_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ |
| 600 class IPC_MESSAGE_EXPORT msg_class : public IPC::Message { \ | 602 class IPC_MESSAGE_EXPORT msg_class : public IPC::Message { \ |
| 601 public: \ | 603 public: \ |
| 602 typedef IPC::MessageSchema<IPC_TUPLE_IN_##in_cnt in_list> Schema; \ | 604 typedef IPC::MessageSchema<IPC_TUPLE_IN_##in_cnt in_list> Schema; \ |
| 603 typedef Schema::Param Param; \ | 605 typedef Schema::Param Param; \ |
| 604 enum { ID = IPC_MESSAGE_ID() }; \ | 606 enum { ID = IPC_MESSAGE_ID() }; \ |
| 605 msg_class(IPC_TYPE_IN_##in_cnt in_list); \ | 607 msg_class(IPC_TYPE_IN_##in_cnt in_list); \ |
| 606 ~msg_class() override; \ | 608 ~msg_class() override; \ |
| 607 static bool Read(const Message* msg, Schema::Param* p); \ | 609 static bool Read(const Message* msg, Schema::Param* p); \ |
| 608 static void Log(std::string* name, const Message* msg, std::string* l); \ | 610 static void Log(std::string* name, const Message* msg, std::string* l); \ |
| 609 IPC_ASYNC_MESSAGE_METHODS_##in_cnt \ | 611 IPC_ASYNC_MESSAGE_METHODS_##in_cnt \ |
| 610 }; | 612 }; |
| 611 | 613 |
| 612 #define IPC_ASYNC_ROUTED_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ | 614 #define IPC_ASYNC_ROUTED_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ |
| 613 class IPC_MESSAGE_EXPORT msg_class : public IPC::Message { \ | 615 class IPC_MESSAGE_EXPORT msg_class : public IPC::Message { \ |
| 614 public: \ | 616 public: \ |
| 615 typedef IPC::MessageSchema<IPC_TUPLE_IN_##in_cnt in_list> Schema; \ | 617 typedef IPC::MessageSchema<IPC_TUPLE_IN_##in_cnt in_list> Schema; \ |
| 616 typedef Schema::Param Param; \ | 618 typedef Schema::Param Param; \ |
| 617 enum { ID = IPC_MESSAGE_ID() }; \ | 619 enum { ID = IPC_MESSAGE_ID() }; \ |
| 618 msg_class(int32 routing_id IPC_COMMA_##in_cnt \ | 620 msg_class(int32_t routing_id IPC_COMMA_##in_cnt \ |
| 619 IPC_TYPE_IN_##in_cnt in_list); \ | 621 IPC_TYPE_IN_##in_cnt in_list); \ |
| 620 ~msg_class() override; \ | 622 ~msg_class() override; \ |
| 621 static bool Read(const Message* msg, Schema::Param* p); \ | 623 static bool Read(const Message* msg, Schema::Param* p); \ |
| 622 static void Log(std::string* name, const Message* msg, std::string* l); \ | 624 static void Log(std::string* name, const Message* msg, std::string* l); \ |
| 623 IPC_ASYNC_MESSAGE_METHODS_##in_cnt \ | 625 IPC_ASYNC_MESSAGE_METHODS_##in_cnt \ |
| 624 }; | 626 }; |
| 625 | 627 |
| 626 #define IPC_SYNC_CONTROL_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ | 628 #define IPC_SYNC_CONTROL_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ |
| 627 class IPC_MESSAGE_EXPORT msg_class : public IPC::SyncMessage { \ | 629 class IPC_MESSAGE_EXPORT msg_class : public IPC::SyncMessage { \ |
| 628 public: \ | 630 public: \ |
| (...skipping 15 matching lines...) Expand all Loading... |
| 644 }; | 646 }; |
| 645 | 647 |
| 646 #define IPC_SYNC_ROUTED_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ | 648 #define IPC_SYNC_ROUTED_DECL(msg_class, in_cnt, out_cnt, in_list, out_list) \ |
| 647 class IPC_MESSAGE_EXPORT msg_class : public IPC::SyncMessage { \ | 649 class IPC_MESSAGE_EXPORT msg_class : public IPC::SyncMessage { \ |
| 648 public: \ | 650 public: \ |
| 649 typedef IPC::SyncMessageSchema<IPC_TUPLE_IN_##in_cnt in_list, \ | 651 typedef IPC::SyncMessageSchema<IPC_TUPLE_IN_##in_cnt in_list, \ |
| 650 IPC_TUPLE_OUT_##out_cnt out_list> Schema; \ | 652 IPC_TUPLE_OUT_##out_cnt out_list> Schema; \ |
| 651 typedef Schema::ReplyParam ReplyParam; \ | 653 typedef Schema::ReplyParam ReplyParam; \ |
| 652 typedef Schema::SendParam SendParam; \ | 654 typedef Schema::SendParam SendParam; \ |
| 653 enum { ID = IPC_MESSAGE_ID() }; \ | 655 enum { ID = IPC_MESSAGE_ID() }; \ |
| 654 msg_class(int32 routing_id \ | 656 msg_class(int32_t routing_id \ |
| 655 IPC_COMMA_OR_##in_cnt(IPC_COMMA_##out_cnt) \ | 657 IPC_COMMA_OR_##in_cnt(IPC_COMMA_##out_cnt) \ |
| 656 IPC_TYPE_IN_##in_cnt in_list \ | 658 IPC_TYPE_IN_##in_cnt in_list \ |
| 657 IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \ | 659 IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \ |
| 658 IPC_TYPE_OUT_##out_cnt out_list); \ | 660 IPC_TYPE_OUT_##out_cnt out_list); \ |
| 659 ~msg_class() override; \ | 661 ~msg_class() override; \ |
| 660 static bool ReadSendParam(const Message* msg, Schema::SendParam* p); \ | 662 static bool ReadSendParam(const Message* msg, Schema::SendParam* p); \ |
| 661 static bool ReadReplyParam( \ | 663 static bool ReadReplyParam( \ |
| 662 const Message* msg, \ | 664 const Message* msg, \ |
| 663 base::TupleTypes<ReplyParam>::ValueTuple* p); \ | 665 base::TupleTypes<ReplyParam>::ValueTuple* p); \ |
| 664 static void Log(std::string* name, const Message* msg, std::string* l); \ | 666 static void Log(std::string* name, const Message* msg, std::string* l); \ |
| (...skipping 18 matching lines...) Expand all Loading... |
| 683 msg_class::msg_class(IPC_TYPE_IN_##in_cnt in_list) : \ | 685 msg_class::msg_class(IPC_TYPE_IN_##in_cnt in_list) : \ |
| 684 IPC::Message(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL) { \ | 686 IPC::Message(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL) { \ |
| 685 Schema::Write(this, IPC_NAME_IN_##in_cnt in_list); \ | 687 Schema::Write(this, IPC_NAME_IN_##in_cnt in_list); \ |
| 686 } \ | 688 } \ |
| 687 msg_class::~msg_class() {} \ | 689 msg_class::~msg_class() {} \ |
| 688 bool msg_class::Read(const Message* msg, Schema::Param* p) { \ | 690 bool msg_class::Read(const Message* msg, Schema::Param* p) { \ |
| 689 return Schema::Read(msg, p); \ | 691 return Schema::Read(msg, p); \ |
| 690 } | 692 } |
| 691 | 693 |
| 692 #define IPC_ASYNC_ROUTED_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \ | 694 #define IPC_ASYNC_ROUTED_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \ |
| 693 msg_class::msg_class(int32 routing_id IPC_COMMA_##in_cnt \ | 695 msg_class::msg_class(int32_t routing_id IPC_COMMA_##in_cnt \ |
| 694 IPC_TYPE_IN_##in_cnt in_list) : \ | 696 IPC_TYPE_IN_##in_cnt in_list) : \ |
| 695 IPC::Message(routing_id, ID, PRIORITY_NORMAL) { \ | 697 IPC::Message(routing_id, ID, PRIORITY_NORMAL) { \ |
| 696 Schema::Write(this, IPC_NAME_IN_##in_cnt in_list); \ | 698 Schema::Write(this, IPC_NAME_IN_##in_cnt in_list); \ |
| 697 } \ | 699 } \ |
| 698 msg_class::~msg_class() {} \ | 700 msg_class::~msg_class() {} \ |
| 699 bool msg_class::Read(const Message* msg, Schema::Param* p) { \ | 701 bool msg_class::Read(const Message* msg, Schema::Param* p) { \ |
| 700 return Schema::Read(msg, p); \ | 702 return Schema::Read(msg, p); \ |
| 701 } | 703 } |
| 702 | 704 |
| 703 #define IPC_SYNC_CONTROL_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \ | 705 #define IPC_SYNC_CONTROL_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \ |
| 704 msg_class::msg_class(IPC_TYPE_IN_##in_cnt in_list \ | 706 msg_class::msg_class(IPC_TYPE_IN_##in_cnt in_list \ |
| 705 IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \ | 707 IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \ |
| 706 IPC_TYPE_OUT_##out_cnt out_list) : \ | 708 IPC_TYPE_OUT_##out_cnt out_list) : \ |
| 707 IPC::SyncMessage(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL, \ | 709 IPC::SyncMessage(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL, \ |
| 708 new IPC::ParamDeserializer<Schema::ReplyParam>( \ | 710 new IPC::ParamDeserializer<Schema::ReplyParam>( \ |
| 709 IPC_NAME_OUT_##out_cnt out_list)) { \ | 711 IPC_NAME_OUT_##out_cnt out_list)) { \ |
| 710 Schema::Write(this, IPC_NAME_IN_##in_cnt in_list); \ | 712 Schema::Write(this, IPC_NAME_IN_##in_cnt in_list); \ |
| 711 } \ | 713 } \ |
| 712 msg_class::~msg_class() {} \ | 714 msg_class::~msg_class() {} \ |
| 713 bool msg_class::ReadSendParam(const Message* msg, Schema::SendParam* p) { \ | 715 bool msg_class::ReadSendParam(const Message* msg, Schema::SendParam* p) { \ |
| 714 return Schema::ReadSendParam(msg, p); \ | 716 return Schema::ReadSendParam(msg, p); \ |
| 715 } \ | 717 } \ |
| 716 bool msg_class::ReadReplyParam( \ | 718 bool msg_class::ReadReplyParam( \ |
| 717 const Message* msg, \ | 719 const Message* msg, \ |
| 718 base::TupleTypes<ReplyParam>::ValueTuple* p) { \ | 720 base::TupleTypes<ReplyParam>::ValueTuple* p) { \ |
| 719 return Schema::ReadReplyParam(msg, p); \ | 721 return Schema::ReadReplyParam(msg, p); \ |
| 720 } | 722 } |
| 721 | 723 |
| 722 #define IPC_SYNC_ROUTED_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \ | 724 #define IPC_SYNC_ROUTED_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \ |
| 723 msg_class::msg_class(int32 routing_id \ | 725 msg_class::msg_class(int32_t routing_id \ |
| 724 IPC_COMMA_OR_##in_cnt(IPC_COMMA_##out_cnt) \ | 726 IPC_COMMA_OR_##in_cnt(IPC_COMMA_##out_cnt) \ |
| 725 IPC_TYPE_IN_##in_cnt in_list \ | 727 IPC_TYPE_IN_##in_cnt in_list \ |
| 726 IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \ | 728 IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \ |
| 727 IPC_TYPE_OUT_##out_cnt out_list) : \ | 729 IPC_TYPE_OUT_##out_cnt out_list) : \ |
| 728 IPC::SyncMessage(routing_id, ID, PRIORITY_NORMAL, \ | 730 IPC::SyncMessage(routing_id, ID, PRIORITY_NORMAL, \ |
| 729 new IPC::ParamDeserializer<Schema::ReplyParam>( \ | 731 new IPC::ParamDeserializer<Schema::ReplyParam>( \ |
| 730 IPC_NAME_OUT_##out_cnt out_list)) { \ | 732 IPC_NAME_OUT_##out_cnt out_list)) { \ |
| 731 Schema::Write(this, IPC_NAME_IN_##in_cnt in_list); \ | 733 Schema::Write(this, IPC_NAME_IN_##in_cnt in_list); \ |
| 732 } \ | 734 } \ |
| 733 msg_class::~msg_class() {} \ | 735 msg_class::~msg_class() {} \ |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 #ifndef IPC_LOG_TABLE_ADD_ENTRY | 788 #ifndef IPC_LOG_TABLE_ADD_ENTRY |
| 787 #error You need to define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) | 789 #error You need to define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) |
| 788 #endif | 790 #endif |
| 789 | 791 |
| 790 // "Log table" inclusion produces extra logging registration code. | 792 // "Log table" inclusion produces extra logging registration code. |
| 791 #define IPC_MESSAGE_EXTRA(sync, kind, msg_class, \ | 793 #define IPC_MESSAGE_EXTRA(sync, kind, msg_class, \ |
| 792 in_cnt, out_cnt, in_list, out_list) \ | 794 in_cnt, out_cnt, in_list, out_list) \ |
| 793 class LoggerRegisterHelper##msg_class { \ | 795 class LoggerRegisterHelper##msg_class { \ |
| 794 public: \ | 796 public: \ |
| 795 LoggerRegisterHelper##msg_class() { \ | 797 LoggerRegisterHelper##msg_class() { \ |
| 796 const uint32 msg_id = static_cast<uint32>(msg_class::ID); \ | 798 const uint32_t msg_id = static_cast<uint32_t>(msg_class::ID); \ |
| 797 IPC_LOG_TABLE_ADD_ENTRY(msg_id, msg_class::Log); \ | 799 IPC_LOG_TABLE_ADD_ENTRY(msg_id, msg_class::Log); \ |
| 798 } \ | 800 } \ |
| 799 }; \ | 801 }; \ |
| 800 LoggerRegisterHelper##msg_class g_LoggerRegisterHelper##msg_class; | 802 LoggerRegisterHelper##msg_class g_LoggerRegisterHelper##msg_class; |
| 801 | 803 |
| 802 #else | 804 #else |
| 803 | 805 |
| 804 // Normal inclusion produces nothing extra. | 806 // Normal inclusion produces nothing extra. |
| 805 #define IPC_MESSAGE_EXTRA(sync, kind, msg_class, \ | 807 #define IPC_MESSAGE_EXTRA(sync, kind, msg_class, \ |
| 806 in_cnt, out_cnt, in_list, out_list) | 808 in_cnt, out_cnt, in_list, out_list) |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 // This corresponds to an enum value from IPCMessageStart. | 975 // This corresponds to an enum value from IPCMessageStart. |
| 974 #define IPC_MESSAGE_CLASS(message) \ | 976 #define IPC_MESSAGE_CLASS(message) \ |
| 975 IPC_MESSAGE_ID_CLASS(message.type()) | 977 IPC_MESSAGE_ID_CLASS(message.type()) |
| 976 | 978 |
| 977 #endif // IPC_IPC_MESSAGE_MACROS_H_ | 979 #endif // IPC_IPC_MESSAGE_MACROS_H_ |
| 978 | 980 |
| 979 // Clean up IPC_MESSAGE_START in this unguarded section so that the | 981 // Clean up IPC_MESSAGE_START in this unguarded section so that the |
| 980 // XXX_messages.h files need not do so themselves. This makes the | 982 // XXX_messages.h files need not do so themselves. This makes the |
| 981 // XXX_messages.h files easier to write. | 983 // XXX_messages.h files easier to write. |
| 982 #undef IPC_MESSAGE_START | 984 #undef IPC_MESSAGE_START |
| OLD | NEW |