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

Unified Diff: base/callback_internal.cc

Issue 2723423002: Start BindStateBase ref count from 1 instead of 0 (Closed)
Patch Set: +test 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
« no previous file with comments | « no previous file | base/memory/ref_counted.h » ('j') | base/memory/ref_counted.h » ('J')
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 3a665d28cae8fc6d5280acad88313de0a8a8ec41..5a83bfa50ec3369c622efa6f1d305af4355a7c61 100644
--- a/base/callback_internal.cc
+++ b/base/callback_internal.cc
@@ -29,7 +29,8 @@ BindStateBase::BindStateBase(InvokeFuncStorage polymorphic_invoke,
BindStateBase::BindStateBase(InvokeFuncStorage polymorphic_invoke,
void (*destructor)(const BindStateBase*),
bool (*is_cancelled)(const BindStateBase*))
- : polymorphic_invoke_(polymorphic_invoke),
+ : RefCountedThreadSafe(1 /* initial_ref_count */),
+ polymorphic_invoke_(polymorphic_invoke),
destructor_(destructor),
is_cancelled_(is_cancelled) {}
@@ -74,9 +75,8 @@ bool CallbackBase<CopyMode::MoveOnly>::EqualsInternal(
return bind_state_ == other.bind_state_;
}
-CallbackBase<CopyMode::MoveOnly>::CallbackBase(
- BindStateBase* bind_state)
- : bind_state_(bind_state) {
+CallbackBase<CopyMode::MoveOnly>::CallbackBase(BindStateBase* bind_state)
+ : bind_state_(AdoptRef(bind_state)) {
DCHECK(!bind_state_.get() || bind_state_->HasOneRef());
}
« no previous file with comments | « no previous file | base/memory/ref_counted.h » ('j') | base/memory/ref_counted.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698