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

Side by Side Diff: third_party/protobuf/src/google/protobuf/stubs/callback.h

Issue 2600753002: Reverts third_party/protobuf: Update to HEAD (f52e188fe4) (Closed)
Patch Set: Created 3 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
OLDNEW
1 #ifndef GOOGLE_PROTOBUF_STUBS_CALLBACK_H_ 1 #ifndef GOOGLE_PROTOBUF_STUBS_CALLBACK_H_
2 #define GOOGLE_PROTOBUF_STUBS_CALLBACK_H_ 2 #define GOOGLE_PROTOBUF_STUBS_CALLBACK_H_
3 3
4 #include <google/protobuf/stubs/macros.h> 4 #include <google/protobuf/stubs/macros.h>
5 #include <google/protobuf/stubs/type_traits.h> 5 #include <google/protobuf/stubs/type_traits.h>
6 6
7 // =================================================================== 7 // ===================================================================
8 // emulates google3/base/callback.h 8 // emulates google3/base/callback.h
9 9
10 namespace google { 10 namespace google {
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 bool self_deleting_; 339 bool self_deleting_;
340 P1 p1_; 340 P1 p1_;
341 }; 341 };
342 342
343 template <typename T> 343 template <typename T>
344 struct InternalConstRef { 344 struct InternalConstRef {
345 typedef typename remove_reference<T>::type base_type; 345 typedef typename remove_reference<T>::type base_type;
346 typedef const base_type& type; 346 typedef const base_type& type;
347 }; 347 };
348 348
349 template<typename R, typename T>
350 class MethodResultCallback_0_0 : public ResultCallback<R> {
351 public:
352 typedef R (T::*MethodType)();
353 MethodResultCallback_0_0(T* object, MethodType method, bool self_deleting)
354 : object_(object),
355 method_(method),
356 self_deleting_(self_deleting) {}
357 ~MethodResultCallback_0_0() {}
358
359 R Run() {
360 bool needs_delete = self_deleting_;
361 R result = (object_->*method_)();
362 if (needs_delete) delete this;
363 return result;
364 }
365
366 private:
367 T* object_;
368 MethodType method_;
369 bool self_deleting_;
370 };
371
372 template <typename R, typename T, typename P1, typename P2, typename P3, 349 template <typename R, typename T, typename P1, typename P2, typename P3,
373 typename P4, typename P5, typename A1, typename A2> 350 typename P4, typename P5, typename A1, typename A2>
374 class MethodResultCallback_5_2 : public ResultCallback2<R, A1, A2> { 351 class MethodResultCallback_5_2 : public ResultCallback2<R, A1, A2> {
375 public: 352 public:
376 typedef R (T::*MethodType)(P1, P2, P3, P4, P5, A1, A2); 353 typedef R (T::*MethodType)(P1, P2, P3, P4, P5, A1, A2);
377 MethodResultCallback_5_2(T* object, MethodType method, bool self_deleting, 354 MethodResultCallback_5_2(T* object, MethodType method, bool self_deleting,
378 P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) 355 P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
379 : object_(object), 356 : object_(object),
380 method_(method), 357 method_(method),
381 self_deleting_(self_deleting), 358 self_deleting_(self_deleting),
(...skipping 15 matching lines...) Expand all
397 T* object_; 374 T* object_;
398 MethodType method_; 375 MethodType method_;
399 bool self_deleting_; 376 bool self_deleting_;
400 typename remove_reference<P1>::type p1_; 377 typename remove_reference<P1>::type p1_;
401 typename remove_reference<P2>::type p2_; 378 typename remove_reference<P2>::type p2_;
402 typename remove_reference<P3>::type p3_; 379 typename remove_reference<P3>::type p3_;
403 typename remove_reference<P4>::type p4_; 380 typename remove_reference<P4>::type p4_;
404 typename remove_reference<P5>::type p5_; 381 typename remove_reference<P5>::type p5_;
405 }; 382 };
406 383
407 } // namespace internal
408
409 // See Closure. 384 // See Closure.
410 inline Closure* NewCallback(void (*function)()) { 385 inline Closure* NewCallback(void (*function)()) {
411 return new internal::FunctionClosure0(function, true); 386 return new internal::FunctionClosure0(function, true);
412 } 387 }
413 388
414 // See Closure. 389 // See Closure.
415 inline Closure* NewPermanentCallback(void (*function)()) { 390 inline Closure* NewPermanentCallback(void (*function)()) {
416 return new internal::FunctionClosure0(function, false); 391 return new internal::FunctionClosure0(function, false);
417 } 392 }
418 393
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } 511 }
537 512
538 // See ResultCallback1 513 // See ResultCallback1
539 template<typename R, typename P1, typename A1> 514 template<typename R, typename P1, typename A1>
540 inline ResultCallback1<R, A1>* NewPermanentCallback( 515 inline ResultCallback1<R, A1>* NewPermanentCallback(
541 R (*function)(P1, A1), P1 p1) { 516 R (*function)(P1, A1), P1 p1) {
542 return new internal::FunctionResultCallback_1_1<R, P1, A1>( 517 return new internal::FunctionResultCallback_1_1<R, P1, A1>(
543 function, false, p1); 518 function, false, p1);
544 } 519 }
545 520
546 // See MethodResultCallback_0_0
547 template <typename R, typename T1, typename T2>
548 inline ResultCallback<R>* NewPermanentCallback(
549 T1* object, R (T2::*function)()) {
550 return new internal::MethodResultCallback_0_0<R, T1>(object, function, false);
551 }
552
553 // See MethodResultCallback_5_2 521 // See MethodResultCallback_5_2
554 template <typename R, typename T, typename P1, typename P2, typename P3, 522 template <typename R, typename T, typename P1, typename P2, typename P3,
555 typename P4, typename P5, typename A1, typename A2> 523 typename P4, typename P5, typename A1, typename A2>
556 inline ResultCallback2<R, A1, A2>* NewPermanentCallback( 524 inline ResultCallback2<R, A1, A2>* NewPermanentCallback(
557 T* object, R (T::*function)(P1, P2, P3, P4, P5, A1, A2), 525 T* object, R (T::*function)(P1, P2, P3, P4, P5, A1, A2),
558 typename internal::InternalConstRef<P1>::type p1, 526 typename internal::InternalConstRef<P1>::type p1,
559 typename internal::InternalConstRef<P2>::type p2, 527 typename internal::InternalConstRef<P2>::type p2,
560 typename internal::InternalConstRef<P3>::type p3, 528 typename internal::InternalConstRef<P3>::type p3,
561 typename internal::InternalConstRef<P4>::type p4, 529 typename internal::InternalConstRef<P4>::type p4,
562 typename internal::InternalConstRef<P5>::type p5) { 530 typename internal::InternalConstRef<P5>::type p5) {
563 return new internal::MethodResultCallback_5_2<R, T, P1, P2, P3, P4, P5, A1, 531 return new internal::MethodResultCallback_5_2<R, T, P1, P2, P3, P4, P5, A1,
564 A2>(object, function, false, p1, 532 A2>(object, function, false, p1,
565 p2, p3, p4, p5); 533 p2, p3, p4, p5);
566 } 534 }
567 535
536 } // namespace internal
537
568 // A function which does nothing. Useful for creating no-op callbacks, e.g.: 538 // A function which does nothing. Useful for creating no-op callbacks, e.g.:
569 // Closure* nothing = NewCallback(&DoNothing); 539 // Closure* nothing = NewCallback(&DoNothing);
570 void LIBPROTOBUF_EXPORT DoNothing(); 540 void LIBPROTOBUF_EXPORT DoNothing();
571 541
572 542
573 } // namespace protobuf 543 } // namespace protobuf
574 } // namespace google 544 } // namespace google
575 545
576 #endif // GOOGLE_PROTOBUF_STUBS_CALLBACK_H_ 546 #endif // GOOGLE_PROTOBUF_STUBS_CALLBACK_H_
OLDNEW
« no previous file with comments | « third_party/protobuf/src/google/protobuf/stubs/bytestream.h ('k') | third_party/protobuf/src/google/protobuf/stubs/common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698