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

Side by Side Diff: base/mac/scoped_block.h

Issue 1855483004: [iOS/OS X] Allow base::scoped_nsobject<> to be used when ARC is enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert changes to build/config/compiler/BUILD.gn Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_SCOPED_BLOCK_H_ 5 #ifndef BASE_MAC_SCOPED_BLOCK_H_
6 #define BASE_MAC_SCOPED_BLOCK_H_ 6 #define BASE_MAC_SCOPED_BLOCK_H_
7 7
8 #include <Block.h> 8 #include <Block.h>
9 9
10 #include "base/mac/scoped_typeref.h" 10 #include "base/mac/scoped_typeref.h"
11 11
12 namespace base { 12 namespace base {
13 namespace mac { 13 namespace mac {
14 14
15 namespace internal { 15 namespace internal {
16 16
17 id ScopedBlockTraitsRetain(id block);
Mark Mentovai 2016/04/05 00:09:15 Blocks are normally typed as const void*. If you u
18 void ScopedBlockTraitsRelease(id block);
19
17 template <typename B> 20 template <typename B>
18 struct ScopedBlockTraits { 21 struct ScopedBlockTraits {
19 static B InvalidValue() { return nullptr; } 22 static B InvalidValue() { return nullptr; }
20 static B Retain(B block) { return Block_copy(block); } 23 static B Retain(B block) { return ScopedBlockTraitsRetain(block); }
21 static void Release(B block) { Block_release(block); } 24 static void Release(B block) { ScopedBlockTraitsRelease(block); }
22 }; 25 };
23 26
24 } // namespace internal 27 } // namespace internal
25 28
26 // ScopedBlock<> is patterned after ScopedCFTypeRef<>, but uses Block_copy() and 29 // ScopedBlock<> is patterned after ScopedCFTypeRef<>, but uses Block_copy() and
27 // Block_release() instead of CFRetain() and CFRelease(). 30 // Block_release() instead of CFRetain() and CFRelease().
28 31
29 template <typename B> 32 template <typename B>
30 using ScopedBlock = ScopedTypeRef<B, internal::ScopedBlockTraits<B>>; 33 using ScopedBlock = ScopedTypeRef<B, internal::ScopedBlockTraits<B>>;
31 34
32 } // namespace mac 35 } // namespace mac
33 } // namespace base 36 } // namespace base
34 37
35 #endif // BASE_MAC_SCOPED_BLOCK_H_ 38 #endif // BASE_MAC_SCOPED_BLOCK_H_
OLDNEW
« no previous file with comments | « base/mac/bind_objc_block.h ('k') | base/mac/scoped_block.mm » ('j') | base/mac/scoped_block.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698