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_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 13 matching lines...) Expand all Loading... | |
24 | 24 |
25 protected: | 25 protected: |
26 RefCountedBase(); | 26 RefCountedBase(); |
27 ~RefCountedBase(); | 27 ~RefCountedBase(); |
28 | 28 |
29 void AddRef() const; | 29 void AddRef() const; |
30 | 30 |
31 // Returns true if the object should self-delete. | 31 // Returns true if the object should self-delete. |
32 bool Release() const; | 32 bool Release() const; |
33 | 33 |
34 private: | 34 public: |
dominich
2012/06/18 15:32:44
no.
| |
35 mutable int ref_count_; | 35 mutable int ref_count_; |
36 #ifndef NDEBUG | 36 #ifndef NDEBUG |
37 mutable bool in_dtor_; | 37 mutable bool in_dtor_; |
38 #endif | 38 #endif |
39 | 39 |
40 DFAKE_MUTEX(add_release_); | 40 DFAKE_MUTEX(add_release_); |
41 | 41 |
42 DISALLOW_COPY_AND_ASSIGN(RefCountedBase); | 42 DISALLOW_COPY_AND_ASSIGN(RefCountedBase); |
43 }; | 43 }; |
44 | 44 |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 }; | 296 }; |
297 | 297 |
298 // Handy utility for creating a scoped_refptr<T> out of a T* explicitly without | 298 // Handy utility for creating a scoped_refptr<T> out of a T* explicitly without |
299 // having to retype all the template arguments | 299 // having to retype all the template arguments |
300 template <typename T> | 300 template <typename T> |
301 scoped_refptr<T> make_scoped_refptr(T* t) { | 301 scoped_refptr<T> make_scoped_refptr(T* t) { |
302 return scoped_refptr<T>(t); | 302 return scoped_refptr<T>(t); |
303 } | 303 } |
304 | 304 |
305 #endif // BASE_MEMORY_REF_COUNTED_H_ | 305 #endif // BASE_MEMORY_REF_COUNTED_H_ |
OLD | NEW |