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

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: +test, +DCHECK 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 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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698