Chromium Code Reviews| 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 namespace internal { | |
| 11 | |
| 12 FunctionCancellerImplBase::FunctionCancellerImplBase() = default; | |
| 13 FunctionCancellerImplBase::~FunctionCancellerImplBase() = default; | |
| 14 | |
| 15 } // namespace internal | |
| 16 | |
| 17 FunctionCanceller::FunctionCanceller() = default; | |
| 18 FunctionCanceller::FunctionCanceller(PassRefPtr<internal::FunctionCancellerImplB ase> cancellation) | |
| 19 : m_cancellation(cancellation) | |
| 20 { | |
| 21 DCHECK(m_cancellation); | |
| 22 } | |
| 23 | |
| 24 FunctionCanceller::FunctionCanceller(FunctionCanceller&&) = default; | |
| 25 FunctionCanceller& FunctionCanceller::operator=(FunctionCanceller&&) = default; | |
| 26 | |
| 27 FunctionCanceller::~FunctionCanceller() | |
| 28 { | |
| 29 cancel(); | |
|
Yuta Kitamura
2016/07/27 09:08:02
This might be a bit surprising (task getting cance
tzik
2016/07/27 10:10:30
Added a comment and example there.
Yes, this will
| |
| 30 } | |
| 31 | |
| 32 void FunctionCanceller::detach() | |
| 33 { | |
| 34 m_cancellation = nullptr; | |
| 35 } | |
| 36 | |
| 37 void FunctionCanceller::cancel() | |
| 38 { | |
| 39 if (!m_cancellation) | |
| 40 return; | |
| 41 | |
| 42 m_cancellation->cancel(); | |
| 43 m_cancellation = nullptr; | |
| 44 } | |
| 45 | |
| 46 } // namespace WTF | |
| OLD | NEW |