OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_REF_COUNTED_H_ | 5 #ifndef BASE_REF_COUNTED_H_ |
6 #define BASE_REF_COUNTED_H_ | 6 #define BASE_REF_COUNTED_H_ |
7 | 7 |
8 #include "base/atomic_ref_count.h" | 8 #include "base/atomic_ref_count.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/thread_collision_warner.h" |
10 | 11 |
11 namespace base { | 12 namespace base { |
12 | 13 |
13 namespace subtle { | 14 namespace subtle { |
14 | 15 |
15 class RefCountedBase { | 16 class RefCountedBase { |
16 protected: | 17 protected: |
17 RefCountedBase(); | 18 RefCountedBase(); |
18 ~RefCountedBase(); | 19 ~RefCountedBase(); |
19 | 20 |
20 void AddRef(); | 21 void AddRef(); |
21 | 22 |
22 // Returns true if the object should self-delete. | 23 // Returns true if the object should self-delete. |
23 bool Release(); | 24 bool Release(); |
24 | 25 |
25 private: | 26 private: |
26 int ref_count_; | 27 int ref_count_; |
27 #ifndef NDEBUG | 28 #ifndef NDEBUG |
28 bool in_dtor_; | 29 bool in_dtor_; |
29 #endif | 30 #endif |
30 | 31 |
| 32 DFAKE_MUTEX(add_release_); |
| 33 |
31 DISALLOW_COPY_AND_ASSIGN(RefCountedBase); | 34 DISALLOW_COPY_AND_ASSIGN(RefCountedBase); |
32 }; | 35 }; |
33 | 36 |
34 class RefCountedThreadSafeBase { | 37 class RefCountedThreadSafeBase { |
35 protected: | 38 protected: |
36 RefCountedThreadSafeBase(); | 39 RefCountedThreadSafeBase(); |
37 ~RefCountedThreadSafeBase(); | 40 ~RefCountedThreadSafeBase(); |
38 | 41 |
39 void AddRef(); | 42 void AddRef(); |
40 | 43 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 223 |
221 void swap(scoped_refptr<T>& r) { | 224 void swap(scoped_refptr<T>& r) { |
222 swap(&r.ptr_); | 225 swap(&r.ptr_); |
223 } | 226 } |
224 | 227 |
225 protected: | 228 protected: |
226 T* ptr_; | 229 T* ptr_; |
227 }; | 230 }; |
228 | 231 |
229 #endif // BASE_REF_COUNTED_H_ | 232 #endif // BASE_REF_COUNTED_H_ |
OLD | NEW |