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 #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 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 static void Log(const param_type& p, std::string* l); | 679 static void Log(const param_type& p, std::string* l); |
680 }; | 680 }; |
681 | 681 |
682 template <> | 682 template <> |
683 struct IPC_EXPORT ParamTraits<Message> { | 683 struct IPC_EXPORT ParamTraits<Message> { |
684 static void Write(Message* m, const Message& p); | 684 static void Write(Message* m, const Message& p); |
685 static bool Read(const Message* m, PickleIterator* iter, Message* r); | 685 static bool Read(const Message* m, PickleIterator* iter, Message* r); |
686 static void Log(const Message& p, std::string* l); | 686 static void Log(const Message& p, std::string* l); |
687 }; | 687 }; |
688 | 688 |
| 689 // Wayland ParamTraits --------------------------------------------------------- |
| 690 |
| 691 #if defined(USE_WAYLAND) |
| 692 template <> |
| 693 struct IPC_EXPORT ParamTraits<ui::WaylandWindow*> { |
| 694 typedef ui::WaylandWindow* param_type; |
| 695 static void Write(Message* m, const param_type& p) { |
| 696 m->WriteData(reinterpret_cast<const char*>(&p), sizeof(ui::WaylandWindow*)); |
| 697 } |
| 698 static bool Read(const Message* m, PickleIterator* iter, param_type* r) { |
| 699 const char *data; |
| 700 int data_size = 0; |
| 701 bool result = m->ReadData(iter, &data, &data_size); |
| 702 if (result && data_size == sizeof(ui::WaylandWindow*)) { |
| 703 memcpy(r, data, sizeof(ui::WaylandWindow*)); |
| 704 } else { |
| 705 result = false; |
| 706 NOTREACHED(); |
| 707 } |
| 708 |
| 709 return result; |
| 710 } |
| 711 static void Log(const param_type& p, std::string* l) { |
| 712 l->append("<ui::WaylandWindow*>"); |
| 713 } |
| 714 }; |
| 715 #endif |
| 716 |
689 // Windows ParamTraits --------------------------------------------------------- | 717 // Windows ParamTraits --------------------------------------------------------- |
690 | 718 |
691 #if defined(OS_WIN) | 719 #if defined(OS_WIN) |
692 template <> | 720 template <> |
693 struct IPC_EXPORT ParamTraits<HANDLE> { | 721 struct IPC_EXPORT ParamTraits<HANDLE> { |
694 typedef HANDLE param_type; | 722 typedef HANDLE param_type; |
695 static void Write(Message* m, const param_type& p); | 723 static void Write(Message* m, const param_type& p); |
696 static bool Read(const Message* m, PickleIterator* iter, param_type* r); | 724 static bool Read(const Message* m, PickleIterator* iter, param_type* r); |
697 static void Log(const param_type& p, std::string* l); | 725 static void Log(const param_type& p, std::string* l); |
698 }; | 726 }; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 template<typename TA, typename TB, typename TC, typename TD, typename TE> | 894 template<typename TA, typename TB, typename TC, typename TD, typename TE> |
867 static void WriteReplyParams(Message* reply, TA a, TB b, TC c, TD d, TE e) { | 895 static void WriteReplyParams(Message* reply, TA a, TB b, TC c, TD d, TE e) { |
868 ReplyParam p(a, b, c, d, e); | 896 ReplyParam p(a, b, c, d, e); |
869 WriteParam(reply, p); | 897 WriteParam(reply, p); |
870 } | 898 } |
871 }; | 899 }; |
872 | 900 |
873 } // namespace IPC | 901 } // namespace IPC |
874 | 902 |
875 #endif // IPC_IPC_MESSAGE_UTILS_H_ | 903 #endif // IPC_IPC_MESSAGE_UTILS_H_ |
OLD | NEW |