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> |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 typedef base::TimeTicks param_type; | 628 typedef base::TimeTicks param_type; |
629 static void GetSize(base::PickleSizer* sizer, const param_type& p); | 629 static void GetSize(base::PickleSizer* sizer, const param_type& p); |
630 static void Write(base::Pickle* m, const param_type& p); | 630 static void Write(base::Pickle* m, const param_type& p); |
631 static bool Read(const base::Pickle* m, | 631 static bool Read(const base::Pickle* m, |
632 base::PickleIterator* iter, | 632 base::PickleIterator* iter, |
633 param_type* r); | 633 param_type* r); |
634 static void Log(const param_type& p, std::string* l); | 634 static void Log(const param_type& p, std::string* l); |
635 }; | 635 }; |
636 | 636 |
637 template <> | 637 template <> |
638 struct ParamTraits<base::Tuple<>> { | 638 struct ParamTraits<std::tuple<>> { |
639 typedef base::Tuple<> param_type; | 639 typedef std::tuple<> param_type; |
640 static void GetSize(base::PickleSizer* sizer, const param_type& p) {} | 640 static void GetSize(base::PickleSizer* sizer, const param_type& p) {} |
641 static void Write(base::Pickle* m, const param_type& p) {} | 641 static void Write(base::Pickle* m, const param_type& p) {} |
642 static bool Read(const base::Pickle* m, | 642 static bool Read(const base::Pickle* m, |
643 base::PickleIterator* iter, | 643 base::PickleIterator* iter, |
644 param_type* r) { | 644 param_type* r) { |
645 return true; | 645 return true; |
646 } | 646 } |
647 static void Log(const param_type& p, std::string* l) { | 647 static void Log(const param_type& p, std::string* l) { |
648 } | 648 } |
649 }; | 649 }; |
650 | 650 |
651 template <class A> | 651 template <class A> |
652 struct ParamTraits<base::Tuple<A>> { | 652 struct ParamTraits<std::tuple<A>> { |
653 typedef base::Tuple<A> param_type; | 653 typedef std::tuple<A> param_type; |
654 static void GetSize(base::PickleSizer* sizer, const param_type& p) { | 654 static void GetSize(base::PickleSizer* sizer, const param_type& p) { |
655 GetParamSize(sizer, base::get<0>(p)); | 655 GetParamSize(sizer, base::get<0>(p)); |
656 } | 656 } |
657 static void Write(base::Pickle* m, const param_type& p) { | 657 static void Write(base::Pickle* m, const param_type& p) { |
658 WriteParam(m, base::get<0>(p)); | 658 WriteParam(m, base::get<0>(p)); |
659 } | 659 } |
660 static bool Read(const base::Pickle* m, | 660 static bool Read(const base::Pickle* m, |
661 base::PickleIterator* iter, | 661 base::PickleIterator* iter, |
662 param_type* r) { | 662 param_type* r) { |
663 return ReadParam(m, iter, &base::get<0>(*r)); | 663 return ReadParam(m, iter, &base::get<0>(*r)); |
664 } | 664 } |
665 static void Log(const param_type& p, std::string* l) { | 665 static void Log(const param_type& p, std::string* l) { |
666 LogParam(base::get<0>(p), l); | 666 LogParam(base::get<0>(p), l); |
667 } | 667 } |
668 }; | 668 }; |
669 | 669 |
670 template <class A, class B> | 670 template <class A, class B> |
671 struct ParamTraits<base::Tuple<A, B>> { | 671 struct ParamTraits<std::tuple<A, B>> { |
672 typedef base::Tuple<A, B> param_type; | 672 typedef std::tuple<A, B> param_type; |
673 static void GetSize(base::PickleSizer* sizer, const param_type& p) { | 673 static void GetSize(base::PickleSizer* sizer, const param_type& p) { |
674 GetParamSize(sizer, base::get<0>(p)); | 674 GetParamSize(sizer, base::get<0>(p)); |
675 GetParamSize(sizer, base::get<1>(p)); | 675 GetParamSize(sizer, base::get<1>(p)); |
676 } | 676 } |
677 static void Write(base::Pickle* m, const param_type& p) { | 677 static void Write(base::Pickle* m, const param_type& p) { |
678 WriteParam(m, base::get<0>(p)); | 678 WriteParam(m, base::get<0>(p)); |
679 WriteParam(m, base::get<1>(p)); | 679 WriteParam(m, base::get<1>(p)); |
680 } | 680 } |
681 static bool Read(const base::Pickle* m, | 681 static bool Read(const base::Pickle* m, |
682 base::PickleIterator* iter, | 682 base::PickleIterator* iter, |
683 param_type* r) { | 683 param_type* r) { |
684 return (ReadParam(m, iter, &base::get<0>(*r)) && | 684 return (ReadParam(m, iter, &base::get<0>(*r)) && |
685 ReadParam(m, iter, &base::get<1>(*r))); | 685 ReadParam(m, iter, &base::get<1>(*r))); |
686 } | 686 } |
687 static void Log(const param_type& p, std::string* l) { | 687 static void Log(const param_type& p, std::string* l) { |
688 LogParam(base::get<0>(p), l); | 688 LogParam(base::get<0>(p), l); |
689 l->append(", "); | 689 l->append(", "); |
690 LogParam(base::get<1>(p), l); | 690 LogParam(base::get<1>(p), l); |
691 } | 691 } |
692 }; | 692 }; |
693 | 693 |
694 template <class A, class B, class C> | 694 template <class A, class B, class C> |
695 struct ParamTraits<base::Tuple<A, B, C>> { | 695 struct ParamTraits<std::tuple<A, B, C>> { |
696 typedef base::Tuple<A, B, C> param_type; | 696 typedef std::tuple<A, B, C> param_type; |
697 static void GetSize(base::PickleSizer* sizer, const param_type& p) { | 697 static void GetSize(base::PickleSizer* sizer, const param_type& p) { |
698 GetParamSize(sizer, base::get<0>(p)); | 698 GetParamSize(sizer, base::get<0>(p)); |
699 GetParamSize(sizer, base::get<1>(p)); | 699 GetParamSize(sizer, base::get<1>(p)); |
700 GetParamSize(sizer, base::get<2>(p)); | 700 GetParamSize(sizer, base::get<2>(p)); |
701 } | 701 } |
702 static void Write(base::Pickle* m, const param_type& p) { | 702 static void Write(base::Pickle* m, const param_type& p) { |
703 WriteParam(m, base::get<0>(p)); | 703 WriteParam(m, base::get<0>(p)); |
704 WriteParam(m, base::get<1>(p)); | 704 WriteParam(m, base::get<1>(p)); |
705 WriteParam(m, base::get<2>(p)); | 705 WriteParam(m, base::get<2>(p)); |
706 } | 706 } |
707 static bool Read(const base::Pickle* m, | 707 static bool Read(const base::Pickle* m, |
708 base::PickleIterator* iter, | 708 base::PickleIterator* iter, |
709 param_type* r) { | 709 param_type* r) { |
710 return (ReadParam(m, iter, &base::get<0>(*r)) && | 710 return (ReadParam(m, iter, &base::get<0>(*r)) && |
711 ReadParam(m, iter, &base::get<1>(*r)) && | 711 ReadParam(m, iter, &base::get<1>(*r)) && |
712 ReadParam(m, iter, &base::get<2>(*r))); | 712 ReadParam(m, iter, &base::get<2>(*r))); |
713 } | 713 } |
714 static void Log(const param_type& p, std::string* l) { | 714 static void Log(const param_type& p, std::string* l) { |
715 LogParam(base::get<0>(p), l); | 715 LogParam(base::get<0>(p), l); |
716 l->append(", "); | 716 l->append(", "); |
717 LogParam(base::get<1>(p), l); | 717 LogParam(base::get<1>(p), l); |
718 l->append(", "); | 718 l->append(", "); |
719 LogParam(base::get<2>(p), l); | 719 LogParam(base::get<2>(p), l); |
720 } | 720 } |
721 }; | 721 }; |
722 | 722 |
723 template <class A, class B, class C, class D> | 723 template <class A, class B, class C, class D> |
724 struct ParamTraits<base::Tuple<A, B, C, D>> { | 724 struct ParamTraits<std::tuple<A, B, C, D>> { |
725 typedef base::Tuple<A, B, C, D> param_type; | 725 typedef std::tuple<A, B, C, D> param_type; |
726 static void GetSize(base::PickleSizer* sizer, const param_type& p) { | 726 static void GetSize(base::PickleSizer* sizer, const param_type& p) { |
727 GetParamSize(sizer, base::get<0>(p)); | 727 GetParamSize(sizer, base::get<0>(p)); |
728 GetParamSize(sizer, base::get<1>(p)); | 728 GetParamSize(sizer, base::get<1>(p)); |
729 GetParamSize(sizer, base::get<2>(p)); | 729 GetParamSize(sizer, base::get<2>(p)); |
730 GetParamSize(sizer, base::get<3>(p)); | 730 GetParamSize(sizer, base::get<3>(p)); |
731 } | 731 } |
732 static void Write(base::Pickle* m, const param_type& p) { | 732 static void Write(base::Pickle* m, const param_type& p) { |
733 WriteParam(m, base::get<0>(p)); | 733 WriteParam(m, base::get<0>(p)); |
734 WriteParam(m, base::get<1>(p)); | 734 WriteParam(m, base::get<1>(p)); |
735 WriteParam(m, base::get<2>(p)); | 735 WriteParam(m, base::get<2>(p)); |
(...skipping 12 matching lines...) Expand all Loading... |
748 l->append(", "); | 748 l->append(", "); |
749 LogParam(base::get<1>(p), l); | 749 LogParam(base::get<1>(p), l); |
750 l->append(", "); | 750 l->append(", "); |
751 LogParam(base::get<2>(p), l); | 751 LogParam(base::get<2>(p), l); |
752 l->append(", "); | 752 l->append(", "); |
753 LogParam(base::get<3>(p), l); | 753 LogParam(base::get<3>(p), l); |
754 } | 754 } |
755 }; | 755 }; |
756 | 756 |
757 template <class A, class B, class C, class D, class E> | 757 template <class A, class B, class C, class D, class E> |
758 struct ParamTraits<base::Tuple<A, B, C, D, E>> { | 758 struct ParamTraits<std::tuple<A, B, C, D, E>> { |
759 typedef base::Tuple<A, B, C, D, E> param_type; | 759 typedef std::tuple<A, B, C, D, E> param_type; |
760 static void GetSize(base::PickleSizer* sizer, const param_type& p) { | 760 static void GetSize(base::PickleSizer* sizer, const param_type& p) { |
761 GetParamSize(sizer, base::get<0>(p)); | 761 GetParamSize(sizer, base::get<0>(p)); |
762 GetParamSize(sizer, base::get<1>(p)); | 762 GetParamSize(sizer, base::get<1>(p)); |
763 GetParamSize(sizer, base::get<2>(p)); | 763 GetParamSize(sizer, base::get<2>(p)); |
764 GetParamSize(sizer, base::get<3>(p)); | 764 GetParamSize(sizer, base::get<3>(p)); |
765 GetParamSize(sizer, base::get<4>(p)); | 765 GetParamSize(sizer, base::get<4>(p)); |
766 } | 766 } |
767 static void Write(base::Pickle* m, const param_type& p) { | 767 static void Write(base::Pickle* m, const param_type& p) { |
768 WriteParam(m, base::get<0>(p)); | 768 WriteParam(m, base::get<0>(p)); |
769 WriteParam(m, base::get<1>(p)); | 769 WriteParam(m, base::get<1>(p)); |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 template <class ReplyParamType> | 1070 template <class ReplyParamType> |
1071 inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, | 1071 inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, |
1072 const Message* msg) {} | 1072 const Message* msg) {} |
1073 | 1073 |
1074 inline void ConnectMessageAndReply(const Message* msg, Message* reply) {} | 1074 inline void ConnectMessageAndReply(const Message* msg, Message* reply) {} |
1075 #endif | 1075 #endif |
1076 | 1076 |
1077 } // namespace IPC | 1077 } // namespace IPC |
1078 | 1078 |
1079 #endif // IPC_IPC_MESSAGE_UTILS_H_ | 1079 #endif // IPC_IPC_MESSAGE_UTILS_H_ |
OLD | NEW |