| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef IPC_IPC_MESSAGE_UTILS_H_ | 5 #ifndef IPC_IPC_MESSAGE_UTILS_H_ |
| 6 #define IPC_IPC_MESSAGE_UTILS_H_ | 6 #define IPC_IPC_MESSAGE_UTILS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 | 723 |
| 724 return result; | 724 return result; |
| 725 } | 725 } |
| 726 static void Log(const param_type& p, std::string* l) { | 726 static void Log(const param_type& p, std::string* l) { |
| 727 l->append("<XFORM>"); | 727 l->append("<XFORM>"); |
| 728 } | 728 } |
| 729 }; | 729 }; |
| 730 #endif // defined(OS_WIN) | 730 #endif // defined(OS_WIN) |
| 731 | 731 |
| 732 struct LogData { | 732 struct LogData { |
| 733 LogData(); |
| 734 ~LogData(); |
| 735 |
| 733 std::string channel; | 736 std::string channel; |
| 734 int32 routing_id; | 737 int32 routing_id; |
| 735 uint32 type; // "User-defined" message type, from ipc_message.h. | 738 uint32 type; // "User-defined" message type, from ipc_message.h. |
| 736 std::string flags; | 739 std::string flags; |
| 737 int64 sent; // Time that the message was sent (i.e. at Send()). | 740 int64 sent; // Time that the message was sent (i.e. at Send()). |
| 738 int64 receive; // Time before it was dispatched (i.e. before calling | 741 int64 receive; // Time before it was dispatched (i.e. before calling |
| 739 // OnMessageReceived). | 742 // OnMessageReceived). |
| 740 int64 dispatch; // Time after it was dispatched (i.e. after calling | 743 int64 dispatch; // Time after it was dispatched (i.e. after calling |
| 741 // OnMessageReceived). | 744 // OnMessageReceived). |
| 742 std::string message_name; | 745 std::string message_name; |
| 743 std::string params; | 746 std::string params; |
| 744 }; | 747 }; |
| 745 | 748 |
| 746 template <> | 749 template <> |
| 747 struct ParamTraits<LogData> { | 750 struct ParamTraits<LogData> { |
| 748 typedef LogData param_type; | 751 typedef LogData param_type; |
| 749 static void Write(Message* m, const param_type& p) { | 752 static void Write(Message* m, const param_type& p); |
| 750 WriteParam(m, p.channel); | 753 static bool Read(const Message* m, void** iter, param_type* r); |
| 751 WriteParam(m, p.routing_id); | |
| 752 WriteParam(m, static_cast<int>(p.type)); | |
| 753 WriteParam(m, p.flags); | |
| 754 WriteParam(m, p.sent); | |
| 755 WriteParam(m, p.receive); | |
| 756 WriteParam(m, p.dispatch); | |
| 757 WriteParam(m, p.params); | |
| 758 } | |
| 759 static bool Read(const Message* m, void** iter, param_type* r) { | |
| 760 int type; | |
| 761 bool result = | |
| 762 ReadParam(m, iter, &r->channel) && | |
| 763 ReadParam(m, iter, &r->routing_id) && | |
| 764 ReadParam(m, iter, &type) && | |
| 765 ReadParam(m, iter, &r->flags) && | |
| 766 ReadParam(m, iter, &r->sent) && | |
| 767 ReadParam(m, iter, &r->receive) && | |
| 768 ReadParam(m, iter, &r->dispatch) && | |
| 769 ReadParam(m, iter, &r->params); | |
| 770 r->type = static_cast<uint16>(type); | |
| 771 return result; | |
| 772 } | |
| 773 static void Log(const param_type& p, std::string* l) { | 754 static void Log(const param_type& p, std::string* l) { |
| 774 // Doesn't make sense to implement this! | 755 // Doesn't make sense to implement this! |
| 775 } | 756 } |
| 776 }; | 757 }; |
| 777 | 758 |
| 778 template <> | 759 template <> |
| 779 struct ParamTraits<Message> { | 760 struct ParamTraits<Message> { |
| 780 static void Write(Message* m, const Message& p) { | 761 static void Write(Message* m, const Message& p) { |
| 781 m->WriteInt(p.size()); | 762 m->WriteInt(p.size()); |
| 782 m->WriteData(reinterpret_cast<const char*>(p.data()), p.size()); | 763 m->WriteData(reinterpret_cast<const char*>(p.data()), p.size()); |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1199 ReplyParam p(a, b, c, d, e); | 1180 ReplyParam p(a, b, c, d, e); |
| 1200 WriteParam(reply, p); | 1181 WriteParam(reply, p); |
| 1201 } | 1182 } |
| 1202 }; | 1183 }; |
| 1203 | 1184 |
| 1204 //----------------------------------------------------------------------------- | 1185 //----------------------------------------------------------------------------- |
| 1205 | 1186 |
| 1206 } // namespace IPC | 1187 } // namespace IPC |
| 1207 | 1188 |
| 1208 #endif // IPC_IPC_MESSAGE_UTILS_H_ | 1189 #endif // IPC_IPC_MESSAGE_UTILS_H_ |
| OLD | NEW |