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

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: +self-assign fix, +test, +comment and examples 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 #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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698