Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/security/sandbox/chromium/base/callback_internal.cc
Line
Count
Source (jump to first uncovered line)
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
3
// found in the LICENSE file.
4
5
#include "base/callback_internal.h"
6
7
#include "base/logging.h"
8
9
namespace base {
10
namespace internal {
11
12
namespace {
13
14
0
bool ReturnFalse(const BindStateBase*) {
15
0
  return false;
16
0
}
17
18
}  // namespace
19
20
0
void BindStateBaseRefCountTraits::Destruct(const BindStateBase* bind_state) {
21
0
  bind_state->destructor_(bind_state);
22
0
}
23
24
BindStateBase::BindStateBase(InvokeFuncStorage polymorphic_invoke,
25
                             void (*destructor)(const BindStateBase*))
26
0
    : BindStateBase(polymorphic_invoke, destructor, &ReturnFalse) {
27
0
}
28
29
BindStateBase::BindStateBase(InvokeFuncStorage polymorphic_invoke,
30
                             void (*destructor)(const BindStateBase*),
31
                             bool (*is_cancelled)(const BindStateBase*))
32
    : polymorphic_invoke_(polymorphic_invoke),
33
      destructor_(destructor),
34
0
      is_cancelled_(is_cancelled) {}
35
36
0
CallbackBase::CallbackBase(CallbackBase&& c) = default;
37
0
CallbackBase& CallbackBase::operator=(CallbackBase&& c) = default;
38
CallbackBase::CallbackBase(const CallbackBaseCopyable& c)
39
0
    : bind_state_(c.bind_state_) {}
40
41
0
CallbackBase& CallbackBase::operator=(const CallbackBaseCopyable& c) {
42
0
  bind_state_ = c.bind_state_;
43
0
  return *this;
44
0
}
45
46
CallbackBase::CallbackBase(CallbackBaseCopyable&& c)
47
0
    : bind_state_(std::move(c.bind_state_)) {}
48
49
0
CallbackBase& CallbackBase::operator=(CallbackBaseCopyable&& c) {
50
0
  bind_state_ = std::move(c.bind_state_);
51
0
  return *this;
52
0
}
53
54
0
void CallbackBase::Reset() {
55
0
  // NULL the bind_state_ last, since it may be holding the last ref to whatever
56
0
  // object owns us, and we may be deleted after that.
57
0
  bind_state_ = nullptr;
58
0
}
59
60
0
bool CallbackBase::IsCancelled() const {
61
0
  DCHECK(bind_state_);
62
0
  return bind_state_->IsCancelled();
63
0
}
64
65
0
bool CallbackBase::EqualsInternal(const CallbackBase& other) const {
66
0
  return bind_state_ == other.bind_state_;
67
0
}
68
69
CallbackBase::CallbackBase(BindStateBase* bind_state)
70
0
    : bind_state_(bind_state ? AdoptRef(bind_state) : nullptr) {
71
0
  DCHECK(!bind_state_.get() || bind_state_->HasOneRef());
72
0
}
73
74
0
CallbackBase::~CallbackBase() {}
75
76
CallbackBaseCopyable::CallbackBaseCopyable(const CallbackBaseCopyable& c)
77
0
    : CallbackBase(nullptr) {
78
0
  bind_state_ = c.bind_state_;
79
0
}
80
81
0
CallbackBaseCopyable::CallbackBaseCopyable(CallbackBaseCopyable&& c) = default;
82
83
CallbackBaseCopyable& CallbackBaseCopyable::operator=(
84
0
    const CallbackBaseCopyable& c) {
85
0
  bind_state_ = c.bind_state_;
86
0
  return *this;
87
0
}
88
89
CallbackBaseCopyable& CallbackBaseCopyable::operator=(
90
0
    CallbackBaseCopyable&& c) = default;
91
92
}  // namespace internal
93
}  // namespace base