Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: third_party/WebKit/Source/wtf/MakeCancellable.cpp

Issue 2177283005: Add WTF::makeCancellable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: +comment Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/MakeCancellable.h ('k') | third_party/WebKit/Source/wtf/MakeCancellableTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698