| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |