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

Side by Side Diff: base/task/cancelable_task_tracker.cc

Issue 1997153002: libchrome: Several upstreamable fixes from libchrome Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Addressed feedback Created 4 years, 7 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/task/cancelable_task_tracker.h" 5 #include "base/task/cancelable_task_tracker.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 21 matching lines...) Expand all
32 } 32 }
33 33
34 void RunIfNotCanceledThenUntrack(const CancellationFlag* flag, 34 void RunIfNotCanceledThenUntrack(const CancellationFlag* flag,
35 const Closure& task, 35 const Closure& task,
36 const Closure& untrack) { 36 const Closure& untrack) {
37 RunIfNotCanceled(flag, task); 37 RunIfNotCanceled(flag, task);
38 untrack.Run(); 38 untrack.Run();
39 } 39 }
40 40
41 bool IsCanceled(const CancellationFlag* flag, 41 bool IsCanceled(const CancellationFlag* flag,
42 base::ScopedClosureRunner* cleanup_runner) { 42 base::ScopedClosureRunner* /*cleanup_runner*/) {
43 return flag->IsSet(); 43 return flag->IsSet();
44 } 44 }
45 45
46 void RunAndDeleteFlag(const Closure& closure, const CancellationFlag* flag) { 46 void RunAndDeleteFlag(const Closure& closure, const CancellationFlag* flag) {
47 closure.Run(); 47 closure.Run();
48 delete flag; 48 delete flag;
49 } 49 }
50 50
51 void RunOrPostToTaskRunner(TaskRunner* task_runner, const Closure& closure) { 51 void RunOrPostToTaskRunner(TaskRunner* task_runner, const Closure& closure) {
52 if (task_runner->RunsTasksOnCurrentThread()) 52 if (task_runner->RunsTasksOnCurrentThread())
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 DCHECK(success); 182 DCHECK(success);
183 } 183 }
184 184
185 void CancelableTaskTracker::Untrack(TaskId id) { 185 void CancelableTaskTracker::Untrack(TaskId id) {
186 DCHECK(thread_checker_.CalledOnValidThread()); 186 DCHECK(thread_checker_.CalledOnValidThread());
187 size_t num = task_flags_.erase(id); 187 size_t num = task_flags_.erase(id);
188 DCHECK_EQ(1u, num); 188 DCHECK_EQ(1u, num);
189 } 189 }
190 190
191 } // namespace base 191 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698