diff options
author | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-30 09:09:34 +0000 |
---|---|---|
committer | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-30 09:09:34 +0000 |
commit | cea20fe4e5ee8e0b81c9d4f0ff7750cb8ef64aef (patch) | |
tree | 48ce1068ad3c94af442bdb9b373329ff3300ef5f /base/bind_internal.h | |
parent | f3f0da43dfff66771f894b48c45c8c567062244f (diff) | |
download | chromium_src-cea20fe4e5ee8e0b81c9d4f0ff7750cb8ef64aef.zip chromium_src-cea20fe4e5ee8e0b81c9d4f0ff7750cb8ef64aef.tar.gz chromium_src-cea20fe4e5ee8e0b81c9d4f0ff7750cb8ef64aef.tar.bz2 |
Allow Bind() to take a Callback<> and bind all its free parameters.
Basically, turns base::Callback<void(...)> to base::Closure.
It turns out there are a number of use caess where an API takes a callback, and then wants to invoke the Callback on another thread. This piece of syntactic sugar removes the need for custom helper functions.
This isn't quite full currying, however it is much simpler to implement.
BUG=87287
TEST=none
Review URL: http://codereview.chromium.org/8073012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103446 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/bind_internal.h')
-rw-r--r-- | base/bind_internal.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/base/bind_internal.h b/base/bind_internal.h index 17ce9c8..404b795 100644 --- a/base/bind_internal.h +++ b/base/bind_internal.h @@ -1721,6 +1721,47 @@ struct Invoker6<true, StorageType, void(T::*)(X1, X2, X3, X4, X5)> { } }; +// BindMoreFuncN<> +// +// This set of functions help in fully binding the free parameters in a +// Callback<>. +template <typename Sig, typename P1> +void BindMoreFunc1(const base::Callback<Sig>& callback, const P1& p1) { + callback.Run(p1); +} + +template <typename Sig, typename P1, typename P2> +void BindMoreFunc2(const base::Callback<Sig>& callback, const P1& p1, + const P2& p2) { + callback.Run(p1, p2); +} + +template <typename Sig, typename P1, typename P2, typename P3> +void BindMoreFunc3(const base::Callback<Sig>& callback, const P1& p1, + const P2& p2, const P3& p3) { + callback.Run(p1, p2, p3); +} + +template <typename Sig, typename P1, typename P2, typename P3, typename P4> +void BindMoreFunc4(const base::Callback<Sig>& callback, const P1& p1, + const P2& p2, const P3& p3, const P4& p4) { + callback.Run(p1, p2, p3, p4); +} + +template <typename Sig, typename P1, typename P2, typename P3, typename P4, + typename P5> +void BindMoreFunc5(const base::Callback<Sig>& callback, const P1& p1, + const P2& p2, const P3& p3, const P4& p4, const P5& p5) { + callback.Run(p1, p2, p3, p4, p5); +} + +template <typename Sig, typename P1, typename P2, typename P3, typename P4, + typename P5, typename P6> +void BindMoreFunc6(const base::Callback<Sig>& callback, const P1& p1, + const P2& p2, const P3& p3, const P4& p4, const P5& p5, const P6& p6) { + callback.Run(p1, p2, p3, p4, p5, p6); +} + // InvokerStorageN<> // // These are the actual storage classes for the Invokers. |