| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_SCOPED_CFTYPEREF_H_ | 5 #ifndef BASE_SCOPED_CFTYPEREF_H_ |
| 6 #define BASE_SCOPED_CFTYPEREF_H_ | 6 #define BASE_SCOPED_CFTYPEREF_H_ |
| 7 | 7 |
| 8 #include <CoreFoundation/CoreFoundation.h> | 8 #include <CoreFoundation/CoreFoundation.h> |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 | 10 |
| 11 // scoped_cftyperef<> is patterned after scoped_ptr<>, but maintains ownership | 11 // scoped_cftyperef<> is patterned after scoped_ptr<>, but maintains ownership |
| 12 // of a CoreFoundation object: any object that can be represented as a | 12 // of a CoreFoundation object: any object that can be represented as a |
| 13 // CFTypeRef. Style deviations here are solely for compatibility with | 13 // CFTypeRef. Style deviations here are solely for compatibility with |
| 14 // scoped_ptr<>'s interface, with which everyone is already familiar. | 14 // scoped_ptr<>'s interface, with which everyone is already familiar. |
| 15 // |
| 16 // When scoped_cftyperef<> takes ownership of an object (in the constructor or |
| 17 // in reset()), it takes over the caller's existing ownership claim. The |
| 18 // caller must own the object. scoped_cftyperef<> does not call CFRetain(). |
| 15 template<typename CFT> | 19 template<typename CFT> |
| 16 class scoped_cftyperef { | 20 class scoped_cftyperef { |
| 17 public: | 21 public: |
| 18 typedef CFT element_type; | 22 typedef CFT element_type; |
| 19 | 23 |
| 20 explicit scoped_cftyperef(CFT object = NULL) | 24 explicit scoped_cftyperef(CFT object = NULL) |
| 21 : object_(object) { | 25 : object_(object) { |
| 22 } | 26 } |
| 23 | 27 |
| 24 ~scoped_cftyperef() { | 28 ~scoped_cftyperef() { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 return temp; | 69 return temp; |
| 66 } | 70 } |
| 67 | 71 |
| 68 private: | 72 private: |
| 69 CFT object_; | 73 CFT object_; |
| 70 | 74 |
| 71 DISALLOW_COPY_AND_ASSIGN(scoped_cftyperef); | 75 DISALLOW_COPY_AND_ASSIGN(scoped_cftyperef); |
| 72 }; | 76 }; |
| 73 | 77 |
| 74 #endif // BASE_SCOPED_CFTYPEREF_H_ | 78 #endif // BASE_SCOPED_CFTYPEREF_H_ |
| OLD | NEW |