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" | |
|
haraken
2016/07/29 14:02:52
Do you need this?
tzik
2016/07/29 16:49:13
Oh, no. It's no longer needed.
| |
| 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 ScopedFunctionCanceller::ScopedFunctionCanceller(ScopedFunctionCanceller&&) = de fault; | |
| 19 ScopedFunctionCanceller& ScopedFunctionCanceller::operator=(ScopedFunctionCancel ler&& other) | |
| 20 { | |
| 21 RefPtr<FunctionCanceller> canceller = std::move(other.m_canceller); | |
| 22 cancel(); | |
| 23 m_canceller = std::move(canceller); | |
| 24 return *this; | |
| 25 } | |
| 26 | |
| 27 ScopedFunctionCanceller::~ScopedFunctionCanceller() | |
| 28 { | |
| 29 cancel(); | |
| 30 } | |
| 31 | |
| 32 void ScopedFunctionCanceller::detach() | |
| 33 { | |
| 34 m_canceller = nullptr; | |
| 35 } | |
| 36 | |
| 37 void ScopedFunctionCanceller::cancel() | |
| 38 { | |
| 39 if (!m_canceller) | |
| 40 return; | |
| 41 | |
| 42 m_canceller->cancel(); | |
| 43 m_canceller = nullptr; | |
| 44 } | |
| 45 | |
| 46 } // namespace WTF | |
| OLD | NEW |