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

Side by Side Diff: base/scoped_nsobject.h

Issue 3855001: Move scoped_cftyperef from base to base/mac, use the new namespace, and name ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « base/scoped_cftyperef.h ('k') | base/sys_string_conversions_mac.mm » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_NSOBJECT_H_ 5 #ifndef BASE_SCOPED_NSOBJECT_H_
6 #define BASE_SCOPED_NSOBJECT_H_ 6 #define BASE_SCOPED_NSOBJECT_H_
7 #pragma once 7 #pragma once
8 8
9 #import <Foundation/Foundation.h> 9 #import <Foundation/Foundation.h>
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 23 matching lines...) Expand all
34 explicit scoped_nsobject(NST* object = nil) 34 explicit scoped_nsobject(NST* object = nil)
35 : object_(object) { 35 : object_(object) {
36 } 36 }
37 37
38 ~scoped_nsobject() { 38 ~scoped_nsobject() {
39 [object_ release]; 39 [object_ release];
40 } 40 }
41 41
42 void reset(NST* object = nil) { 42 void reset(NST* object = nil) {
43 // We intentionally do not check that object != object_ as the caller must 43 // We intentionally do not check that object != object_ as the caller must
44 // already have an ownership claim over whatever it gives to scoped_nsobject 44 // already have an ownership claim over whatever it gives to
45 // and scoped_cftyperef, whether it's in the constructor or in a call to 45 // scoped_nsobject and ScopedCFTypeRef, whether it's in the constructor or
46 // reset(). In either case, it relinquishes that claim and the scoper 46 // in a call to reset(). In either case, it relinquishes that claim and
47 // assumes it. 47 // the scoper assumes it.
48 [object_ release]; 48 [object_ release];
49 object_ = object; 49 object_ = object;
50 } 50 }
51 51
52 bool operator==(NST* that) const { return object_ == that; } 52 bool operator==(NST* that) const { return object_ == that; }
53 bool operator!=(NST* that) const { return object_ != that; } 53 bool operator!=(NST* that) const { return object_ != that; }
54 54
55 operator NST*() const { 55 operator NST*() const {
56 return object_; 56 return object_;
57 } 57 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 explicit scoped_nsobject(id object = nil) 107 explicit scoped_nsobject(id object = nil)
108 : object_(object) { 108 : object_(object) {
109 } 109 }
110 110
111 ~scoped_nsobject() { 111 ~scoped_nsobject() {
112 [object_ release]; 112 [object_ release];
113 } 113 }
114 114
115 void reset(id object = nil) { 115 void reset(id object = nil) {
116 // We intentionally do not check that object != object_ as the caller must 116 // We intentionally do not check that object != object_ as the caller must
117 // already have an ownership claim over whatever it gives to scoped_nsobject 117 // already have an ownership claim over whatever it gives to
118 // and scoped_cftyperef, whether it's in the constructor or in a call to 118 // scoped_nsobject and ScopedCFTypeRef, whether it's in the constructor or
119 // reset(). In either case, it relinquishes that claim and the scoper 119 // in a call to reset(). In either case, it relinquishes that claim and
120 // assumes it. 120 // the scoper assumes it.
121 [object_ release]; 121 [object_ release];
122 object_ = object; 122 object_ = object;
123 } 123 }
124 124
125 bool operator==(id that) const { return object_ == that; } 125 bool operator==(id that) const { return object_ == that; }
126 bool operator!=(id that) const { return object_ != that; } 126 bool operator!=(id that) const { return object_ != that; }
127 127
128 operator id() const { 128 operator id() const {
129 return object_; 129 return object_;
130 } 130 }
(...skipping 27 matching lines...) Expand all
158 // ScopedNSAutoreleasePool instead. This is a compile time check. See details 158 // ScopedNSAutoreleasePool instead. This is a compile time check. See details
159 // at top of header. 159 // at top of header.
160 template<> 160 template<>
161 class scoped_nsobject<NSAutoreleasePool> { 161 class scoped_nsobject<NSAutoreleasePool> {
162 private: 162 private:
163 explicit scoped_nsobject(NSAutoreleasePool* object = nil); 163 explicit scoped_nsobject(NSAutoreleasePool* object = nil);
164 DISALLOW_COPY_AND_ASSIGN(scoped_nsobject); 164 DISALLOW_COPY_AND_ASSIGN(scoped_nsobject);
165 }; 165 };
166 166
167 #endif // BASE_SCOPED_NSOBJECT_H_ 167 #endif // BASE_SCOPED_NSOBJECT_H_
OLDNEW
« no previous file with comments | « base/scoped_cftyperef.h ('k') | base/sys_string_conversions_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698