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

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 fix 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"
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698