1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/functional/callback_internal.h"
7 #include "base/check.h"
8 #include "base/notreached.h"
15 bool QueryCancellationTraitsForNonCancellables(
17 BindStateBase::CancellationQueryMode mode) {
19 case BindStateBase::IS_CANCELLED:
21 case BindStateBase::MAYBE_VALID:
29 void BindStateBaseRefCountTraits::Destruct(const BindStateBase* bind_state) {
30 bind_state->destructor_(bind_state);
33 BindStateBase::BindStateBase(InvokeFuncStorage polymorphic_invoke,
34 void (*destructor)(const BindStateBase*))
35 : BindStateBase(polymorphic_invoke,
37 &QueryCancellationTraitsForNonCancellables) {}
39 BindStateBase::BindStateBase(
40 InvokeFuncStorage polymorphic_invoke,
41 void (*destructor)(const BindStateBase*),
42 bool (*query_cancellation_traits)(const BindStateBase*,
43 CancellationQueryMode))
44 : polymorphic_invoke_(polymorphic_invoke),
45 destructor_(destructor),
46 query_cancellation_traits_(query_cancellation_traits) {}
48 BindStateHolder& BindStateHolder::operator=(BindStateHolder&&) noexcept =
51 BindStateHolder::BindStateHolder(const BindStateHolder&) = default;
53 BindStateHolder& BindStateHolder::operator=(const BindStateHolder&) = default;
55 BindStateHolder::~BindStateHolder() = default;
57 void BindStateHolder::Reset() {
58 bind_state_ = nullptr;
61 bool BindStateHolder::IsCancelled() const {
63 return bind_state_->IsCancelled();
66 bool BindStateHolder::MaybeValid() const {
68 return bind_state_->MaybeValid();
71 } // namespace internal