OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/callback_internal.h" | 5 #include "base/callback_internal.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace base { | 9 namespace base { |
10 namespace internal { | 10 namespace internal { |
11 | 11 |
| 12 BindStateBase::BindStateBase(InvokeFuncStorage polymorphic_invoke, |
| 13 void (*destructor)(BindStateBase*)) |
| 14 : polymorphic_invoke_(polymorphic_invoke), |
| 15 ref_count_(0), destructor_(destructor) {} |
| 16 |
12 void BindStateBase::AddRef() { | 17 void BindStateBase::AddRef() { |
13 AtomicRefCountInc(&ref_count_); | 18 AtomicRefCountInc(&ref_count_); |
14 } | 19 } |
15 | 20 |
16 void BindStateBase::Release() { | 21 void BindStateBase::Release() { |
17 if (!AtomicRefCountDec(&ref_count_)) | 22 if (!AtomicRefCountDec(&ref_count_)) |
18 destructor_(this); | 23 destructor_(this); |
19 } | 24 } |
20 | 25 |
21 CallbackBase<CopyMode::MoveOnly>::CallbackBase(CallbackBase&& c) = default; | 26 CallbackBase<CopyMode::MoveOnly>::CallbackBase(CallbackBase&& c) = default; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 } | 62 } |
58 | 63 |
59 CallbackBase<CopyMode::Copyable>& | 64 CallbackBase<CopyMode::Copyable>& |
60 CallbackBase<CopyMode::Copyable>::operator=(CallbackBase&& c) = default; | 65 CallbackBase<CopyMode::Copyable>::operator=(CallbackBase&& c) = default; |
61 | 66 |
62 template class CallbackBase<CopyMode::MoveOnly>; | 67 template class CallbackBase<CopyMode::MoveOnly>; |
63 template class CallbackBase<CopyMode::Copyable>; | 68 template class CallbackBase<CopyMode::Copyable>; |
64 | 69 |
65 } // namespace internal | 70 } // namespace internal |
66 } // namespace base | 71 } // namespace base |
OLD | NEW |