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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 const TestOrderablePendingTask& other) const { | 57 const TestOrderablePendingTask& other) const { |
58 if (*this == other) | 58 if (*this == other) |
59 return false; | 59 return false; |
60 | 60 |
61 if (GetTimeToRun() == other.GetTimeToRun()) { | 61 if (GetTimeToRun() == other.GetTimeToRun()) { |
62 return task_id_ < other.task_id_; | 62 return task_id_ < other.task_id_; |
63 } | 63 } |
64 return ShouldRunBefore(other); | 64 return ShouldRunBefore(other); |
65 } | 65 } |
66 | 66 |
67 scoped_ptr<base::trace_event::ConvertableToTraceFormat> | 67 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
68 TestOrderablePendingTask::AsValue() const { | 68 TestOrderablePendingTask::AsValue() const { |
69 scoped_ptr<base::trace_event::TracedValue> state( | 69 std::unique_ptr<base::trace_event::TracedValue> state( |
70 new base::trace_event::TracedValue()); | 70 new base::trace_event::TracedValue()); |
71 AsValueInto(state.get()); | 71 AsValueInto(state.get()); |
72 return std::move(state); | 72 return std::move(state); |
73 } | 73 } |
74 | 74 |
75 void TestOrderablePendingTask::AsValueInto( | 75 void TestOrderablePendingTask::AsValueInto( |
76 base::trace_event::TracedValue* state) const { | 76 base::trace_event::TracedValue* state) const { |
77 state->SetInteger("id", base::saturated_cast<int>(task_id_)); | 77 state->SetInteger("id", base::saturated_cast<int>(task_id_)); |
78 state->SetInteger("run_at", GetTimeToRun().ToInternalValue()); | 78 state->SetInteger("run_at", GetTimeToRun().ToInternalValue()); |
79 state->SetString("posted_from", location.ToString()); | 79 state->SetString("posted_from", location.ToString()); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 } | 254 } |
255 | 255 |
256 return result; | 256 return result; |
257 } | 257 } |
258 | 258 |
259 bool OrderedSimpleTaskRunner::RunForPeriod(base::TimeDelta period) { | 259 bool OrderedSimpleTaskRunner::RunForPeriod(base::TimeDelta period) { |
260 return RunUntilTime(now_src_->NowTicks() + period); | 260 return RunUntilTime(now_src_->NowTicks() + period); |
261 } | 261 } |
262 | 262 |
263 // base::trace_event tracing functionality | 263 // base::trace_event tracing functionality |
264 scoped_ptr<base::trace_event::ConvertableToTraceFormat> | 264 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
265 OrderedSimpleTaskRunner::AsValue() const { | 265 OrderedSimpleTaskRunner::AsValue() const { |
266 scoped_ptr<base::trace_event::TracedValue> state( | 266 std::unique_ptr<base::trace_event::TracedValue> state( |
267 new base::trace_event::TracedValue()); | 267 new base::trace_event::TracedValue()); |
268 AsValueInto(state.get()); | 268 AsValueInto(state.get()); |
269 return std::move(state); | 269 return std::move(state); |
270 } | 270 } |
271 | 271 |
272 void OrderedSimpleTaskRunner::AsValueInto( | 272 void OrderedSimpleTaskRunner::AsValueInto( |
273 base::trace_event::TracedValue* state) const { | 273 base::trace_event::TracedValue* state) const { |
274 state->SetInteger("pending_tasks", | 274 state->SetInteger("pending_tasks", |
275 base::saturated_cast<int>(pending_tasks_.size())); | 275 base::saturated_cast<int>(pending_tasks_.size())); |
276 | 276 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 | 336 |
337 bool OrderedSimpleTaskRunner::AdvanceNowCallback() { | 337 bool OrderedSimpleTaskRunner::AdvanceNowCallback() { |
338 base::TimeTicks next_task_time = NextTaskTime(); | 338 base::TimeTicks next_task_time = NextTaskTime(); |
339 if (now_src_->NowTicks() < next_task_time) { | 339 if (now_src_->NowTicks() < next_task_time) { |
340 now_src_->Advance(next_task_time - now_src_->NowTicks()); | 340 now_src_->Advance(next_task_time - now_src_->NowTicks()); |
341 } | 341 } |
342 return true; | 342 return true; |
343 } | 343 } |
344 | 344 |
345 } // namespace cc | 345 } // namespace cc |
OLD | NEW |