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

Side by Side Diff: base/ref_counted.h

Issue 246027: Reverting 27389. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 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/message_pump_glib_unittest.cc ('k') | base/task.h » ('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) 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/thread_collision_warner.h" 9 #include "base/thread_collision_warner.h"
10 10
11 namespace base { 11 namespace base {
12 12
13 namespace subtle { 13 namespace subtle {
14 14
15 class RefCountedBase { 15 class RefCountedBase {
16 public: 16 public:
17 static bool ImplementsThreadSafeReferenceCounting() { return false; }
18
17 bool HasOneRef() const { return ref_count_ == 1; } 19 bool HasOneRef() const { return ref_count_ == 1; }
18 20
19 protected: 21 protected:
20 RefCountedBase(); 22 RefCountedBase();
21 ~RefCountedBase(); 23 ~RefCountedBase();
22 24
23 void AddRef(); 25 void AddRef();
24 26
25 // Returns true if the object should self-delete. 27 // Returns true if the object should self-delete.
26 bool Release(); 28 bool Release();
27 29
28 private: 30 private:
29 int ref_count_; 31 int ref_count_;
30 #ifndef NDEBUG 32 #ifndef NDEBUG
31 bool in_dtor_; 33 bool in_dtor_;
32 #endif 34 #endif
33 35
34 DFAKE_MUTEX(add_release_); 36 DFAKE_MUTEX(add_release_);
35 37
36 DISALLOW_COPY_AND_ASSIGN(RefCountedBase); 38 DISALLOW_COPY_AND_ASSIGN(RefCountedBase);
37 }; 39 };
38 40
39 class RefCountedThreadSafeBase { 41 class RefCountedThreadSafeBase {
40 public: 42 public:
43 static bool ImplementsThreadSafeReferenceCounting() { return true; }
44
41 bool HasOneRef() const; 45 bool HasOneRef() const;
42 46
43 protected: 47 protected:
44 RefCountedThreadSafeBase(); 48 RefCountedThreadSafeBase();
45 ~RefCountedThreadSafeBase(); 49 ~RefCountedThreadSafeBase();
46 50
47 void AddRef(); 51 void AddRef();
48 52
49 // Returns true if the object should self-delete. 53 // Returns true if the object should self-delete.
50 bool Release(); 54 bool Release();
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 243
240 void swap(scoped_refptr<T>& r) { 244 void swap(scoped_refptr<T>& r) {
241 swap(&r.ptr_); 245 swap(&r.ptr_);
242 } 246 }
243 247
244 protected: 248 protected:
245 T* ptr_; 249 T* ptr_;
246 }; 250 };
247 251
248 #endif // BASE_REF_COUNTED_H_ 252 #endif // BASE_REF_COUNTED_H_
OLDNEW
« no previous file with comments | « base/message_pump_glib_unittest.cc ('k') | base/task.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698