Index: base/memory/ref_counted.cc |
diff --git a/base/memory/ref_counted.cc b/base/memory/ref_counted.cc |
index f5924d0fe76e44672ca24372f93b40d418f46b62..f7014a342182e511571e656e863b4a11a77b9fd0 100644 |
--- a/base/memory/ref_counted.cc |
+++ b/base/memory/ref_counted.cc |
@@ -9,6 +9,34 @@ namespace base { |
namespace subtle { |
+void RefCountedBase::AddRef() const { |
+ // TODO(maruel): Add back once it doesn't assert 500 times/sec. |
+ // Current thread books the critical section "AddRelease" |
+ // without release it. |
+ // DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_); |
+#ifndef NDEBUG |
+ DCHECK(!in_dtor_); |
+#endif |
+ ++ref_count_; |
+} |
+ |
+bool RefCountedBase::Release() const { |
+ // TODO(maruel): Add back once it doesn't assert 500 times/sec. |
+ // Current thread books the critical section "AddRelease" |
+ // without release it. |
+ // DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_); |
+#ifndef NDEBUG |
+ DCHECK(!in_dtor_); |
+#endif |
+ if (--ref_count_ == 0) { |
+#ifndef NDEBUG |
+ in_dtor_ = true; |
+#endif |
+ return true; |
+ } |
+ return false; |
+} |
+ |
bool RefCountedThreadSafeBase::HasOneRef() const { |
return AtomicRefCountIsOne( |
&const_cast<RefCountedThreadSafeBase*>(this)->ref_count_); |