OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_MAC_BIND_OBJC_BLOCK_H_ | 5 #ifndef BASE_MAC_BIND_OBJC_BLOCK_H_ |
6 #define BASE_MAC_BIND_OBJC_BLOCK_H_ | 6 #define BASE_MAC_BIND_OBJC_BLOCK_H_ |
7 | 7 |
8 #include <Block.h> | 8 #include <Block.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 return extracted_block(args...); | 39 return extracted_block(args...); |
40 } | 40 } |
41 | 41 |
42 } // namespace internal | 42 } // namespace internal |
43 | 43 |
44 // Construct a callback from an objective-C block with up to six arguments (see | 44 // Construct a callback from an objective-C block with up to six arguments (see |
45 // note above). | 45 // note above). |
46 template<typename R, typename... Args> | 46 template<typename R, typename... Args> |
47 base::Callback<R(Args...)> BindBlock(R(^block)(Args...)) { | 47 base::Callback<R(Args...)> BindBlock(R(^block)(Args...)) { |
48 return base::Bind(&base::internal::RunBlock<R, Args...>, | 48 return base::Bind(&base::internal::RunBlock<R, Args...>, |
49 base::mac::ScopedBlock<R(^)(Args...)>(Block_copy(block))); | 49 base::mac::ScopedBlock<R (^)(Args...)>( |
| 50 base::mac::internal::ScopedBlockTraitsRetain(block))); |
50 } | 51 } |
51 | 52 |
52 } // namespace base | 53 } // namespace base |
53 | 54 |
54 #endif // BASE_MAC_BIND_OBJC_BLOCK_H_ | 55 #endif // BASE_MAC_BIND_OBJC_BLOCK_H_ |
OLD | NEW |