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_SCOPED_CFTYPEREF_H_ | 5 #ifndef BASE_MAC_SCOPED_CFTYPEREF_H_ |
6 #define BASE_MAC_SCOPED_CFTYPEREF_H_ | 6 #define BASE_MAC_SCOPED_CFTYPEREF_H_ |
7 | 7 |
8 #include <CoreFoundation/CoreFoundation.h> | 8 #include <CoreFoundation/CoreFoundation.h> |
9 | 9 |
10 #include "base/mac/scoped_typeref.h" | 10 #include "base/mac/scoped_typeref.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // call CFRetain(). This behavior is parameterized by the |OwnershipPolicy| | 23 // call CFRetain(). This behavior is parameterized by the |OwnershipPolicy| |
24 // enum. If the value |RETAIN| is passed (in the constructor or in reset()), | 24 // enum. If the value |RETAIN| is passed (in the constructor or in reset()), |
25 // then ScopedCFTypeRef<> will call CFRetain() on the object, and the initial | 25 // then ScopedCFTypeRef<> will call CFRetain() on the object, and the initial |
26 // ownership is not changed. | 26 // ownership is not changed. |
27 | 27 |
28 namespace internal { | 28 namespace internal { |
29 | 29 |
30 template<typename CFT> | 30 template<typename CFT> |
31 struct ScopedCFTypeRefTraits { | 31 struct ScopedCFTypeRefTraits { |
32 static CFT InvalidValue() { return nullptr; } | 32 static CFT InvalidValue() { return nullptr; } |
33 static void Retain(CFT object) { | 33 static CFT Retain(CFT object) { |
34 CFRetain(object); | 34 CFRetain(object); |
| 35 return object; |
35 } | 36 } |
36 static void Release(CFT object) { | 37 static void Release(CFT object) { |
37 CFRelease(object); | 38 CFRelease(object); |
38 } | 39 } |
39 }; | 40 }; |
40 | 41 |
41 } // namespace internal | 42 } // namespace internal |
42 | 43 |
43 template<typename CFT> | 44 template<typename CFT> |
44 using ScopedCFTypeRef = | 45 using ScopedCFTypeRef = |
45 ScopedTypeRef<CFT, internal::ScopedCFTypeRefTraits<CFT>>; | 46 ScopedTypeRef<CFT, internal::ScopedCFTypeRefTraits<CFT>>; |
46 | 47 |
47 } // namespace base | 48 } // namespace base |
48 | 49 |
49 #endif // BASE_MAC_SCOPED_CFTYPEREF_H_ | 50 #endif // BASE_MAC_SCOPED_CFTYPEREF_H_ |
OLD | NEW |