Skip to content

Commit

Permalink
Minor clean up for RefCountedThreadSafeBase
Browse files Browse the repository at this point in the history
* Remove unneeded const_cast in the HasOneRef.
* Move initial values of members to the declaration.

Review-Url: https://codereview.chromium.org/2723403003
Cr-Commit-Position: refs/heads/master@{#454335}
  • Loading branch information
tzik authored and Commit bot committed Mar 2, 2017
1 parent dd7a3b8 commit e3e3bda
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
9 changes: 2 additions & 7 deletions base/memory/ref_counted.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,10 @@ namespace base {
namespace subtle {

bool RefCountedThreadSafeBase::HasOneRef() const {
return AtomicRefCountIsOne(
&const_cast<RefCountedThreadSafeBase*>(this)->ref_count_);
return AtomicRefCountIsOne(&ref_count_);
}

RefCountedThreadSafeBase::RefCountedThreadSafeBase() : ref_count_(0) {
#if DCHECK_IS_ON()
in_dtor_ = false;
#endif
}
RefCountedThreadSafeBase::RefCountedThreadSafeBase() = default;

RefCountedThreadSafeBase::~RefCountedThreadSafeBase() {
#if DCHECK_IS_ON()
Expand Down
4 changes: 2 additions & 2 deletions base/memory/ref_counted.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ class BASE_EXPORT RefCountedThreadSafeBase {
bool Release() const;

private:
mutable AtomicRefCount ref_count_;
mutable AtomicRefCount ref_count_ = 0;
#if DCHECK_IS_ON()
mutable bool in_dtor_;
mutable bool in_dtor_ = false;
#endif

DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafeBase);
Expand Down

0 comments on commit e3e3bda

Please sign in to comment.