Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: ipc/ipc_message_utils.h

Issue 1673563002: Replace base::Tuple implementation with std::tuple (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 typedef base::TimeTicks param_type; 651 typedef base::TimeTicks param_type;
652 static void GetSize(base::PickleSizer* sizer, const param_type& p); 652 static void GetSize(base::PickleSizer* sizer, const param_type& p);
653 static void Write(base::Pickle* m, const param_type& p); 653 static void Write(base::Pickle* m, const param_type& p);
654 static bool Read(const base::Pickle* m, 654 static bool Read(const base::Pickle* m,
655 base::PickleIterator* iter, 655 base::PickleIterator* iter,
656 param_type* r); 656 param_type* r);
657 static void Log(const param_type& p, std::string* l); 657 static void Log(const param_type& p, std::string* l);
658 }; 658 };
659 659
660 template <> 660 template <>
661 struct ParamTraits<base::Tuple<>> { 661 struct ParamTraits<std::tuple<>> {
Nico 2016/02/09 12:23:11 This change is for 2013, right?
tzik 2016/02/10 15:10:54 Yes, it seems failing on the type alias + variadic
662 typedef base::Tuple<> param_type; 662 typedef std::tuple<> param_type;
663 static void GetSize(base::PickleSizer* sizer, const param_type& p) {} 663 static void GetSize(base::PickleSizer* sizer, const param_type& p) {}
664 static void Write(base::Pickle* m, const param_type& p) {} 664 static void Write(base::Pickle* m, const param_type& p) {}
665 static bool Read(const base::Pickle* m, 665 static bool Read(const base::Pickle* m,
666 base::PickleIterator* iter, 666 base::PickleIterator* iter,
667 param_type* r) { 667 param_type* r) {
668 return true; 668 return true;
669 } 669 }
670 static void Log(const param_type& p, std::string* l) { 670 static void Log(const param_type& p, std::string* l) {
671 } 671 }
672 }; 672 };
673 673
674 template <class A> 674 template <class A>
675 struct ParamTraits<base::Tuple<A>> { 675 struct ParamTraits<std::tuple<A>> {
676 typedef base::Tuple<A> param_type; 676 typedef std::tuple<A> param_type;
677 static void GetSize(base::PickleSizer* sizer, const param_type& p) { 677 static void GetSize(base::PickleSizer* sizer, const param_type& p) {
678 GetParamSize(sizer, base::get<0>(p)); 678 GetParamSize(sizer, base::get<0>(p));
679 } 679 }
680 static void Write(base::Pickle* m, const param_type& p) { 680 static void Write(base::Pickle* m, const param_type& p) {
681 WriteParam(m, base::get<0>(p)); 681 WriteParam(m, base::get<0>(p));
682 } 682 }
683 static bool Read(const base::Pickle* m, 683 static bool Read(const base::Pickle* m,
684 base::PickleIterator* iter, 684 base::PickleIterator* iter,
685 param_type* r) { 685 param_type* r) {
686 return ReadParam(m, iter, &base::get<0>(*r)); 686 return ReadParam(m, iter, &base::get<0>(*r));
687 } 687 }
688 static void Log(const param_type& p, std::string* l) { 688 static void Log(const param_type& p, std::string* l) {
689 LogParam(base::get<0>(p), l); 689 LogParam(base::get<0>(p), l);
690 } 690 }
691 }; 691 };
692 692
693 template <class A, class B> 693 template <class A, class B>
694 struct ParamTraits<base::Tuple<A, B>> { 694 struct ParamTraits<std::tuple<A, B>> {
695 typedef base::Tuple<A, B> param_type; 695 typedef std::tuple<A, B> param_type;
696 static void GetSize(base::PickleSizer* sizer, const param_type& p) { 696 static void GetSize(base::PickleSizer* sizer, const param_type& p) {
697 GetParamSize(sizer, base::get<0>(p)); 697 GetParamSize(sizer, base::get<0>(p));
698 GetParamSize(sizer, base::get<1>(p)); 698 GetParamSize(sizer, base::get<1>(p));
699 } 699 }
700 static void Write(base::Pickle* m, const param_type& p) { 700 static void Write(base::Pickle* m, const param_type& p) {
701 WriteParam(m, base::get<0>(p)); 701 WriteParam(m, base::get<0>(p));
702 WriteParam(m, base::get<1>(p)); 702 WriteParam(m, base::get<1>(p));
703 } 703 }
704 static bool Read(const base::Pickle* m, 704 static bool Read(const base::Pickle* m,
705 base::PickleIterator* iter, 705 base::PickleIterator* iter,
706 param_type* r) { 706 param_type* r) {
707 return (ReadParam(m, iter, &base::get<0>(*r)) && 707 return (ReadParam(m, iter, &base::get<0>(*r)) &&
708 ReadParam(m, iter, &base::get<1>(*r))); 708 ReadParam(m, iter, &base::get<1>(*r)));
709 } 709 }
710 static void Log(const param_type& p, std::string* l) { 710 static void Log(const param_type& p, std::string* l) {
711 LogParam(base::get<0>(p), l); 711 LogParam(base::get<0>(p), l);
712 l->append(", "); 712 l->append(", ");
713 LogParam(base::get<1>(p), l); 713 LogParam(base::get<1>(p), l);
714 } 714 }
715 }; 715 };
716 716
717 template <class A, class B, class C> 717 template <class A, class B, class C>
718 struct ParamTraits<base::Tuple<A, B, C>> { 718 struct ParamTraits<std::tuple<A, B, C>> {
719 typedef base::Tuple<A, B, C> param_type; 719 typedef std::tuple<A, B, C> param_type;
720 static void GetSize(base::PickleSizer* sizer, const param_type& p) { 720 static void GetSize(base::PickleSizer* sizer, const param_type& p) {
721 GetParamSize(sizer, base::get<0>(p)); 721 GetParamSize(sizer, base::get<0>(p));
722 GetParamSize(sizer, base::get<1>(p)); 722 GetParamSize(sizer, base::get<1>(p));
723 GetParamSize(sizer, base::get<2>(p)); 723 GetParamSize(sizer, base::get<2>(p));
724 } 724 }
725 static void Write(base::Pickle* m, const param_type& p) { 725 static void Write(base::Pickle* m, const param_type& p) {
726 WriteParam(m, base::get<0>(p)); 726 WriteParam(m, base::get<0>(p));
727 WriteParam(m, base::get<1>(p)); 727 WriteParam(m, base::get<1>(p));
728 WriteParam(m, base::get<2>(p)); 728 WriteParam(m, base::get<2>(p));
729 } 729 }
730 static bool Read(const base::Pickle* m, 730 static bool Read(const base::Pickle* m,
731 base::PickleIterator* iter, 731 base::PickleIterator* iter,
732 param_type* r) { 732 param_type* r) {
733 return (ReadParam(m, iter, &base::get<0>(*r)) && 733 return (ReadParam(m, iter, &base::get<0>(*r)) &&
734 ReadParam(m, iter, &base::get<1>(*r)) && 734 ReadParam(m, iter, &base::get<1>(*r)) &&
735 ReadParam(m, iter, &base::get<2>(*r))); 735 ReadParam(m, iter, &base::get<2>(*r)));
736 } 736 }
737 static void Log(const param_type& p, std::string* l) { 737 static void Log(const param_type& p, std::string* l) {
738 LogParam(base::get<0>(p), l); 738 LogParam(base::get<0>(p), l);
739 l->append(", "); 739 l->append(", ");
740 LogParam(base::get<1>(p), l); 740 LogParam(base::get<1>(p), l);
741 l->append(", "); 741 l->append(", ");
742 LogParam(base::get<2>(p), l); 742 LogParam(base::get<2>(p), l);
743 } 743 }
744 }; 744 };
745 745
746 template <class A, class B, class C, class D> 746 template <class A, class B, class C, class D>
747 struct ParamTraits<base::Tuple<A, B, C, D>> { 747 struct ParamTraits<std::tuple<A, B, C, D>> {
748 typedef base::Tuple<A, B, C, D> param_type; 748 typedef std::tuple<A, B, C, D> param_type;
749 static void GetSize(base::PickleSizer* sizer, const param_type& p) { 749 static void GetSize(base::PickleSizer* sizer, const param_type& p) {
750 GetParamSize(sizer, base::get<0>(p)); 750 GetParamSize(sizer, base::get<0>(p));
751 GetParamSize(sizer, base::get<1>(p)); 751 GetParamSize(sizer, base::get<1>(p));
752 GetParamSize(sizer, base::get<2>(p)); 752 GetParamSize(sizer, base::get<2>(p));
753 GetParamSize(sizer, base::get<3>(p)); 753 GetParamSize(sizer, base::get<3>(p));
754 } 754 }
755 static void Write(base::Pickle* m, const param_type& p) { 755 static void Write(base::Pickle* m, const param_type& p) {
756 WriteParam(m, base::get<0>(p)); 756 WriteParam(m, base::get<0>(p));
757 WriteParam(m, base::get<1>(p)); 757 WriteParam(m, base::get<1>(p));
758 WriteParam(m, base::get<2>(p)); 758 WriteParam(m, base::get<2>(p));
(...skipping 12 matching lines...) Expand all
771 l->append(", "); 771 l->append(", ");
772 LogParam(base::get<1>(p), l); 772 LogParam(base::get<1>(p), l);
773 l->append(", "); 773 l->append(", ");
774 LogParam(base::get<2>(p), l); 774 LogParam(base::get<2>(p), l);
775 l->append(", "); 775 l->append(", ");
776 LogParam(base::get<3>(p), l); 776 LogParam(base::get<3>(p), l);
777 } 777 }
778 }; 778 };
779 779
780 template <class A, class B, class C, class D, class E> 780 template <class A, class B, class C, class D, class E>
781 struct ParamTraits<base::Tuple<A, B, C, D, E>> { 781 struct ParamTraits<std::tuple<A, B, C, D, E>> {
782 typedef base::Tuple<A, B, C, D, E> param_type; 782 typedef std::tuple<A, B, C, D, E> param_type;
783 static void GetSize(base::PickleSizer* sizer, const param_type& p) { 783 static void GetSize(base::PickleSizer* sizer, const param_type& p) {
784 GetParamSize(sizer, base::get<0>(p)); 784 GetParamSize(sizer, base::get<0>(p));
785 GetParamSize(sizer, base::get<1>(p)); 785 GetParamSize(sizer, base::get<1>(p));
786 GetParamSize(sizer, base::get<2>(p)); 786 GetParamSize(sizer, base::get<2>(p));
787 GetParamSize(sizer, base::get<3>(p)); 787 GetParamSize(sizer, base::get<3>(p));
788 GetParamSize(sizer, base::get<4>(p)); 788 GetParamSize(sizer, base::get<4>(p));
789 } 789 }
790 static void Write(base::Pickle* m, const param_type& p) { 790 static void Write(base::Pickle* m, const param_type& p) {
791 WriteParam(m, base::get<0>(p)); 791 WriteParam(m, base::get<0>(p));
792 WriteParam(m, base::get<1>(p)); 792 WriteParam(m, base::get<1>(p));
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 return ok; 1156 return ok;
1157 } 1157 }
1158 1158
1159 template<class T, class Method> 1159 template<class T, class Method>
1160 static bool DispatchDelayReplyWithSendParams(bool ok, 1160 static bool DispatchDelayReplyWithSendParams(bool ok,
1161 const SendParam& send_params, 1161 const SendParam& send_params,
1162 const Message* msg, T* obj, 1162 const Message* msg, T* obj,
1163 Method func) { 1163 Method func) {
1164 Message* reply = SyncMessage::GenerateReply(msg); 1164 Message* reply = SyncMessage::GenerateReply(msg);
1165 if (ok) { 1165 if (ok) {
1166 base::Tuple<Message&> t = base::MakeRefTuple(*reply); 1166 std::tuple<Message&> t = base::MakeRefTuple(*reply);
1167 ConnectMessageAndReply(msg, reply); 1167 ConnectMessageAndReply(msg, reply);
1168 base::DispatchToMethod(obj, func, send_params, &t); 1168 base::DispatchToMethod(obj, func, send_params, &t);
1169 } else { 1169 } else {
1170 NOTREACHED() << "Error deserializing message " << msg->type(); 1170 NOTREACHED() << "Error deserializing message " << msg->type();
1171 reply->set_reply_error(); 1171 reply->set_reply_error();
1172 obj->Send(reply); 1172 obj->Send(reply);
1173 } 1173 }
1174 return ok; 1174 return ok;
1175 } 1175 }
1176 1176
1177 template <typename... Ts> 1177 template <typename... Ts>
1178 static void WriteReplyParams(Message* reply, Ts... args) { 1178 static void WriteReplyParams(Message* reply, Ts... args) {
1179 ReplyParam p(args...); 1179 ReplyParam p(args...);
1180 WriteParam(reply, p); 1180 WriteParam(reply, p);
1181 } 1181 }
1182 }; 1182 };
1183 1183
1184 } // namespace IPC 1184 } // namespace IPC
1185 1185
1186 #endif // IPC_IPC_MESSAGE_UTILS_H_ 1186 #endif // IPC_IPC_MESSAGE_UTILS_H_
OLDNEW
« no previous file with comments | « base/tuple.h ('k') | ppapi/proxy/ppapi_message_utils.h » ('j') | styleguide/c++/c++11.html » ('J')

Powered by Google App Engine
This is Rietveld 408576698