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

Side by Side Diff: base/memory/ref_counted_delete_on_sequence.h

Issue 2723423002: Start BindStateBase ref count from 1 instead of 0 (Closed)
Patch Set: s/MAKE_REF_COUNT_START_FROM_ONE/REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE()/ Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « base/memory/ref_counted.cc ('k') | base/memory/ref_counted_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_MEMORY_REF_COUNTED_DELETE_ON_SEQUENCE_H_ 5 #ifndef BASE_MEMORY_REF_COUNTED_DELETE_ON_SEQUENCE_H_
6 #define BASE_MEMORY_REF_COUNTED_DELETE_ON_SEQUENCE_H_ 6 #define BASE_MEMORY_REF_COUNTED_DELETE_ON_SEQUENCE_H_
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 15 matching lines...) Expand all
26 // ... 26 // ...
27 // private: 27 // private:
28 // friend class RefCountedDeleteOnSequence<Foo>; 28 // friend class RefCountedDeleteOnSequence<Foo>;
29 // friend class DeleteHelper<Foo>; 29 // friend class DeleteHelper<Foo>;
30 // 30 //
31 // ~Foo(); 31 // ~Foo();
32 // }; 32 // };
33 template <class T> 33 template <class T>
34 class RefCountedDeleteOnSequence : public subtle::RefCountedThreadSafeBase { 34 class RefCountedDeleteOnSequence : public subtle::RefCountedThreadSafeBase {
35 public: 35 public:
36 static constexpr subtle::StartRefCountFromZeroTag kRefCountPreference =
37 subtle::kStartRefCountFromZeroTag;
38
36 // A SequencedTaskRunner for the current sequence can be acquired by calling 39 // A SequencedTaskRunner for the current sequence can be acquired by calling
37 // SequencedTaskRunnerHandle::Get(). 40 // SequencedTaskRunnerHandle::Get().
38 RefCountedDeleteOnSequence(scoped_refptr<SequencedTaskRunner> task_runner) 41 RefCountedDeleteOnSequence(scoped_refptr<SequencedTaskRunner> task_runner)
39 : task_runner_(std::move(task_runner)) { 42 : subtle::RefCountedThreadSafeBase(T::kRefCountPreference),
43 task_runner_(std::move(task_runner)) {
40 DCHECK(task_runner_); 44 DCHECK(task_runner_);
41 } 45 }
42 46
43 void AddRef() const { subtle::RefCountedThreadSafeBase::AddRef(); } 47 void AddRef() const { subtle::RefCountedThreadSafeBase::AddRef(); }
44 48
45 void Release() const { 49 void Release() const {
46 if (subtle::RefCountedThreadSafeBase::Release()) 50 if (subtle::RefCountedThreadSafeBase::Release())
47 DestructOnSequence(); 51 DestructOnSequence();
48 } 52 }
49 53
(...skipping 11 matching lines...) Expand all
61 } 65 }
62 66
63 const scoped_refptr<SequencedTaskRunner> task_runner_; 67 const scoped_refptr<SequencedTaskRunner> task_runner_;
64 68
65 DISALLOW_COPY_AND_ASSIGN(RefCountedDeleteOnSequence); 69 DISALLOW_COPY_AND_ASSIGN(RefCountedDeleteOnSequence);
66 }; 70 };
67 71
68 } // namespace base 72 } // namespace base
69 73
70 #endif // BASE_MEMORY_REF_COUNTED_DELETE_ON_SEQUENCE_H_ 74 #endif // BASE_MEMORY_REF_COUNTED_DELETE_ON_SEQUENCE_H_
OLDNEW
« no previous file with comments | « base/memory/ref_counted.cc ('k') | base/memory/ref_counted_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698