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 <limits.h> | 8 #include <limits.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
11 | 11 |
12 #include <algorithm> | 12 #include <algorithm> |
13 #include <map> | 13 #include <map> |
14 #include <set> | 14 #include <set> |
15 #include <string> | 15 #include <string> |
16 #include <vector> | 16 #include <vector> |
Tom Sepez
2016/03/07 19:05:02
ditto
tzik
2016/03/08 03:32:59
Done.
| |
17 | 17 |
18 #include "base/containers/small_map.h" | 18 #include "base/containers/small_map.h" |
19 #include "base/containers/stack_container.h" | 19 #include "base/containers/stack_container.h" |
20 #include "base/files/file.h" | 20 #include "base/files/file.h" |
21 #include "base/format_macros.h" | 21 #include "base/format_macros.h" |
22 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
23 #include "base/memory/scoped_vector.h" | 23 #include "base/memory/scoped_vector.h" |
24 #include "base/strings/string16.h" | 24 #include "base/strings/string16.h" |
25 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
26 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
659 return true; | 659 return true; |
660 } | 660 } |
661 static void Log(const param_type& p, std::string* l) { | 661 static void Log(const param_type& p, std::string* l) { |
662 } | 662 } |
663 }; | 663 }; |
664 | 664 |
665 template <class A> | 665 template <class A> |
666 struct ParamTraits<std::tuple<A>> { | 666 struct ParamTraits<std::tuple<A>> { |
667 typedef std::tuple<A> param_type; | 667 typedef std::tuple<A> param_type; |
668 static void GetSize(base::PickleSizer* sizer, const param_type& p) { | 668 static void GetSize(base::PickleSizer* sizer, const param_type& p) { |
669 GetParamSize(sizer, base::get<0>(p)); | 669 GetParamSize(sizer, std::get<0>(p)); |
670 } | 670 } |
671 static void Write(base::Pickle* m, const param_type& p) { | 671 static void Write(base::Pickle* m, const param_type& p) { |
672 WriteParam(m, base::get<0>(p)); | 672 WriteParam(m, std::get<0>(p)); |
673 } | 673 } |
674 static bool Read(const base::Pickle* m, | 674 static bool Read(const base::Pickle* m, |
675 base::PickleIterator* iter, | 675 base::PickleIterator* iter, |
676 param_type* r) { | 676 param_type* r) { |
677 return ReadParam(m, iter, &base::get<0>(*r)); | 677 return ReadParam(m, iter, &std::get<0>(*r)); |
678 } | 678 } |
679 static void Log(const param_type& p, std::string* l) { | 679 static void Log(const param_type& p, std::string* l) { |
680 LogParam(base::get<0>(p), l); | 680 LogParam(std::get<0>(p), l); |
681 } | 681 } |
682 }; | 682 }; |
683 | 683 |
684 template <class A, class B> | 684 template <class A, class B> |
685 struct ParamTraits<std::tuple<A, B>> { | 685 struct ParamTraits<std::tuple<A, B>> { |
686 typedef std::tuple<A, B> param_type; | 686 typedef std::tuple<A, B> param_type; |
687 static void GetSize(base::PickleSizer* sizer, const param_type& p) { | 687 static void GetSize(base::PickleSizer* sizer, const param_type& p) { |
688 GetParamSize(sizer, base::get<0>(p)); | 688 GetParamSize(sizer, std::get<0>(p)); |
689 GetParamSize(sizer, base::get<1>(p)); | 689 GetParamSize(sizer, std::get<1>(p)); |
690 } | 690 } |
691 static void Write(base::Pickle* m, const param_type& p) { | 691 static void Write(base::Pickle* m, const param_type& p) { |
692 WriteParam(m, base::get<0>(p)); | 692 WriteParam(m, std::get<0>(p)); |
693 WriteParam(m, base::get<1>(p)); | 693 WriteParam(m, std::get<1>(p)); |
694 } | 694 } |
695 static bool Read(const base::Pickle* m, | 695 static bool Read(const base::Pickle* m, |
696 base::PickleIterator* iter, | 696 base::PickleIterator* iter, |
697 param_type* r) { | 697 param_type* r) { |
698 return (ReadParam(m, iter, &base::get<0>(*r)) && | 698 return (ReadParam(m, iter, &std::get<0>(*r)) && |
699 ReadParam(m, iter, &base::get<1>(*r))); | 699 ReadParam(m, iter, &std::get<1>(*r))); |
700 } | 700 } |
701 static void Log(const param_type& p, std::string* l) { | 701 static void Log(const param_type& p, std::string* l) { |
702 LogParam(base::get<0>(p), l); | 702 LogParam(std::get<0>(p), l); |
703 l->append(", "); | 703 l->append(", "); |
704 LogParam(base::get<1>(p), l); | 704 LogParam(std::get<1>(p), l); |
705 } | 705 } |
706 }; | 706 }; |
707 | 707 |
708 template <class A, class B, class C> | 708 template <class A, class B, class C> |
709 struct ParamTraits<std::tuple<A, B, C>> { | 709 struct ParamTraits<std::tuple<A, B, C>> { |
710 typedef std::tuple<A, B, C> param_type; | 710 typedef std::tuple<A, B, C> param_type; |
711 static void GetSize(base::PickleSizer* sizer, const param_type& p) { | 711 static void GetSize(base::PickleSizer* sizer, const param_type& p) { |
712 GetParamSize(sizer, base::get<0>(p)); | 712 GetParamSize(sizer, std::get<0>(p)); |
713 GetParamSize(sizer, base::get<1>(p)); | 713 GetParamSize(sizer, std::get<1>(p)); |
714 GetParamSize(sizer, base::get<2>(p)); | 714 GetParamSize(sizer, std::get<2>(p)); |
715 } | 715 } |
716 static void Write(base::Pickle* m, const param_type& p) { | 716 static void Write(base::Pickle* m, const param_type& p) { |
717 WriteParam(m, base::get<0>(p)); | 717 WriteParam(m, std::get<0>(p)); |
718 WriteParam(m, base::get<1>(p)); | 718 WriteParam(m, std::get<1>(p)); |
719 WriteParam(m, base::get<2>(p)); | 719 WriteParam(m, std::get<2>(p)); |
720 } | 720 } |
721 static bool Read(const base::Pickle* m, | 721 static bool Read(const base::Pickle* m, |
722 base::PickleIterator* iter, | 722 base::PickleIterator* iter, |
723 param_type* r) { | 723 param_type* r) { |
724 return (ReadParam(m, iter, &base::get<0>(*r)) && | 724 return (ReadParam(m, iter, &std::get<0>(*r)) && |
725 ReadParam(m, iter, &base::get<1>(*r)) && | 725 ReadParam(m, iter, &std::get<1>(*r)) && |
726 ReadParam(m, iter, &base::get<2>(*r))); | 726 ReadParam(m, iter, &std::get<2>(*r))); |
727 } | 727 } |
728 static void Log(const param_type& p, std::string* l) { | 728 static void Log(const param_type& p, std::string* l) { |
729 LogParam(base::get<0>(p), l); | 729 LogParam(std::get<0>(p), l); |
730 l->append(", "); | 730 l->append(", "); |
731 LogParam(base::get<1>(p), l); | 731 LogParam(std::get<1>(p), l); |
732 l->append(", "); | 732 l->append(", "); |
733 LogParam(base::get<2>(p), l); | 733 LogParam(std::get<2>(p), l); |
734 } | 734 } |
735 }; | 735 }; |
736 | 736 |
737 template <class A, class B, class C, class D> | 737 template <class A, class B, class C, class D> |
738 struct ParamTraits<std::tuple<A, B, C, D>> { | 738 struct ParamTraits<std::tuple<A, B, C, D>> { |
739 typedef std::tuple<A, B, C, D> param_type; | 739 typedef std::tuple<A, B, C, D> param_type; |
740 static void GetSize(base::PickleSizer* sizer, const param_type& p) { | 740 static void GetSize(base::PickleSizer* sizer, const param_type& p) { |
741 GetParamSize(sizer, base::get<0>(p)); | 741 GetParamSize(sizer, std::get<0>(p)); |
742 GetParamSize(sizer, base::get<1>(p)); | 742 GetParamSize(sizer, std::get<1>(p)); |
743 GetParamSize(sizer, base::get<2>(p)); | 743 GetParamSize(sizer, std::get<2>(p)); |
744 GetParamSize(sizer, base::get<3>(p)); | 744 GetParamSize(sizer, std::get<3>(p)); |
745 } | 745 } |
746 static void Write(base::Pickle* m, const param_type& p) { | 746 static void Write(base::Pickle* m, const param_type& p) { |
747 WriteParam(m, base::get<0>(p)); | 747 WriteParam(m, std::get<0>(p)); |
748 WriteParam(m, base::get<1>(p)); | 748 WriteParam(m, std::get<1>(p)); |
749 WriteParam(m, base::get<2>(p)); | 749 WriteParam(m, std::get<2>(p)); |
750 WriteParam(m, base::get<3>(p)); | 750 WriteParam(m, std::get<3>(p)); |
751 } | 751 } |
752 static bool Read(const base::Pickle* m, | 752 static bool Read(const base::Pickle* m, |
753 base::PickleIterator* iter, | 753 base::PickleIterator* iter, |
754 param_type* r) { | 754 param_type* r) { |
755 return (ReadParam(m, iter, &base::get<0>(*r)) && | 755 return (ReadParam(m, iter, &std::get<0>(*r)) && |
756 ReadParam(m, iter, &base::get<1>(*r)) && | 756 ReadParam(m, iter, &std::get<1>(*r)) && |
757 ReadParam(m, iter, &base::get<2>(*r)) && | 757 ReadParam(m, iter, &std::get<2>(*r)) && |
758 ReadParam(m, iter, &base::get<3>(*r))); | 758 ReadParam(m, iter, &std::get<3>(*r))); |
759 } | 759 } |
760 static void Log(const param_type& p, std::string* l) { | 760 static void Log(const param_type& p, std::string* l) { |
761 LogParam(base::get<0>(p), l); | 761 LogParam(std::get<0>(p), l); |
762 l->append(", "); | 762 l->append(", "); |
763 LogParam(base::get<1>(p), l); | 763 LogParam(std::get<1>(p), l); |
764 l->append(", "); | 764 l->append(", "); |
765 LogParam(base::get<2>(p), l); | 765 LogParam(std::get<2>(p), l); |
766 l->append(", "); | 766 l->append(", "); |
767 LogParam(base::get<3>(p), l); | 767 LogParam(std::get<3>(p), l); |
768 } | 768 } |
769 }; | 769 }; |
770 | 770 |
771 template <class A, class B, class C, class D, class E> | 771 template <class A, class B, class C, class D, class E> |
772 struct ParamTraits<std::tuple<A, B, C, D, E>> { | 772 struct ParamTraits<std::tuple<A, B, C, D, E>> { |
773 typedef std::tuple<A, B, C, D, E> param_type; | 773 typedef std::tuple<A, B, C, D, E> param_type; |
774 static void GetSize(base::PickleSizer* sizer, const param_type& p) { | 774 static void GetSize(base::PickleSizer* sizer, const param_type& p) { |
775 GetParamSize(sizer, base::get<0>(p)); | 775 GetParamSize(sizer, std::get<0>(p)); |
776 GetParamSize(sizer, base::get<1>(p)); | 776 GetParamSize(sizer, std::get<1>(p)); |
777 GetParamSize(sizer, base::get<2>(p)); | 777 GetParamSize(sizer, std::get<2>(p)); |
778 GetParamSize(sizer, base::get<3>(p)); | 778 GetParamSize(sizer, std::get<3>(p)); |
779 GetParamSize(sizer, base::get<4>(p)); | 779 GetParamSize(sizer, std::get<4>(p)); |
780 } | 780 } |
781 static void Write(base::Pickle* m, const param_type& p) { | 781 static void Write(base::Pickle* m, const param_type& p) { |
782 WriteParam(m, base::get<0>(p)); | 782 WriteParam(m, std::get<0>(p)); |
783 WriteParam(m, base::get<1>(p)); | 783 WriteParam(m, std::get<1>(p)); |
784 WriteParam(m, base::get<2>(p)); | 784 WriteParam(m, std::get<2>(p)); |
785 WriteParam(m, base::get<3>(p)); | 785 WriteParam(m, std::get<3>(p)); |
786 WriteParam(m, base::get<4>(p)); | 786 WriteParam(m, std::get<4>(p)); |
787 } | 787 } |
788 static bool Read(const base::Pickle* m, | 788 static bool Read(const base::Pickle* m, |
789 base::PickleIterator* iter, | 789 base::PickleIterator* iter, |
790 param_type* r) { | 790 param_type* r) { |
791 return (ReadParam(m, iter, &base::get<0>(*r)) && | 791 return (ReadParam(m, iter, &std::get<0>(*r)) && |
792 ReadParam(m, iter, &base::get<1>(*r)) && | 792 ReadParam(m, iter, &std::get<1>(*r)) && |
793 ReadParam(m, iter, &base::get<2>(*r)) && | 793 ReadParam(m, iter, &std::get<2>(*r)) && |
794 ReadParam(m, iter, &base::get<3>(*r)) && | 794 ReadParam(m, iter, &std::get<3>(*r)) && |
795 ReadParam(m, iter, &base::get<4>(*r))); | 795 ReadParam(m, iter, &std::get<4>(*r))); |
796 } | 796 } |
797 static void Log(const param_type& p, std::string* l) { | 797 static void Log(const param_type& p, std::string* l) { |
798 LogParam(base::get<0>(p), l); | 798 LogParam(std::get<0>(p), l); |
799 l->append(", "); | 799 l->append(", "); |
800 LogParam(base::get<1>(p), l); | 800 LogParam(std::get<1>(p), l); |
801 l->append(", "); | 801 l->append(", "); |
802 LogParam(base::get<2>(p), l); | 802 LogParam(std::get<2>(p), l); |
803 l->append(", "); | 803 l->append(", "); |
804 LogParam(base::get<3>(p), l); | 804 LogParam(std::get<3>(p), l); |
805 l->append(", "); | 805 l->append(", "); |
806 LogParam(base::get<4>(p), l); | 806 LogParam(std::get<4>(p), l); |
807 } | 807 } |
808 }; | 808 }; |
809 | 809 |
810 template<class P> | 810 template<class P> |
811 struct ParamTraits<ScopedVector<P> > { | 811 struct ParamTraits<ScopedVector<P> > { |
812 typedef ScopedVector<P> param_type; | 812 typedef ScopedVector<P> param_type; |
813 static void Write(base::Pickle* m, const param_type& p) { | 813 static void Write(base::Pickle* m, const param_type& p) { |
814 WriteParam(m, static_cast<int>(p.size())); | 814 WriteParam(m, static_cast<int>(p.size())); |
815 for (size_t i = 0; i < p.size(); i++) | 815 for (size_t i = 0; i < p.size(); i++) |
816 WriteParam(m, *p[i]); | 816 WriteParam(m, *p[i]); |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1084 template <class ReplyParamType> | 1084 template <class ReplyParamType> |
1085 inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, | 1085 inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, |
1086 const Message* msg) {} | 1086 const Message* msg) {} |
1087 | 1087 |
1088 inline void ConnectMessageAndReply(const Message* msg, Message* reply) {} | 1088 inline void ConnectMessageAndReply(const Message* msg, Message* reply) {} |
1089 #endif | 1089 #endif |
1090 | 1090 |
1091 } // namespace IPC | 1091 } // namespace IPC |
1092 | 1092 |
1093 #endif // IPC_IPC_MESSAGE_UTILS_H_ | 1093 #endif // IPC_IPC_MESSAGE_UTILS_H_ |
OLD | NEW |