Fix emulator build error
[platform/framework/web/chromium-efl.git] / base / functional / callback_internal.cc
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.
4
5 #include "base/functional/callback_internal.h"
6
7 #include "base/check.h"
8 #include "base/notreached.h"
9
10 namespace base {
11 namespace internal {
12
13 namespace {
14
15 bool QueryCancellationTraitsForNonCancellables(
16     const BindStateBase*,
17     BindStateBase::CancellationQueryMode mode) {
18   switch (mode) {
19     case BindStateBase::IS_CANCELLED:
20       return false;
21     case BindStateBase::MAYBE_VALID:
22       return true;
23   }
24   NOTREACHED();
25 }
26
27 }  // namespace
28
29 void BindStateBaseRefCountTraits::Destruct(const BindStateBase* bind_state) {
30   bind_state->destructor_(bind_state);
31 }
32
33 BindStateBase::BindStateBase(InvokeFuncStorage polymorphic_invoke,
34                              void (*destructor)(const BindStateBase*))
35     : BindStateBase(polymorphic_invoke,
36                     destructor,
37                     &QueryCancellationTraitsForNonCancellables) {}
38
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) {}
47
48 BindStateHolder& BindStateHolder::operator=(BindStateHolder&&) noexcept =
49     default;
50
51 BindStateHolder::BindStateHolder(const BindStateHolder&) = default;
52
53 BindStateHolder& BindStateHolder::operator=(const BindStateHolder&) = default;
54
55 BindStateHolder::~BindStateHolder() = default;
56
57 void BindStateHolder::Reset() {
58   bind_state_ = nullptr;
59 }
60
61 bool BindStateHolder::IsCancelled() const {
62   DCHECK(bind_state_);
63   return bind_state_->IsCancelled();
64 }
65
66 bool BindStateHolder::MaybeValid() const {
67   DCHECK(bind_state_);
68   return bind_state_->MaybeValid();
69 }
70
71 }  // namespace internal
72 }  // namespace base