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_MEMORY_SCOPED_NSOBJECT_H_ | 5 #ifndef BASE_MAC_SCOPED_NSOBJECT_H_ |
6 #define BASE_MEMORY_SCOPED_NSOBJECT_H_ | 6 #define BASE_MAC_SCOPED_NSOBJECT_H_ |
7 | 7 |
8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 | 11 |
| 12 namespace base { |
| 13 |
12 // scoped_nsobject<> is patterned after scoped_ptr<>, but maintains ownership | 14 // scoped_nsobject<> is patterned after scoped_ptr<>, but maintains ownership |
13 // of an NSObject subclass object. Style deviations here are solely for | 15 // of an NSObject subclass object. Style deviations here are solely for |
14 // compatibility with scoped_ptr<>'s interface, with which everyone is already | 16 // compatibility with scoped_ptr<>'s interface, with which everyone is already |
15 // familiar. | 17 // familiar. |
16 // | 18 // |
17 // scoped_nsobject<> takes ownership of an object (in the constructor or in | 19 // scoped_nsobject<> takes ownership of an object (in the constructor or in |
18 // reset()) by taking over the caller's existing ownership claim. The caller | 20 // reset()) by taking over the caller's existing ownership claim. The caller |
19 // must own the object it gives to scoped_nsobject<>, and relinquishes an | 21 // must own the object it gives to scoped_nsobject<>, and relinquishes an |
20 // ownership claim to that object. scoped_nsobject<> does not call -retain, | 22 // ownership claim to that object. scoped_nsobject<> does not call -retain, |
21 // callers have to call this manually if appropriate. | 23 // callers have to call this manually if appropriate. |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 143 |
142 // Do not use scoped_nsobject for NSAutoreleasePools, use | 144 // Do not use scoped_nsobject for NSAutoreleasePools, use |
143 // ScopedNSAutoreleasePool instead. This is a compile time check. See details | 145 // ScopedNSAutoreleasePool instead. This is a compile time check. See details |
144 // at top of header. | 146 // at top of header. |
145 template<> | 147 template<> |
146 class scoped_nsobject<NSAutoreleasePool> { | 148 class scoped_nsobject<NSAutoreleasePool> { |
147 private: | 149 private: |
148 explicit scoped_nsobject(NSAutoreleasePool* object = nil); | 150 explicit scoped_nsobject(NSAutoreleasePool* object = nil); |
149 DISALLOW_COPY_AND_ASSIGN(scoped_nsobject); | 151 DISALLOW_COPY_AND_ASSIGN(scoped_nsobject); |
150 }; | 152 }; |
151 #endif // BASE_MEMORY_SCOPED_NSOBJECT_H_ | 153 |
| 154 } // namespace base |
| 155 |
| 156 #endif // BASE_MAC_SCOPED_NSOBJECT_H_ |
OLD | NEW |