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