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

Side by Side Diff: webrtc/base/bind.h

Issue 1308563004: rtc::Bind: Capture scoped_refptr reference arguments by value (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Capture scoped_refptr references by-value instead Created 5 years, 4 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 | « no previous file | webrtc/base/bind.h.pump » ('j') | webrtc/base/bind_unittest.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // This file was GENERATED by command: 1 // This file was GENERATED by command:
2 // pump.py bind.h.pump 2 // pump.py bind.h.pump
3 // DO NOT EDIT BY HAND!!! 3 // DO NOT EDIT BY HAND!!!
4 4
5 /* 5 /*
6 * Copyright 2012 The WebRTC Project Authors. All rights reserved. 6 * Copyright 2012 The WebRTC Project Authors. All rights reserved.
7 * 7 *
8 * Use of this source code is governed by a BSD-style license 8 * Use of this source code is governed by a BSD-style license
9 * that can be found in the LICENSE file in the root of the source 9 * that can be found in the LICENSE file in the root of the source
10 * tree. An additional intellectual property rights grant can be found 10 * tree. An additional intellectual property rights grant can be found
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 121
122 // PointerType<T>::type will be scoped_refptr<T> for ref counted types, and T* 122 // PointerType<T>::type will be scoped_refptr<T> for ref counted types, and T*
123 // otherwise. 123 // otherwise.
124 template <class T> 124 template <class T>
125 struct PointerType { 125 struct PointerType {
126 typedef typename TernaryTypeOperator<IsRefCounted<T>::value, 126 typedef typename TernaryTypeOperator<IsRefCounted<T>::value,
127 scoped_refptr<T>, 127 scoped_refptr<T>,
128 T*>::type type; 128 T*>::type type;
129 }; 129 };
130 130
131 // RemoveScopedPtrRef will capture scoped_refptr by-value instead of
132 // by-reference.
133 template <class T> struct RemoveScopedPtrRef { typedef T type; };
134 template <class T>
135 struct RemoveScopedPtrRef<const scoped_refptr<T>&> {
136 typedef scoped_refptr<T> type;
137 };
138 template <class T>
139 struct RemoveScopedPtrRef<scoped_refptr<T>&> {
140 typedef scoped_refptr<T> type;
141 };
142
131 } // namespace detail 143 } // namespace detail
132 144
133 template <class ObjectT, class MethodT, class R> 145 template <class ObjectT, class MethodT, class R>
134 class MethodFunctor0 { 146 class MethodFunctor0 {
135 public: 147 public:
136 MethodFunctor0(MethodT method, ObjectT* object) 148 MethodFunctor0(MethodT method, ObjectT* object)
137 : method_(method), object_(object) {} 149 : method_(method), object_(object) {}
138 R operator()() const { 150 R operator()() const {
139 return (object_->*method_)(); } 151 return (object_->*method_)(); }
140 private: 152 private:
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 public: 213 public:
202 MethodFunctor1(MethodT method, ObjectT* object, 214 MethodFunctor1(MethodT method, ObjectT* object,
203 P1 p1) 215 P1 p1)
204 : method_(method), object_(object), 216 : method_(method), object_(object),
205 p1_(p1) {} 217 p1_(p1) {}
206 R operator()() const { 218 R operator()() const {
207 return (object_->*method_)(p1_); } 219 return (object_->*method_)(p1_); }
208 private: 220 private:
209 MethodT method_; 221 MethodT method_;
210 typename detail::PointerType<ObjectT>::type object_; 222 typename detail::PointerType<ObjectT>::type object_;
211 P1 p1_; 223 typename detail::RemoveScopedPtrRef<P1>::type p1_;
212 }; 224 };
213 225
214 template <class FunctorT, class R, 226 template <class FunctorT, class R,
215 class P1> 227 class P1>
216 class Functor1 { 228 class Functor1 {
217 public: 229 public:
218 Functor1(const FunctorT& functor, P1 p1) 230 Functor1(const FunctorT& functor, P1 p1)
219 : functor_(functor), 231 : functor_(functor),
220 p1_(p1) {} 232 p1_(p1) {}
221 R operator()() const { 233 R operator()() const {
222 return functor_(p1_); } 234 return functor_(p1_); }
223 private: 235 private:
224 FunctorT functor_; 236 FunctorT functor_;
225 P1 p1_; 237 typename detail::RemoveScopedPtrRef<P1>::type p1_;
226 }; 238 };
227 239
228 240
229 #define FP_T(x) R (ObjectT::*x)(P1) 241 #define FP_T(x) R (ObjectT::*x)(P1)
230 242
231 template <class ObjectT, class R, 243 template <class ObjectT, class R,
232 class P1> 244 class P1>
233 MethodFunctor1<ObjectT, FP_T(NONAME), R, P1> 245 MethodFunctor1<ObjectT, FP_T(NONAME), R, P1>
234 Bind(FP_T(method), ObjectT* object, 246 Bind(FP_T(method), ObjectT* object,
235 typename detail::identity<P1>::type p1) { 247 typename detail::identity<P1>::type p1) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 P1 p1, 296 P1 p1,
285 P2 p2) 297 P2 p2)
286 : method_(method), object_(object), 298 : method_(method), object_(object),
287 p1_(p1), 299 p1_(p1),
288 p2_(p2) {} 300 p2_(p2) {}
289 R operator()() const { 301 R operator()() const {
290 return (object_->*method_)(p1_, p2_); } 302 return (object_->*method_)(p1_, p2_); }
291 private: 303 private:
292 MethodT method_; 304 MethodT method_;
293 typename detail::PointerType<ObjectT>::type object_; 305 typename detail::PointerType<ObjectT>::type object_;
294 P1 p1_; 306 typename detail::RemoveScopedPtrRef<P1>::type p1_;
295 P2 p2_; 307 typename detail::RemoveScopedPtrRef<P2>::type p2_;
296 }; 308 };
297 309
298 template <class FunctorT, class R, 310 template <class FunctorT, class R,
299 class P1, 311 class P1,
300 class P2> 312 class P2>
301 class Functor2 { 313 class Functor2 {
302 public: 314 public:
303 Functor2(const FunctorT& functor, P1 p1, P2 p2) 315 Functor2(const FunctorT& functor, P1 p1, P2 p2)
304 : functor_(functor), 316 : functor_(functor),
305 p1_(p1), 317 p1_(p1),
306 p2_(p2) {} 318 p2_(p2) {}
307 R operator()() const { 319 R operator()() const {
308 return functor_(p1_, p2_); } 320 return functor_(p1_, p2_); }
309 private: 321 private:
310 FunctorT functor_; 322 FunctorT functor_;
311 P1 p1_; 323 typename detail::RemoveScopedPtrRef<P1>::type p1_;
312 P2 p2_; 324 typename detail::RemoveScopedPtrRef<P2>::type p2_;
313 }; 325 };
314 326
315 327
316 #define FP_T(x) R (ObjectT::*x)(P1, P2) 328 #define FP_T(x) R (ObjectT::*x)(P1, P2)
317 329
318 template <class ObjectT, class R, 330 template <class ObjectT, class R,
319 class P1, 331 class P1,
320 class P2> 332 class P2>
321 MethodFunctor2<ObjectT, FP_T(NONAME), R, P1, P2> 333 MethodFunctor2<ObjectT, FP_T(NONAME), R, P1, P2>
322 Bind(FP_T(method), ObjectT* object, 334 Bind(FP_T(method), ObjectT* object,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 P3 p3) 394 P3 p3)
383 : method_(method), object_(object), 395 : method_(method), object_(object),
384 p1_(p1), 396 p1_(p1),
385 p2_(p2), 397 p2_(p2),
386 p3_(p3) {} 398 p3_(p3) {}
387 R operator()() const { 399 R operator()() const {
388 return (object_->*method_)(p1_, p2_, p3_); } 400 return (object_->*method_)(p1_, p2_, p3_); }
389 private: 401 private:
390 MethodT method_; 402 MethodT method_;
391 typename detail::PointerType<ObjectT>::type object_; 403 typename detail::PointerType<ObjectT>::type object_;
392 P1 p1_; 404 typename detail::RemoveScopedPtrRef<P1>::type p1_;
393 P2 p2_; 405 typename detail::RemoveScopedPtrRef<P2>::type p2_;
394 P3 p3_; 406 typename detail::RemoveScopedPtrRef<P3>::type p3_;
395 }; 407 };
396 408
397 template <class FunctorT, class R, 409 template <class FunctorT, class R,
398 class P1, 410 class P1,
399 class P2, 411 class P2,
400 class P3> 412 class P3>
401 class Functor3 { 413 class Functor3 {
402 public: 414 public:
403 Functor3(const FunctorT& functor, P1 p1, P2 p2, P3 p3) 415 Functor3(const FunctorT& functor, P1 p1, P2 p2, P3 p3)
404 : functor_(functor), 416 : functor_(functor),
405 p1_(p1), 417 p1_(p1),
406 p2_(p2), 418 p2_(p2),
407 p3_(p3) {} 419 p3_(p3) {}
408 R operator()() const { 420 R operator()() const {
409 return functor_(p1_, p2_, p3_); } 421 return functor_(p1_, p2_, p3_); }
410 private: 422 private:
411 FunctorT functor_; 423 FunctorT functor_;
412 P1 p1_; 424 typename detail::RemoveScopedPtrRef<P1>::type p1_;
413 P2 p2_; 425 typename detail::RemoveScopedPtrRef<P2>::type p2_;
414 P3 p3_; 426 typename detail::RemoveScopedPtrRef<P3>::type p3_;
415 }; 427 };
416 428
417 429
418 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3) 430 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3)
419 431
420 template <class ObjectT, class R, 432 template <class ObjectT, class R,
421 class P1, 433 class P1,
422 class P2, 434 class P2,
423 class P3> 435 class P3>
424 MethodFunctor3<ObjectT, FP_T(NONAME), R, P1, P2, P3> 436 MethodFunctor3<ObjectT, FP_T(NONAME), R, P1, P2, P3>
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 : method_(method), object_(object), 507 : method_(method), object_(object),
496 p1_(p1), 508 p1_(p1),
497 p2_(p2), 509 p2_(p2),
498 p3_(p3), 510 p3_(p3),
499 p4_(p4) {} 511 p4_(p4) {}
500 R operator()() const { 512 R operator()() const {
501 return (object_->*method_)(p1_, p2_, p3_, p4_); } 513 return (object_->*method_)(p1_, p2_, p3_, p4_); }
502 private: 514 private:
503 MethodT method_; 515 MethodT method_;
504 typename detail::PointerType<ObjectT>::type object_; 516 typename detail::PointerType<ObjectT>::type object_;
505 P1 p1_; 517 typename detail::RemoveScopedPtrRef<P1>::type p1_;
506 P2 p2_; 518 typename detail::RemoveScopedPtrRef<P2>::type p2_;
507 P3 p3_; 519 typename detail::RemoveScopedPtrRef<P3>::type p3_;
508 P4 p4_; 520 typename detail::RemoveScopedPtrRef<P4>::type p4_;
509 }; 521 };
510 522
511 template <class FunctorT, class R, 523 template <class FunctorT, class R,
512 class P1, 524 class P1,
513 class P2, 525 class P2,
514 class P3, 526 class P3,
515 class P4> 527 class P4>
516 class Functor4 { 528 class Functor4 {
517 public: 529 public:
518 Functor4(const FunctorT& functor, P1 p1, P2 p2, P3 p3, P4 p4) 530 Functor4(const FunctorT& functor, P1 p1, P2 p2, P3 p3, P4 p4)
519 : functor_(functor), 531 : functor_(functor),
520 p1_(p1), 532 p1_(p1),
521 p2_(p2), 533 p2_(p2),
522 p3_(p3), 534 p3_(p3),
523 p4_(p4) {} 535 p4_(p4) {}
524 R operator()() const { 536 R operator()() const {
525 return functor_(p1_, p2_, p3_, p4_); } 537 return functor_(p1_, p2_, p3_, p4_); }
526 private: 538 private:
527 FunctorT functor_; 539 FunctorT functor_;
528 P1 p1_; 540 typename detail::RemoveScopedPtrRef<P1>::type p1_;
529 P2 p2_; 541 typename detail::RemoveScopedPtrRef<P2>::type p2_;
530 P3 p3_; 542 typename detail::RemoveScopedPtrRef<P3>::type p3_;
531 P4 p4_; 543 typename detail::RemoveScopedPtrRef<P4>::type p4_;
532 }; 544 };
533 545
534 546
535 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4) 547 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4)
536 548
537 template <class ObjectT, class R, 549 template <class ObjectT, class R,
538 class P1, 550 class P1,
539 class P2, 551 class P2,
540 class P3, 552 class P3,
541 class P4> 553 class P4>
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 p1_(p1), 635 p1_(p1),
624 p2_(p2), 636 p2_(p2),
625 p3_(p3), 637 p3_(p3),
626 p4_(p4), 638 p4_(p4),
627 p5_(p5) {} 639 p5_(p5) {}
628 R operator()() const { 640 R operator()() const {
629 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_); } 641 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_); }
630 private: 642 private:
631 MethodT method_; 643 MethodT method_;
632 typename detail::PointerType<ObjectT>::type object_; 644 typename detail::PointerType<ObjectT>::type object_;
633 P1 p1_; 645 typename detail::RemoveScopedPtrRef<P1>::type p1_;
634 P2 p2_; 646 typename detail::RemoveScopedPtrRef<P2>::type p2_;
635 P3 p3_; 647 typename detail::RemoveScopedPtrRef<P3>::type p3_;
636 P4 p4_; 648 typename detail::RemoveScopedPtrRef<P4>::type p4_;
637 P5 p5_; 649 typename detail::RemoveScopedPtrRef<P5>::type p5_;
638 }; 650 };
639 651
640 template <class FunctorT, class R, 652 template <class FunctorT, class R,
641 class P1, 653 class P1,
642 class P2, 654 class P2,
643 class P3, 655 class P3,
644 class P4, 656 class P4,
645 class P5> 657 class P5>
646 class Functor5 { 658 class Functor5 {
647 public: 659 public:
648 Functor5(const FunctorT& functor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) 660 Functor5(const FunctorT& functor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
649 : functor_(functor), 661 : functor_(functor),
650 p1_(p1), 662 p1_(p1),
651 p2_(p2), 663 p2_(p2),
652 p3_(p3), 664 p3_(p3),
653 p4_(p4), 665 p4_(p4),
654 p5_(p5) {} 666 p5_(p5) {}
655 R operator()() const { 667 R operator()() const {
656 return functor_(p1_, p2_, p3_, p4_, p5_); } 668 return functor_(p1_, p2_, p3_, p4_, p5_); }
657 private: 669 private:
658 FunctorT functor_; 670 FunctorT functor_;
659 P1 p1_; 671 typename detail::RemoveScopedPtrRef<P1>::type p1_;
660 P2 p2_; 672 typename detail::RemoveScopedPtrRef<P2>::type p2_;
661 P3 p3_; 673 typename detail::RemoveScopedPtrRef<P3>::type p3_;
662 P4 p4_; 674 typename detail::RemoveScopedPtrRef<P4>::type p4_;
663 P5 p5_; 675 typename detail::RemoveScopedPtrRef<P5>::type p5_;
664 }; 676 };
665 677
666 678
667 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5) 679 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5)
668 680
669 template <class ObjectT, class R, 681 template <class ObjectT, class R,
670 class P1, 682 class P1,
671 class P2, 683 class P2,
672 class P3, 684 class P3,
673 class P4, 685 class P4,
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 p2_(p2), 778 p2_(p2),
767 p3_(p3), 779 p3_(p3),
768 p4_(p4), 780 p4_(p4),
769 p5_(p5), 781 p5_(p5),
770 p6_(p6) {} 782 p6_(p6) {}
771 R operator()() const { 783 R operator()() const {
772 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_, p6_); } 784 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_, p6_); }
773 private: 785 private:
774 MethodT method_; 786 MethodT method_;
775 typename detail::PointerType<ObjectT>::type object_; 787 typename detail::PointerType<ObjectT>::type object_;
776 P1 p1_; 788 typename detail::RemoveScopedPtrRef<P1>::type p1_;
777 P2 p2_; 789 typename detail::RemoveScopedPtrRef<P2>::type p2_;
778 P3 p3_; 790 typename detail::RemoveScopedPtrRef<P3>::type p3_;
779 P4 p4_; 791 typename detail::RemoveScopedPtrRef<P4>::type p4_;
780 P5 p5_; 792 typename detail::RemoveScopedPtrRef<P5>::type p5_;
781 P6 p6_; 793 typename detail::RemoveScopedPtrRef<P6>::type p6_;
782 }; 794 };
783 795
784 template <class FunctorT, class R, 796 template <class FunctorT, class R,
785 class P1, 797 class P1,
786 class P2, 798 class P2,
787 class P3, 799 class P3,
788 class P4, 800 class P4,
789 class P5, 801 class P5,
790 class P6> 802 class P6>
791 class Functor6 { 803 class Functor6 {
792 public: 804 public:
793 Functor6(const FunctorT& functor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) 805 Functor6(const FunctorT& functor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
794 : functor_(functor), 806 : functor_(functor),
795 p1_(p1), 807 p1_(p1),
796 p2_(p2), 808 p2_(p2),
797 p3_(p3), 809 p3_(p3),
798 p4_(p4), 810 p4_(p4),
799 p5_(p5), 811 p5_(p5),
800 p6_(p6) {} 812 p6_(p6) {}
801 R operator()() const { 813 R operator()() const {
802 return functor_(p1_, p2_, p3_, p4_, p5_, p6_); } 814 return functor_(p1_, p2_, p3_, p4_, p5_, p6_); }
803 private: 815 private:
804 FunctorT functor_; 816 FunctorT functor_;
805 P1 p1_; 817 typename detail::RemoveScopedPtrRef<P1>::type p1_;
806 P2 p2_; 818 typename detail::RemoveScopedPtrRef<P2>::type p2_;
807 P3 p3_; 819 typename detail::RemoveScopedPtrRef<P3>::type p3_;
808 P4 p4_; 820 typename detail::RemoveScopedPtrRef<P4>::type p4_;
809 P5 p5_; 821 typename detail::RemoveScopedPtrRef<P5>::type p5_;
810 P6 p6_; 822 typename detail::RemoveScopedPtrRef<P6>::type p6_;
811 }; 823 };
812 824
813 825
814 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6) 826 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6)
815 827
816 template <class ObjectT, class R, 828 template <class ObjectT, class R,
817 class P1, 829 class P1,
818 class P2, 830 class P2,
819 class P3, 831 class P3,
820 class P4, 832 class P4,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 function, p1, p2, p3, p4, p5, p6); 910 function, p1, p2, p3, p4, p5, p6);
899 } 911 }
900 912
901 #undef FP_T 913 #undef FP_T
902 914
903 } // namespace rtc 915 } // namespace rtc
904 916
905 #undef NONAME 917 #undef NONAME
906 918
907 #endif // WEBRTC_BASE_BIND_H_ 919 #endif // WEBRTC_BASE_BIND_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/base/bind.h.pump » ('j') | webrtc/base/bind_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698