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 #include "base/logging.h" |
| 8 |
| 9 namespace WTF { |
| 10 |
| 11 FunctionCanceller::FunctionCanceller() = default; |
| 12 FunctionCanceller::~FunctionCanceller() = default; |
| 13 |
| 14 ScopedFunctionCanceller::ScopedFunctionCanceller() = default; |
| 15 ScopedFunctionCanceller::ScopedFunctionCanceller(PassRefPtr<FunctionCanceller> c
anceller) |
| 16 : m_canceller(canceller) |
| 17 { |
| 18 DCHECK(m_canceller); |
| 19 } |
| 20 |
| 21 ScopedFunctionCanceller::ScopedFunctionCanceller(ScopedFunctionCanceller&&) = de
fault; |
| 22 ScopedFunctionCanceller& ScopedFunctionCanceller::operator=(ScopedFunctionCancel
ler&&) = default; |
| 23 |
| 24 ScopedFunctionCanceller::~ScopedFunctionCanceller() |
| 25 { |
| 26 cancel(); |
| 27 } |
| 28 |
| 29 void ScopedFunctionCanceller::detach() |
| 30 { |
| 31 m_canceller = nullptr; |
| 32 } |
| 33 |
| 34 void ScopedFunctionCanceller::cancel() |
| 35 { |
| 36 if (!m_canceller) |
| 37 return; |
| 38 |
| 39 m_canceller->cancel(); |
| 40 m_canceller = nullptr; |
| 41 } |
| 42 |
| 43 } // namespace WTF |
OLD | NEW |