OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 "wtf/MakeCancellable.h" |
| 6 |
| 7 namespace WTF { |
| 8 |
| 9 namespace internal { |
| 10 |
| 11 FunctionCanceller::FunctionCanceller() = default; |
| 12 FunctionCanceller::~FunctionCanceller() = default; |
| 13 |
| 14 } // namespace internal |
| 15 |
| 16 ScopedFunctionCanceller::ScopedFunctionCanceller() = default; |
| 17 ScopedFunctionCanceller::ScopedFunctionCanceller(PassRefPtr<internal::FunctionCa
nceller> canceller) |
| 18 : m_canceller(std::move(canceller)) { } |
| 19 |
| 20 ScopedFunctionCanceller::ScopedFunctionCanceller(ScopedFunctionCanceller&&) = de
fault; |
| 21 ScopedFunctionCanceller& ScopedFunctionCanceller::operator=(ScopedFunctionCancel
ler&& other) |
| 22 { |
| 23 RefPtr<internal::FunctionCanceller> canceller = std::move(other.m_canceller)
; |
| 24 cancel(); |
| 25 m_canceller = std::move(canceller); |
| 26 return *this; |
| 27 } |
| 28 |
| 29 ScopedFunctionCanceller::~ScopedFunctionCanceller() |
| 30 { |
| 31 cancel(); |
| 32 } |
| 33 |
| 34 void ScopedFunctionCanceller::detach() |
| 35 { |
| 36 m_canceller = nullptr; |
| 37 } |
| 38 |
| 39 void ScopedFunctionCanceller::cancel() |
| 40 { |
| 41 if (!m_canceller) |
| 42 return; |
| 43 |
| 44 m_canceller->cancel(); |
| 45 m_canceller = nullptr; |
| 46 } |
| 47 |
| 48 bool ScopedFunctionCanceller::isActive() const |
| 49 { |
| 50 return m_canceller && m_canceller->isActive(); |
| 51 } |
| 52 |
| 53 } // namespace WTF |
OLD | NEW |