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

Unified Diff: base/callback_internal.cc

Issue 2747673002: Use base::RefCountedThreadSafe on BindStateBase (Closed)
Patch Set: fix Created 3 years, 9 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
« base/callback_internal.h ('K') | « base/callback_internal.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/callback_internal.cc
diff --git a/base/callback_internal.cc b/base/callback_internal.cc
index 4330e9cce511a5d819b85fe128c3ba5bc46eaf9e..3a665d28cae8fc6d5280acad88313de0a8a8ec41 100644
--- a/base/callback_internal.cc
+++ b/base/callback_internal.cc
@@ -17,6 +17,10 @@ bool ReturnFalse(const BindStateBase*) {
} // namespace
+void BindStateBaseRefCountTraits::Destruct(const BindStateBase* bind_state) {
+ bind_state->destructor_(bind_state);
+}
+
BindStateBase::BindStateBase(InvokeFuncStorage polymorphic_invoke,
void (*destructor)(const BindStateBase*))
: BindStateBase(polymorphic_invoke, destructor, &ReturnFalse) {
@@ -26,19 +30,9 @@ BindStateBase::BindStateBase(InvokeFuncStorage polymorphic_invoke,
void (*destructor)(const BindStateBase*),
bool (*is_cancelled)(const BindStateBase*))
: polymorphic_invoke_(polymorphic_invoke),
- ref_count_(0),
destructor_(destructor),
is_cancelled_(is_cancelled) {}
-void BindStateBase::AddRef() const {
- AtomicRefCountInc(&ref_count_);
-}
-
-void BindStateBase::Release() const {
- if (!AtomicRefCountDec(&ref_count_))
- destructor_(this);
-}
-
CallbackBase<CopyMode::MoveOnly>::CallbackBase(CallbackBase&& c) = default;
CallbackBase<CopyMode::MoveOnly>&
@@ -83,7 +77,7 @@ bool CallbackBase<CopyMode::MoveOnly>::EqualsInternal(
CallbackBase<CopyMode::MoveOnly>::CallbackBase(
BindStateBase* bind_state)
: bind_state_(bind_state) {
- DCHECK(!bind_state_.get() || bind_state_->ref_count_ == 1);
+ DCHECK(!bind_state_.get() || bind_state_->HasOneRef());
}
CallbackBase<CopyMode::MoveOnly>::~CallbackBase() {}
« base/callback_internal.h ('K') | « base/callback_internal.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698