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

Unified Diff: base/bind.h.pump

Issue 8073012: Callback API Change: Allow Bind() to take a Callback<> and bind all its free parameters. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/bind.h ('k') | base/bind_internal.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/bind.h.pump
diff --git a/base/bind.h.pump b/base/bind.h.pump
index 62b313f666fcaabd4357e6bb1ef59e2d1053b284..eca00cdd0773edf9606a120f0fc431f7f9624887 100644
--- a/base/bind.h.pump
+++ b/base/bind.h.pump
@@ -63,6 +63,26 @@ $for BOUND_ARG , [[P$(BOUND_ARG)]]>(
}
]]
+]] $$ for BOUND
+
+// Specializations to allow binding all the free arguments in a
+// pre-existing base::Callback<>. This does not give full support for
+// currying, but is significantly simpler and addresses the use case
+// where a base::Callback<> needs to be invoked on another context/thread.
+$for BOUND [[
+$range BOUND_ARG 1..BOUND
+$if BOUND != 0 [[
+
+template <typename Sig, $for BOUND_ARG , [[typename P$(BOUND_ARG)]]>
+base::Closure Bind(const base::Callback<Sig>& callback, [[]]
+$for BOUND_ARG , [[const P$(BOUND_ARG)& p$(BOUND_ARG)]]) {
+ return base::Bind([[]]
+&internal::BindMoreFunc$(BOUND)<Sig, $for BOUND_ARG , [[P$(BOUND_ARG)]]>, [[]]
+callback, [[]]
+$for BOUND_ARG , [[p$(BOUND_ARG)]]);
+}
+
+]]
]] $$ for BOUND
« no previous file with comments | « base/bind.h ('k') | base/bind_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698