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

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

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 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
« no previous file with comments | « base/mac/scoped_launch_data.h ('k') | base/mac/scoped_typeref.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_NSOBJECT_H_ 5 #ifndef BASE_MAC_SCOPED_NSOBJECT_H_
6 #define BASE_MAC_SCOPED_NSOBJECT_H_ 6 #define BASE_MAC_SCOPED_NSOBJECT_H_
7 7
8 #include <type_traits> 8 #include <type_traits>
9 9
10 // Include NSObject.h directly because Foundation.h pulls in many dependencies. 10 // Include NSObject.h directly because Foundation.h pulls in many dependencies.
11 // (Approx 100k lines of code versus 1.5k for NSObject.h). scoped_nsobject gets 11 // (Approx 100k lines of code versus 1.5k for NSObject.h). scoped_nsobject gets
12 // singled out because it is most typically included from other header files. 12 // singled out because it is most typically included from other header files.
13 #import <Foundation/NSObject.h> 13 #import <Foundation/NSObject.h>
14 14
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/mac/scoped_typeref.h" 16 #include "base/mac/scoped_typeref.h"
17 17
18 @class NSAutoreleasePool; 18 @class NSAutoreleasePool;
19 19
20 namespace base { 20 namespace base {
21 21
22 // scoped_nsobject<> is patterned after scoped_ptr<>, but maintains ownership 22 // scoped_nsobject<> is patterned after std::unique_ptr<>, but maintains
23 // of an NSObject subclass object. Style deviations here are solely for 23 // ownership of an NSObject subclass object. Style deviations here are solely
24 // compatibility with scoped_ptr<>'s interface, with which everyone is already 24 // for compatibility with std::unique_ptr<>'s interface, with which everyone is
25 // familiar. 25 // already familiar.
26 // 26 //
27 // scoped_nsobject<> takes ownership of an object (in the constructor or in 27 // scoped_nsobject<> takes ownership of an object (in the constructor or in
28 // reset()) by taking over the caller's existing ownership claim. The caller 28 // reset()) by taking over the caller's existing ownership claim. The caller
29 // must own the object it gives to scoped_nsobject<>, and relinquishes an 29 // must own the object it gives to scoped_nsobject<>, and relinquishes an
30 // ownership claim to that object. scoped_nsobject<> does not call -retain, 30 // ownership claim to that object. scoped_nsobject<> does not call -retain,
31 // callers have to call this manually if appropriate. 31 // callers have to call this manually if appropriate.
32 // 32 //
33 // scoped_nsprotocol<> has the same behavior as scoped_nsobject, but can be used 33 // scoped_nsprotocol<> has the same behavior as scoped_nsobject, but can be used
34 // with protocols. 34 // with protocols.
35 // 35 //
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // Specialization to make scoped_nsobject<id> work. 89 // Specialization to make scoped_nsobject<id> work.
90 template<> 90 template<>
91 class scoped_nsobject<id> : public scoped_nsprotocol<id> { 91 class scoped_nsobject<id> : public scoped_nsprotocol<id> {
92 public: 92 public:
93 using scoped_nsprotocol<id>::scoped_nsprotocol; 93 using scoped_nsprotocol<id>::scoped_nsprotocol;
94 }; 94 };
95 95
96 } // namespace base 96 } // namespace base
97 97
98 #endif // BASE_MAC_SCOPED_NSOBJECT_H_ 98 #endif // BASE_MAC_SCOPED_NSOBJECT_H_
OLDNEW
« no previous file with comments | « base/mac/scoped_launch_data.h ('k') | base/mac/scoped_typeref.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698