| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 BASE_TASK_H_ | 5 #ifndef BASE_TASK_H_ |
| 6 #define BASE_TASK_H_ | 6 #define BASE_TASK_H_ |
| 7 | 7 |
| 8 #include "base/non_thread_safe.h" | 8 #include "base/non_thread_safe.h" |
| 9 #include "base/revocable_store.h" | 9 #include "base/revocable_store.h" |
| 10 #include "base/tracked.h" | 10 #include "base/tracked.h" |
| 11 #include "base/tuple.h" | 11 #include "base/tuple.h" |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 private: | 671 private: |
| 672 Method m_; | 672 Method m_; |
| 673 Params p_; | 673 Params p_; |
| 674 }; | 674 }; |
| 675 | 675 |
| 676 // Return value implementation with no args. | 676 // Return value implementation with no args. |
| 677 template <typename ReturnValue> | 677 template <typename ReturnValue> |
| 678 struct CallbackWithReturnValue { | 678 struct CallbackWithReturnValue { |
| 679 class Type { | 679 class Type { |
| 680 public: | 680 public: |
| 681 virtual ~Type() {} | |
| 682 virtual ReturnValue Run() = 0; | 681 virtual ReturnValue Run() = 0; |
| 683 }; | 682 }; |
| 684 }; | 683 }; |
| 685 | 684 |
| 686 template <class T, typename Method, typename ReturnValue> | 685 template <class T, typename Method, typename ReturnValue> |
| 687 class CallbackWithReturnValueImpl | 686 class CallbackWithReturnValueImpl |
| 688 : public CallbackStorage<T, Method>, | 687 : public CallbackStorage<T, Method>, |
| 689 public CallbackWithReturnValue<ReturnValue>::Type { | 688 public CallbackWithReturnValue<ReturnValue>::Type { |
| 690 public: | 689 public: |
| 691 CallbackWithReturnValueImpl(T* obj, Method meth) | 690 CallbackWithReturnValueImpl(T* obj, Method meth) |
| 692 : CallbackStorage<T, Method>(obj, meth) {} | 691 : CallbackStorage<T, Method>(obj, meth) {} |
| 693 | 692 |
| 694 virtual ReturnValue Run() { | 693 virtual ReturnValue Run() { |
| 695 return (this->obj_->*(this->meth_))(); | 694 return (this->obj_->*(this->meth_))(); |
| 696 } | 695 } |
| 697 | |
| 698 protected: | |
| 699 ~CallbackWithReturnValueImpl() {} | |
| 700 }; | 696 }; |
| 701 | 697 |
| 702 template <class T, typename ReturnValue> | 698 template <class T, typename ReturnValue> |
| 703 typename CallbackWithReturnValue<ReturnValue>::Type* | 699 typename CallbackWithReturnValue<ReturnValue>::Type* |
| 704 NewCallbackWithReturnValue(T* object, ReturnValue (T::*method)()) { | 700 NewCallbackWithReturnValue(T* object, ReturnValue (T::*method)()) { |
| 705 return new CallbackWithReturnValueImpl<T, ReturnValue (T::*)(), ReturnValue>( | 701 return new CallbackWithReturnValueImpl<T, ReturnValue (T::*)(), ReturnValue>( |
| 706 object, method); | 702 object, method); |
| 707 } | 703 } |
| 708 | 704 |
| 709 | 705 |
| 710 #endif // BASE_TASK_H_ | 706 #endif // BASE_TASK_H_ |
| OLD | NEW |