Adding the possibility to build a closure from an ObjectiveC block.
[chromium-blink-merge.git] / base / mac / bind_objc_block.mm
blob81472d09d25764e04a289f14d5885213d503afec
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
3 // found in the LICENSE file.
5 #import "base/mac/bind_objc_block.h"
7 #include "base/bind.h"
8 #include "base/memory/scoped_nsobject.h"
10 namespace {
12 // Run the block contained in the parameter.
13 void RunBlock(scoped_nsobject<id> block) {
14   void(^extracted_block)() = block.get();
15   extracted_block();
18 }  // namespace
20 namespace base {
22 base::Closure BindBlock(void(^block)()) {
23   return base::Bind(&RunBlock, scoped_nsobject<id>([block copy]));
26 }  // namespace base