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

Unified Diff: base/mac/bind_objc_block.mm

Issue 10818034: Adding the possibility to build a closure from an ObjectiveC block. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Adding whitespace. Created 8 years, 5 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/mac/bind_objc_block.h ('k') | 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.mm
diff --git a/base/mac/bind_objc_block.mm b/base/mac/bind_objc_block.mm
new file mode 100644
index 0000000000000000000000000000000000000000..81472d09d25764e04a289f14d5885213d503afec
--- /dev/null
+++ b/base/mac/bind_objc_block.mm
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "base/mac/bind_objc_block.h"
+
+#include "base/bind.h"
+#include "base/memory/scoped_nsobject.h"
+
+namespace {
+
+// Run the block contained in the parameter.
+void RunBlock(scoped_nsobject<id> block) {
+ void(^extracted_block)() = block.get();
+ extracted_block();
+}
Mark Mentovai 2012/07/25 15:40:19 Won’t the scoped_nsobject<> destructor run here, d
stuartmorgan 2012/07/25 15:56:31 Bind is hard for mortals to understand, but AFAICT
+
+} // namespace
+
+namespace base {
+
+base::Closure BindBlock(void(^block)()) {
+ return base::Bind(&RunBlock, scoped_nsobject<id>([block copy]));
+}
+
+} // namespace base
« no previous file with comments | « base/mac/bind_objc_block.h ('k') | base/mac/bind_objc_block_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698