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

Unified Diff: base/memory/ref_counted.h

Issue 2366323003: Revert of Remove ref_counted.cc (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/BUILD.gn ('k') | base/memory/ref_counted.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/ref_counted.h
diff --git a/base/memory/ref_counted.h b/base/memory/ref_counted.h
index 16e993a230a6904aeba73aca404283a0a8765357..05fc4c4d3ff76e3554fbbbeff37b5d2856a9f242 100644
--- a/base/memory/ref_counted.h
+++ b/base/memory/ref_counted.h
@@ -87,46 +87,16 @@
class BASE_EXPORT RefCountedThreadSafeBase {
public:
- bool HasOneRef() const {
- return AtomicRefCountIsOne(
- &const_cast<RefCountedThreadSafeBase*>(this)->ref_count_);
- }
+ bool HasOneRef() const;
protected:
- RefCountedThreadSafeBase() : ref_count_(0) {
-#ifndef NDEBUG
- in_dtor_ = false;
-#endif
- }
-
- ~RefCountedThreadSafeBase() {
-#ifndef NDEBUG
- DCHECK(in_dtor_) << "RefCountedThreadSafe object deleted without "
- "calling Release()";
-#endif
- }
-
- void AddRef() const {
-#ifndef NDEBUG
- DCHECK(!in_dtor_);
-#endif
- AtomicRefCountInc(&ref_count_);
- }
+ RefCountedThreadSafeBase();
+ ~RefCountedThreadSafeBase();
+
+ void AddRef() const;
// Returns true if the object should self-delete.
- bool Release() const {
-#ifndef NDEBUG
- DCHECK(!in_dtor_);
- DCHECK(!AtomicRefCountIsZero(&ref_count_));
-#endif
- if (!AtomicRefCountDec(&ref_count_)) {
-#ifndef NDEBUG
- in_dtor_ = true;
-#endif
- return true;
- }
- return false;
- }
+ bool Release() const;
private:
mutable AtomicRefCount ref_count_;
« no previous file with comments | « base/BUILD.gn ('k') | base/memory/ref_counted.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698