OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/raw_scoped_refptr_mismatch_checker.h" | 9 #include "base/raw_scoped_refptr_mismatch_checker.h" |
10 #include "base/tracked.h" | 10 #include "base/tracked.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // } | 59 // } |
60 // | 60 // |
61 // void ScheduleSomeMethod() { | 61 // void ScheduleSomeMethod() { |
62 // // If you'd like to only only have one pending task at a time, test for | 62 // // If you'd like to only only have one pending task at a time, test for |
63 // // |empty| before manufacturing another task. | 63 // // |empty| before manufacturing another task. |
64 // if (!some_method_factory_.empty()) | 64 // if (!some_method_factory_.empty()) |
65 // return; | 65 // return; |
66 // | 66 // |
67 // // The factories are not thread safe, so always invoke on | 67 // // The factories are not thread safe, so always invoke on |
68 // // |MessageLoop::current()|. | 68 // // |MessageLoop::current()|. |
69 // MessageLoop::current()->PostDelayedTask(FROM_HERE, | 69 // MessageLoop::current()->PostDelayedTask( |
| 70 // FROM_HERE, |
70 // some_method_factory_.NewRunnableMethod(&MyClass::SomeMethod), | 71 // some_method_factory_.NewRunnableMethod(&MyClass::SomeMethod), |
71 // kSomeMethodDelayMS); | 72 // kSomeMethodDelayMS); |
72 // } | 73 // } |
73 // }; | 74 // }; |
74 | 75 |
75 // A ScopedRunnableMethodFactory creates runnable methods for a specified | 76 // A ScopedRunnableMethodFactory creates runnable methods for a specified |
76 // object. This is particularly useful for generating callbacks for | 77 // object. This is particularly useful for generating callbacks for |
77 // non-reference counted objects when the factory is a member of the object. | 78 // non-reference counted objects when the factory is a member of the object. |
78 template<class T> | 79 template<class T> |
79 class ScopedRunnableMethodFactory { | 80 class ScopedRunnableMethodFactory { |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 | 690 |
690 template <class T, typename ReturnValue> | 691 template <class T, typename ReturnValue> |
691 typename CallbackWithReturnValue<ReturnValue>::Type* | 692 typename CallbackWithReturnValue<ReturnValue>::Type* |
692 NewCallbackWithReturnValue(T* object, ReturnValue (T::*method)()) { | 693 NewCallbackWithReturnValue(T* object, ReturnValue (T::*method)()) { |
693 return new CallbackWithReturnValueImpl<T, ReturnValue (T::*)(), ReturnValue>( | 694 return new CallbackWithReturnValueImpl<T, ReturnValue (T::*)(), ReturnValue>( |
694 object, method); | 695 object, method); |
695 } | 696 } |
696 | 697 |
697 | 698 |
698 #endif // BASE_TASK_H_ | 699 #endif // BASE_TASK_H_ |
OLD | NEW |