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 "cc/test/ordered_simple_task_runner.h" | 5 #include "cc/test/ordered_simple_task_runner.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <limits> | 10 #include <limits> |
(...skipping 18 matching lines...) Expand all Loading... |
29 namespace cc { | 29 namespace cc { |
30 | 30 |
31 // TestOrderablePendingTask implementation | 31 // TestOrderablePendingTask implementation |
32 TestOrderablePendingTask::TestOrderablePendingTask() | 32 TestOrderablePendingTask::TestOrderablePendingTask() |
33 : base::TestPendingTask(), | 33 : base::TestPendingTask(), |
34 task_id_(TestOrderablePendingTask::task_id_counter++) { | 34 task_id_(TestOrderablePendingTask::task_id_counter++) { |
35 } | 35 } |
36 | 36 |
37 TestOrderablePendingTask::TestOrderablePendingTask( | 37 TestOrderablePendingTask::TestOrderablePendingTask( |
38 const tracked_objects::Location& location, | 38 const tracked_objects::Location& location, |
39 base::Closure task, | 39 base::OnceClosure task, |
40 base::TimeTicks post_time, | 40 base::TimeTicks post_time, |
41 base::TimeDelta delay, | 41 base::TimeDelta delay, |
42 TestNestability nestability) | 42 TestNestability nestability) |
43 : base::TestPendingTask(location, | 43 : base::TestPendingTask(location, |
44 std::move(task), | 44 std::move(task), |
45 post_time, | 45 post_time, |
46 delay, | 46 delay, |
47 nestability), | 47 nestability), |
48 task_id_(TestOrderablePendingTask::task_id_counter++) {} | 48 task_id_(TestOrderablePendingTask::task_id_counter++) {} |
49 | 49 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 102 |
103 // static | 103 // static |
104 base::TimeTicks OrderedSimpleTaskRunner::AbsoluteMaxNow() { | 104 base::TimeTicks OrderedSimpleTaskRunner::AbsoluteMaxNow() { |
105 return base::TimeTicks::FromInternalValue( | 105 return base::TimeTicks::FromInternalValue( |
106 std::numeric_limits<int64_t>::max()); | 106 std::numeric_limits<int64_t>::max()); |
107 } | 107 } |
108 | 108 |
109 // base::TestSimpleTaskRunner implementation | 109 // base::TestSimpleTaskRunner implementation |
110 bool OrderedSimpleTaskRunner::PostDelayedTask( | 110 bool OrderedSimpleTaskRunner::PostDelayedTask( |
111 const tracked_objects::Location& from_here, | 111 const tracked_objects::Location& from_here, |
112 base::Closure task, | 112 base::OnceClosure task, |
113 base::TimeDelta delay) { | 113 base::TimeDelta delay) { |
114 DCHECK(thread_checker_.CalledOnValidThread()); | 114 DCHECK(thread_checker_.CalledOnValidThread()); |
115 TestOrderablePendingTask pt(from_here, std::move(task), now_src_->NowTicks(), | 115 TestOrderablePendingTask pt(from_here, std::move(task), now_src_->NowTicks(), |
116 delay, base::TestPendingTask::NESTABLE); | 116 delay, base::TestPendingTask::NESTABLE); |
117 | 117 |
118 TRACE_TASK("OrderedSimpleTaskRunner::PostDelayedTask", pt); | 118 TRACE_TASK("OrderedSimpleTaskRunner::PostDelayedTask", pt); |
119 pending_tasks_.insert(std::move(pt)); | 119 pending_tasks_.insert(std::move(pt)); |
120 return true; | 120 return true; |
121 } | 121 } |
122 | 122 |
123 bool OrderedSimpleTaskRunner::PostNonNestableDelayedTask( | 123 bool OrderedSimpleTaskRunner::PostNonNestableDelayedTask( |
124 const tracked_objects::Location& from_here, | 124 const tracked_objects::Location& from_here, |
125 base::Closure task, | 125 base::OnceClosure task, |
126 base::TimeDelta delay) { | 126 base::TimeDelta delay) { |
127 DCHECK(thread_checker_.CalledOnValidThread()); | 127 DCHECK(thread_checker_.CalledOnValidThread()); |
128 TestOrderablePendingTask pt(from_here, std::move(task), now_src_->NowTicks(), | 128 TestOrderablePendingTask pt(from_here, std::move(task), now_src_->NowTicks(), |
129 delay, base::TestPendingTask::NON_NESTABLE); | 129 delay, base::TestPendingTask::NON_NESTABLE); |
130 | 130 |
131 TRACE_TASK("OrderedSimpleTaskRunner::PostNonNestableDelayedTask", pt); | 131 TRACE_TASK("OrderedSimpleTaskRunner::PostNonNestableDelayedTask", pt); |
132 pending_tasks_.insert(std::move(pt)); | 132 pending_tasks_.insert(std::move(pt)); |
133 return true; | 133 return true; |
134 } | 134 } |
135 | 135 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 while (it != pending_tasks_.end()) { | 374 while (it != pending_tasks_.end()) { |
375 if (it->task.IsCancelled()) { | 375 if (it->task.IsCancelled()) { |
376 it = pending_tasks_.erase(it); | 376 it = pending_tasks_.erase(it); |
377 } else { | 377 } else { |
378 it++; | 378 it++; |
379 } | 379 } |
380 } | 380 } |
381 } | 381 } |
382 | 382 |
383 } // namespace cc | 383 } // namespace cc |
OLD | NEW |