Chromium Code Reviews| 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 |