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

Side by Side Diff: base/ref_counted.h

Issue 248021: Reverting 27379. (Closed) Base URL: svn://chrome-svn/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
19 bool HasOneRef() const { return ref_count_ == 1; } 17 bool HasOneRef() const { return ref_count_ == 1; }
20 18
21 protected: 19 protected:
22 RefCountedBase(); 20 RefCountedBase();
23 ~RefCountedBase(); 21 ~RefCountedBase();
24 22
25 void AddRef(); 23 void AddRef();
26 24
27 // Returns true if the object should self-delete. 25 // Returns true if the object should self-delete.
28 bool Release(); 26 bool Release();
29 27
30 private: 28 private:
31 int ref_count_; 29 int ref_count_;
32 #ifndef NDEBUG 30 #ifndef NDEBUG
33 bool in_dtor_; 31 bool in_dtor_;
34 #endif 32 #endif
35 33
36 DFAKE_MUTEX(add_release_); 34 DFAKE_MUTEX(add_release_);
37 35
38 DISALLOW_COPY_AND_ASSIGN(RefCountedBase); 36 DISALLOW_COPY_AND_ASSIGN(RefCountedBase);
39 }; 37 };
40 38
41 class RefCountedThreadSafeBase { 39 class RefCountedThreadSafeBase {
42 public: 40 public:
43 static bool ImplementsThreadSafeReferenceCounting() { return true; }
44
45 bool HasOneRef() const; 41 bool HasOneRef() const;
46 42
47 protected: 43 protected:
48 RefCountedThreadSafeBase(); 44 RefCountedThreadSafeBase();
49 ~RefCountedThreadSafeBase(); 45 ~RefCountedThreadSafeBase();
50 46
51 void AddRef(); 47 void AddRef();
52 48
53 // Returns true if the object should self-delete. 49 // Returns true if the object should self-delete.
54 bool Release(); 50 bool Release();
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 239
244 void swap(scoped_refptr<T>& r) { 240 void swap(scoped_refptr<T>& r) {
245 swap(&r.ptr_); 241 swap(&r.ptr_);
246 } 242 }
247 243
248 protected: 244 protected:
249 T* ptr_; 245 T* ptr_;
250 }; 246 };
251 247
252 #endif // BASE_REF_COUNTED_H_ 248 #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