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

Unified Diff: base/mac/bind_objc_block.h

Issue 708743002: Update base::BindBlock for three parameters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | « no previous file | base/mac/bind_objc_block_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/mac/bind_objc_block.h
diff --git a/base/mac/bind_objc_block.h b/base/mac/bind_objc_block.h
index 9deb2d22e75c5add2da220e47898060eca0f53b7..3aa7e0d7eef8772b683c38b868b1ee3a49c61b99 100644
--- a/base/mac/bind_objc_block.h
+++ b/base/mac/bind_objc_block.h
@@ -45,6 +45,12 @@ R RunBlock(base::mac::ScopedBlock<R(^)(A1, A2)> block, A1 a, A2 b) {
return extracted_block(a, b);
}
+template<typename R, typename A1, typename A2, typename A3>
+R RunBlock(base::mac::ScopedBlock<R(^)(A1, A2, A3)> block, A1 a, A2 b, A3 c) {
+ R(^extracted_block)(A1, A2, A3) = block.get();
+ return extracted_block(a, b, c);
Nico 2014/11/06 17:44:47 Can you make RunBlock() a variadic template? Then
marq (ping after 24h) 2014/11/07 09:00:55 Done, and BindBlock() is now also variadic.
+}
+
} // namespace internal
// Construct a callback with no argument from an objective-C block.
@@ -68,6 +74,14 @@ base::Callback<R(A1, A2)> BindBlock(R(^block)(A1, A2)) {
base::mac::ScopedBlock<R(^)(A1, A2)>(Block_copy(block)));
}
+// Construct a callback with three arguments from an objective-C block.
+template<typename R, typename A1, typename A2, typename A3>
+base::Callback<R(A1, A2, A3)> BindBlock(R(^block)(A1, A2, A3)) {
+ return base::Bind(&base::internal::RunBlock<R, A1, A2, A3>,
+ base::mac::ScopedBlock<R(^)(A1, A2, A3)>(
+ Block_copy(block)));
+}
+
} // namespace base
#endif // BASE_MAC_BIND_OBJC_BLOCK_H_
« no previous file with comments | « no previous file | base/mac/bind_objc_block_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698