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/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_policy.h" | 12 #include "base/memory/scoped_policy.h" |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 namespace mac { | |
16 | 15 |
17 // ScopedCFTypeRef<> is patterned after scoped_ptr<>, but maintains ownership | 16 // ScopedCFTypeRef<> is patterned after scoped_ptr<>, but maintains ownership |
18 // of a CoreFoundation object: any object that can be represented as a | 17 // of a CoreFoundation object: any object that can be represented as a |
19 // CFTypeRef. Style deviations here are solely for compatibility with | 18 // CFTypeRef. Style deviations here are solely for compatibility with |
20 // scoped_ptr<>'s interface, with which everyone is already familiar. | 19 // scoped_ptr<>'s interface, with which everyone is already familiar. |
21 // | 20 // |
22 // By default, ScopedCFTypeRef<> takes ownership of an object (in the | 21 // By default, ScopedCFTypeRef<> takes ownership of an object (in the |
23 // constructor or in reset()) by taking over the caller's existing ownership | 22 // constructor or in reset()) by taking over the caller's existing ownership |
24 // claim. The caller must own the object it gives to ScopedCFTypeRef<>, and | 23 // claim. The caller must own the object it gives to ScopedCFTypeRef<>, and |
25 // relinquishes an ownership claim to that object. ScopedCFTypeRef<> does not | 24 // relinquishes an ownership claim to that object. ScopedCFTypeRef<> does not |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 CFT release() WARN_UNUSED_RESULT { | 94 CFT release() WARN_UNUSED_RESULT { |
96 CFT temp = object_; | 95 CFT temp = object_; |
97 object_ = NULL; | 96 object_ = NULL; |
98 return temp; | 97 return temp; |
99 } | 98 } |
100 | 99 |
101 private: | 100 private: |
102 CFT object_; | 101 CFT object_; |
103 }; | 102 }; |
104 | 103 |
| 104 // TODO(thakis): Remove this once all clients use base::ScopedCFTypeRef |
| 105 // directly. |
| 106 namespace mac { |
| 107 using base::ScopedCFTypeRef; |
105 } // namespace mac | 108 } // namespace mac |
| 109 |
106 } // namespace base | 110 } // namespace base |
107 | 111 |
108 #endif // BASE_MAC_SCOPED_CFTYPEREF_H_ | 112 #endif // BASE_MAC_SCOPED_CFTYPEREF_H_ |
OLD | NEW |