#include "base/functional/callback_internal.h"
#include "base/check.h"
#include "base/notreached.h"
#include "base/types/cxx23_to_underlying.h"
#include "arkweb/build/features/features.h"
#if BUILDFLAG(ARKWEB_CRASHPAD)
#include "base/logging.h"
#endif
namespace base::internal {
namespace {
bool QueryCancellationTraitsForNonCancellables(
const BindStateBase*,
BindStateBase::CancellationQueryMode mode) {
return to_underlying(mode);
}
}
void BindStateBaseRefCountTraits::Destruct(const BindStateBase* bind_state) {
bind_state->destructor_(bind_state);
}
BindStateBase::BindStateBase(InvokeFuncStorage polymorphic_invoke,
DestructorPtr destructor)
: BindStateBase(polymorphic_invoke,
destructor,
&QueryCancellationTraitsForNonCancellables) {}
BindStateBase::BindStateBase(
InvokeFuncStorage polymorphic_invoke,
DestructorPtr destructor,
QueryCancellationTraitsPtr query_cancellation_traits)
: polymorphic_invoke_(polymorphic_invoke),
destructor_(destructor),
query_cancellation_traits_(query_cancellation_traits) {}
BindStateHolder& BindStateHolder::operator=(BindStateHolder&&) noexcept =
default;
BindStateHolder::BindStateHolder(const BindStateHolder&) = default;
BindStateHolder& BindStateHolder::operator=(const BindStateHolder&) = default;
BindStateHolder::~BindStateHolder() = default;
void BindStateHolder::Reset() {
bind_state_ = nullptr;
}
bool BindStateHolder::IsCancelled() const {
DCHECK(bind_state_);
#if BUILDFLAG(ARKWEB_CRASHPAD)
if (bind_state_ == nullptr) {
LOG(WARNING) << "bind_state_ is nullptr";
return true;
}
#endif
return bind_state_->IsCancelled();
}
bool BindStateHolder::MaybeValid() const {
DCHECK(bind_state_);
return bind_state_->MaybeValid();
}
}