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

Side by Side Diff: ipc/ipc_message_utils.h

Issue 826573002: Revert "Update legacy Tuple-using code." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 12 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
« no previous file with comments | « ipc/ipc_message_macros.h ('k') | sandbox/linux/seccomp-bpf/codegen.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 513
514 template <> 514 template <>
515 struct IPC_EXPORT ParamTraits<base::TimeTicks> { 515 struct IPC_EXPORT ParamTraits<base::TimeTicks> {
516 typedef base::TimeTicks param_type; 516 typedef base::TimeTicks param_type;
517 static void Write(Message* m, const param_type& p); 517 static void Write(Message* m, const param_type& p);
518 static bool Read(const Message* m, PickleIterator* iter, param_type* r); 518 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
519 static void Log(const param_type& p, std::string* l); 519 static void Log(const param_type& p, std::string* l);
520 }; 520 };
521 521
522 template <> 522 template <>
523 struct ParamTraits<Tuple<>> { 523 struct ParamTraits<Tuple0> {
524 typedef Tuple<> param_type; 524 typedef Tuple0 param_type;
525 static void Write(Message* m, const param_type& p) { 525 static void Write(Message* m, const param_type& p) {
526 } 526 }
527 static bool Read(const Message* m, PickleIterator* iter, param_type* r) { 527 static bool Read(const Message* m, PickleIterator* iter, param_type* r) {
528 return true; 528 return true;
529 } 529 }
530 static void Log(const param_type& p, std::string* l) { 530 static void Log(const param_type& p, std::string* l) {
531 } 531 }
532 }; 532 };
533 533
534 template <class A> 534 template <class A>
535 struct ParamTraits<Tuple<A>> { 535 struct ParamTraits< Tuple1<A> > {
536 typedef Tuple<A> param_type; 536 typedef Tuple1<A> param_type;
537 static void Write(Message* m, const param_type& p) { 537 static void Write(Message* m, const param_type& p) {
538 WriteParam(m, get<0>(p)); 538 WriteParam(m, p.a);
539 } 539 }
540 static bool Read(const Message* m, PickleIterator* iter, param_type* r) { 540 static bool Read(const Message* m, PickleIterator* iter, param_type* r) {
541 return ReadParam(m, iter, &get<0>(*r)); 541 return ReadParam(m, iter, &r->a);
542 } 542 }
543 static void Log(const param_type& p, std::string* l) { 543 static void Log(const param_type& p, std::string* l) {
544 LogParam(get<0>(p), l); 544 LogParam(p.a, l);
545 } 545 }
546 }; 546 };
547 547
548 template <class A, class B> 548 template <class A, class B>
549 struct ParamTraits< Tuple<A, B> > { 549 struct ParamTraits< Tuple2<A, B> > {
550 typedef Tuple<A, B> param_type; 550 typedef Tuple2<A, B> param_type;
551 static void Write(Message* m, const param_type& p) { 551 static void Write(Message* m, const param_type& p) {
552 WriteParam(m, get<0>(p)); 552 WriteParam(m, p.a);
553 WriteParam(m, get<1>(p)); 553 WriteParam(m, p.b);
554 } 554 }
555 static bool Read(const Message* m, PickleIterator* iter, param_type* r) { 555 static bool Read(const Message* m, PickleIterator* iter, param_type* r) {
556 return (ReadParam(m, iter, &get<0>(*r)) && 556 return (ReadParam(m, iter, &r->a) &&
557 ReadParam(m, iter, &get<1>(*r))); 557 ReadParam(m, iter, &r->b));
558 } 558 }
559 static void Log(const param_type& p, std::string* l) { 559 static void Log(const param_type& p, std::string* l) {
560 LogParam(get<0>(p), l); 560 LogParam(p.a, l);
561 l->append(", "); 561 l->append(", ");
562 LogParam(get<1>(p), l); 562 LogParam(p.b, l);
563 } 563 }
564 }; 564 };
565 565
566 template <class A, class B, class C> 566 template <class A, class B, class C>
567 struct ParamTraits< Tuple<A, B, C> > { 567 struct ParamTraits< Tuple3<A, B, C> > {
568 typedef Tuple<A, B, C> param_type; 568 typedef Tuple3<A, B, C> param_type;
569 static void Write(Message* m, const param_type& p) { 569 static void Write(Message* m, const param_type& p) {
570 WriteParam(m, get<0>(p)); 570 WriteParam(m, p.a);
571 WriteParam(m, get<1>(p)); 571 WriteParam(m, p.b);
572 WriteParam(m, get<2>(p)); 572 WriteParam(m, p.c);
573 } 573 }
574 static bool Read(const Message* m, PickleIterator* iter, param_type* r) { 574 static bool Read(const Message* m, PickleIterator* iter, param_type* r) {
575 return (ReadParam(m, iter, &get<0>(*r)) && 575 return (ReadParam(m, iter, &r->a) &&
576 ReadParam(m, iter, &get<1>(*r)) && 576 ReadParam(m, iter, &r->b) &&
577 ReadParam(m, iter, &get<2>(*r))); 577 ReadParam(m, iter, &r->c));
578 } 578 }
579 static void Log(const param_type& p, std::string* l) { 579 static void Log(const param_type& p, std::string* l) {
580 LogParam(get<0>(p), l); 580 LogParam(p.a, l);
581 l->append(", "); 581 l->append(", ");
582 LogParam(get<1>(p), l); 582 LogParam(p.b, l);
583 l->append(", "); 583 l->append(", ");
584 LogParam(get<2>(p), l); 584 LogParam(p.c, l);
585 } 585 }
586 }; 586 };
587 587
588 template <class A, class B, class C, class D> 588 template <class A, class B, class C, class D>
589 struct ParamTraits< Tuple<A, B, C, D> > { 589 struct ParamTraits< Tuple4<A, B, C, D> > {
590 typedef Tuple<A, B, C, D> param_type; 590 typedef Tuple4<A, B, C, D> param_type;
591 static void Write(Message* m, const param_type& p) { 591 static void Write(Message* m, const param_type& p) {
592 WriteParam(m, get<0>(p)); 592 WriteParam(m, p.a);
593 WriteParam(m, get<1>(p)); 593 WriteParam(m, p.b);
594 WriteParam(m, get<2>(p)); 594 WriteParam(m, p.c);
595 WriteParam(m, get<3>(p)); 595 WriteParam(m, p.d);
596 } 596 }
597 static bool Read(const Message* m, PickleIterator* iter, param_type* r) { 597 static bool Read(const Message* m, PickleIterator* iter, param_type* r) {
598 return (ReadParam(m, iter, &get<0>(*r)) && 598 return (ReadParam(m, iter, &r->a) &&
599 ReadParam(m, iter, &get<1>(*r)) && 599 ReadParam(m, iter, &r->b) &&
600 ReadParam(m, iter, &get<2>(*r)) && 600 ReadParam(m, iter, &r->c) &&
601 ReadParam(m, iter, &get<3>(*r))); 601 ReadParam(m, iter, &r->d));
602 } 602 }
603 static void Log(const param_type& p, std::string* l) { 603 static void Log(const param_type& p, std::string* l) {
604 LogParam(get<0>(p), l); 604 LogParam(p.a, l);
605 l->append(", "); 605 l->append(", ");
606 LogParam(get<1>(p), l); 606 LogParam(p.b, l);
607 l->append(", "); 607 l->append(", ");
608 LogParam(get<2>(p), l); 608 LogParam(p.c, l);
609 l->append(", "); 609 l->append(", ");
610 LogParam(get<3>(p), l); 610 LogParam(p.d, l);
611 } 611 }
612 }; 612 };
613 613
614 template <class A, class B, class C, class D, class E> 614 template <class A, class B, class C, class D, class E>
615 struct ParamTraits< Tuple<A, B, C, D, E> > { 615 struct ParamTraits< Tuple5<A, B, C, D, E> > {
616 typedef Tuple<A, B, C, D, E> param_type; 616 typedef Tuple5<A, B, C, D, E> param_type;
617 static void Write(Message* m, const param_type& p) { 617 static void Write(Message* m, const param_type& p) {
618 WriteParam(m, get<0>(p)); 618 WriteParam(m, p.a);
619 WriteParam(m, get<1>(p)); 619 WriteParam(m, p.b);
620 WriteParam(m, get<2>(p)); 620 WriteParam(m, p.c);
621 WriteParam(m, get<3>(p)); 621 WriteParam(m, p.d);
622 WriteParam(m, get<4>(p)); 622 WriteParam(m, p.e);
623 } 623 }
624 static bool Read(const Message* m, PickleIterator* iter, param_type* r) { 624 static bool Read(const Message* m, PickleIterator* iter, param_type* r) {
625 return (ReadParam(m, iter, &get<0>(*r)) && 625 return (ReadParam(m, iter, &r->a) &&
626 ReadParam(m, iter, &get<1>(*r)) && 626 ReadParam(m, iter, &r->b) &&
627 ReadParam(m, iter, &get<2>(*r)) && 627 ReadParam(m, iter, &r->c) &&
628 ReadParam(m, iter, &get<3>(*r)) && 628 ReadParam(m, iter, &r->d) &&
629 ReadParam(m, iter, &get<4>(*r))); 629 ReadParam(m, iter, &r->e));
630 } 630 }
631 static void Log(const param_type& p, std::string* l) { 631 static void Log(const param_type& p, std::string* l) {
632 LogParam(get<0>(p), l); 632 LogParam(p.a, l);
633 l->append(", "); 633 l->append(", ");
634 LogParam(get<1>(p), l); 634 LogParam(p.b, l);
635 l->append(", "); 635 l->append(", ");
636 LogParam(get<2>(p), l); 636 LogParam(p.c, l);
637 l->append(", "); 637 l->append(", ");
638 LogParam(get<3>(p), l); 638 LogParam(p.d, l);
639 l->append(", "); 639 l->append(", ");
640 LogParam(get<4>(p), l); 640 LogParam(p.e, l);
641 } 641 }
642 }; 642 };
643 643
644 template<class P> 644 template<class P>
645 struct ParamTraits<ScopedVector<P> > { 645 struct ParamTraits<ScopedVector<P> > {
646 typedef ScopedVector<P> param_type; 646 typedef ScopedVector<P> param_type;
647 static void Write(Message* m, const param_type& p) { 647 static void Write(Message* m, const param_type& p) {
648 WriteParam(m, static_cast<int>(p.size())); 648 WriteParam(m, static_cast<int>(p.size()));
649 for (size_t i = 0; i < p.size(); i++) 649 for (size_t i = 0; i < p.size(); i++)
650 WriteParam(m, *p[i]); 650 WriteParam(m, *p[i]);
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 return ok; 905 return ok;
906 } 906 }
907 907
908 template<class T, class Method> 908 template<class T, class Method>
909 static bool DispatchDelayReplyWithSendParams(bool ok, 909 static bool DispatchDelayReplyWithSendParams(bool ok,
910 const SendParam& send_params, 910 const SendParam& send_params,
911 const Message* msg, T* obj, 911 const Message* msg, T* obj,
912 Method func) { 912 Method func) {
913 Message* reply = SyncMessage::GenerateReply(msg); 913 Message* reply = SyncMessage::GenerateReply(msg);
914 if (ok) { 914 if (ok) {
915 Tuple<Message&> t = MakeRefTuple(*reply); 915 Tuple1<Message&> t = MakeRefTuple(*reply);
916 ConnectMessageAndReply(msg, reply); 916 ConnectMessageAndReply(msg, reply);
917 DispatchToMethod(obj, func, send_params, &t); 917 DispatchToMethod(obj, func, send_params, &t);
918 } else { 918 } else {
919 NOTREACHED() << "Error deserializing message " << msg->type(); 919 NOTREACHED() << "Error deserializing message " << msg->type();
920 reply->set_reply_error(); 920 reply->set_reply_error();
921 obj->Send(reply); 921 obj->Send(reply);
922 } 922 }
923 return ok; 923 return ok;
924 } 924 }
925 925
(...skipping 24 matching lines...) Expand all
950 template<typename TA, typename TB, typename TC, typename TD, typename TE> 950 template<typename TA, typename TB, typename TC, typename TD, typename TE>
951 static void WriteReplyParams(Message* reply, TA a, TB b, TC c, TD d, TE e) { 951 static void WriteReplyParams(Message* reply, TA a, TB b, TC c, TD d, TE e) {
952 ReplyParam p(a, b, c, d, e); 952 ReplyParam p(a, b, c, d, e);
953 WriteParam(reply, p); 953 WriteParam(reply, p);
954 } 954 }
955 }; 955 };
956 956
957 } // namespace IPC 957 } // namespace IPC
958 958
959 #endif // IPC_IPC_MESSAGE_UTILS_H_ 959 #endif // IPC_IPC_MESSAGE_UTILS_H_
OLDNEW
« no previous file with comments | « ipc/ipc_message_macros.h ('k') | sandbox/linux/seccomp-bpf/codegen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698