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

Side by Side Diff: base/memory/ref_counted.h

Issue 10416003: RefCounted types should not have public destructors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One more fix Created 8 years, 6 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 | « no previous file | chrome/browser/net/load_timing_observer.cc » ('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_MEMORY_REF_COUNTED_H_ 5 #ifndef BASE_MEMORY_REF_COUNTED_H_
6 #define BASE_MEMORY_REF_COUNTED_H_ 6 #define BASE_MEMORY_REF_COUNTED_H_
7 #pragma once 7 #pragma once
8 8
9 #include <cassert> 9 #include <cassert>
10 10
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // A wrapper for some piece of data so we can place other things in 157 // A wrapper for some piece of data so we can place other things in
158 // scoped_refptrs<>. 158 // scoped_refptrs<>.
159 // 159 //
160 template<typename T> 160 template<typename T>
161 class RefCountedData : public base::RefCounted< base::RefCountedData<T> > { 161 class RefCountedData : public base::RefCounted< base::RefCountedData<T> > {
162 public: 162 public:
163 RefCountedData() : data() {} 163 RefCountedData() : data() {}
164 RefCountedData(const T& in_value) : data(in_value) {} 164 RefCountedData(const T& in_value) : data(in_value) {}
165 165
166 T data; 166 T data;
167
168 private:
169 friend class base::RefCounted<base::RefCountedData<T> >;
170 ~RefCountedData() {}
167 }; 171 };
168 172
169 } // namespace base 173 } // namespace base
170 174
171 // 175 //
172 // A smart pointer class for reference counted objects. Use this class instead 176 // A smart pointer class for reference counted objects. Use this class instead
173 // of calling AddRef and Release manually on a reference counted object to 177 // of calling AddRef and Release manually on a reference counted object to
174 // avoid common memory leaks caused by forgetting to Release an object 178 // avoid common memory leaks caused by forgetting to Release an object
175 // reference. Sample usage: 179 // reference. Sample usage:
176 // 180 //
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 }; 302 };
299 303
300 // Handy utility for creating a scoped_refptr<T> out of a T* explicitly without 304 // Handy utility for creating a scoped_refptr<T> out of a T* explicitly without
301 // having to retype all the template arguments 305 // having to retype all the template arguments
302 template <typename T> 306 template <typename T>
303 scoped_refptr<T> make_scoped_refptr(T* t) { 307 scoped_refptr<T> make_scoped_refptr(T* t) {
304 return scoped_refptr<T>(t); 308 return scoped_refptr<T>(t);
305 } 309 }
306 310
307 #endif // BASE_MEMORY_REF_COUNTED_H_ 311 #endif // BASE_MEMORY_REF_COUNTED_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/load_timing_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698