diff options
author | mbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-11 16:29:04 +0000 |
---|---|---|
committer | mbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-11 16:29:04 +0000 |
commit | 56835ecb2b31d9976754d95a5ba7e101cc6fab3f (patch) | |
tree | 7ae359cb34b09f40a40383678b201d2edb378629 /base/task.h | |
parent | ac09d34f5fa007f6a25c28641615f40e9a73cdb3 (diff) | |
download | chromium_src-56835ecb2b31d9976754d95a5ba7e101cc6fab3f.zip chromium_src-56835ecb2b31d9976754d95a5ba7e101cc6fab3f.tar.gz chromium_src-56835ecb2b31d9976754d95a5ba7e101cc6fab3f.tar.bz2 |
Change the ScopedRunnableMethodFactory to use CancelableTasks so that
callers can issue fine-grained Cancel() for individual tasks
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/802004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41279 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/task.h')
-rw-r--r-- | base/task.h | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/base/task.h b/base/task.h index 0af79a4..454878a 100644 --- a/base/task.h +++ b/base/task.h @@ -83,25 +83,26 @@ class ScopedRunnableMethodFactory { } template <class Method> - inline Task* NewRunnableMethod(Method method) { + inline CancelableTask* NewRunnableMethod(Method method) { return new RunnableMethod<Method, Tuple0>( weak_factory_.GetWeakPtr(), method, MakeTuple()); } template <class Method, class A> - inline Task* NewRunnableMethod(Method method, const A& a) { + inline CancelableTask* NewRunnableMethod(Method method, const A& a) { return new RunnableMethod<Method, Tuple1<A> >( weak_factory_.GetWeakPtr(), method, MakeTuple(a)); } template <class Method, class A, class B> - inline Task* NewRunnableMethod(Method method, const A& a, const B& b) { + inline CancelableTask* NewRunnableMethod(Method method, const A& a, + const B& b) { return new RunnableMethod<Method, Tuple2<A, B> >( weak_factory_.GetWeakPtr(), method, MakeTuple(a, b)); } template <class Method, class A, class B, class C> - inline Task* NewRunnableMethod(Method method, + inline CancelableTask* NewRunnableMethod(Method method, const A& a, const B& b, const C& c) { @@ -110,7 +111,7 @@ class ScopedRunnableMethodFactory { } template <class Method, class A, class B, class C, class D> - inline Task* NewRunnableMethod(Method method, + inline CancelableTask* NewRunnableMethod(Method method, const A& a, const B& b, const C& c, @@ -120,7 +121,7 @@ class ScopedRunnableMethodFactory { } template <class Method, class A, class B, class C, class D, class E> - inline Task* NewRunnableMethod(Method method, + inline CancelableTask* NewRunnableMethod(Method method, const A& a, const B& b, const C& c, @@ -136,9 +137,10 @@ class ScopedRunnableMethodFactory { protected: template <class Method, class Params> - class RunnableMethod : public Task { + class RunnableMethod : public CancelableTask { public: - RunnableMethod(const base::WeakPtr<T>& obj, Method meth, const Params& params) + RunnableMethod(const base::WeakPtr<T>& obj, Method meth, + const Params& params) : obj_(obj), meth_(meth), params_(params) { @@ -151,6 +153,10 @@ class ScopedRunnableMethodFactory { DispatchToMethod(obj_.get(), meth_, params_); } + virtual void Cancel() { + obj_.reset(); + } + private: base::WeakPtr<T> obj_; Method meth_; |