| 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 <limits> | 7 #include <limits> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <sstream> | 9 #include <sstream> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 const TestOrderablePendingTask& other) const { | 53 const TestOrderablePendingTask& other) const { |
| 54 if (*this == other) | 54 if (*this == other) |
| 55 return false; | 55 return false; |
| 56 | 56 |
| 57 if (GetTimeToRun() == other.GetTimeToRun()) { | 57 if (GetTimeToRun() == other.GetTimeToRun()) { |
| 58 return task_id_ < other.task_id_; | 58 return task_id_ < other.task_id_; |
| 59 } | 59 } |
| 60 return ShouldRunBefore(other); | 60 return ShouldRunBefore(other); |
| 61 } | 61 } |
| 62 | 62 |
| 63 scoped_refptr<base::debug::ConvertableToTraceFormat> | 63 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 64 TestOrderablePendingTask::AsValue() const { | 64 TestOrderablePendingTask::AsValue() const { |
| 65 scoped_refptr<base::debug::TracedValue> state = | 65 scoped_refptr<base::trace_event::TracedValue> state = |
| 66 new base::debug::TracedValue(); | 66 new base::trace_event::TracedValue(); |
| 67 AsValueInto(state.get()); | 67 AsValueInto(state.get()); |
| 68 return state; | 68 return state; |
| 69 } | 69 } |
| 70 | 70 |
| 71 void TestOrderablePendingTask::AsValueInto( | 71 void TestOrderablePendingTask::AsValueInto( |
| 72 base::debug::TracedValue* state) const { | 72 base::trace_event::TracedValue* state) const { |
| 73 state->SetInteger("id", task_id_); | 73 state->SetInteger("id", task_id_); |
| 74 state->SetInteger("run_at", GetTimeToRun().ToInternalValue()); | 74 state->SetInteger("run_at", GetTimeToRun().ToInternalValue()); |
| 75 state->SetString("posted_from", location.ToString()); | 75 state->SetString("posted_from", location.ToString()); |
| 76 } | 76 } |
| 77 | 77 |
| 78 OrderedSimpleTaskRunner::OrderedSimpleTaskRunner() | 78 OrderedSimpleTaskRunner::OrderedSimpleTaskRunner() |
| 79 : advance_now_(true), | 79 : advance_now_(true), |
| 80 now_src_(TestNowSource::Create(0)), | 80 now_src_(TestNowSource::Create(0)), |
| 81 inside_run_tasks_until_(false) { | 81 inside_run_tasks_until_(false) { |
| 82 } | 82 } |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 now_src_->SetNow(time); | 248 now_src_->SetNow(time); |
| 249 } | 249 } |
| 250 | 250 |
| 251 return result; | 251 return result; |
| 252 } | 252 } |
| 253 | 253 |
| 254 bool OrderedSimpleTaskRunner::RunForPeriod(base::TimeDelta period) { | 254 bool OrderedSimpleTaskRunner::RunForPeriod(base::TimeDelta period) { |
| 255 return RunUntilTime(now_src_->Now() + period); | 255 return RunUntilTime(now_src_->Now() + period); |
| 256 } | 256 } |
| 257 | 257 |
| 258 // base::debug tracing functionality | 258 // base::trace_event tracing functionality |
| 259 scoped_refptr<base::debug::ConvertableToTraceFormat> | 259 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 260 OrderedSimpleTaskRunner::AsValue() const { | 260 OrderedSimpleTaskRunner::AsValue() const { |
| 261 scoped_refptr<base::debug::TracedValue> state = | 261 scoped_refptr<base::trace_event::TracedValue> state = |
| 262 new base::debug::TracedValue(); | 262 new base::trace_event::TracedValue(); |
| 263 AsValueInto(state.get()); | 263 AsValueInto(state.get()); |
| 264 return state; | 264 return state; |
| 265 } | 265 } |
| 266 | 266 |
| 267 void OrderedSimpleTaskRunner::AsValueInto( | 267 void OrderedSimpleTaskRunner::AsValueInto( |
| 268 base::debug::TracedValue* state) const { | 268 base::trace_event::TracedValue* state) const { |
| 269 state->SetInteger("pending_tasks", pending_tasks_.size()); | 269 state->SetInteger("pending_tasks", pending_tasks_.size()); |
| 270 | 270 |
| 271 state->BeginArray("tasks"); | 271 state->BeginArray("tasks"); |
| 272 for (std::set<TestOrderablePendingTask>::const_iterator it = | 272 for (std::set<TestOrderablePendingTask>::const_iterator it = |
| 273 pending_tasks_.begin(); | 273 pending_tasks_.begin(); |
| 274 it != pending_tasks_.end(); | 274 it != pending_tasks_.end(); |
| 275 ++it) { | 275 ++it) { |
| 276 state->BeginDictionary(); | 276 state->BeginDictionary(); |
| 277 it->AsValueInto(state); | 277 it->AsValueInto(state); |
| 278 state->EndDictionary(); | 278 state->EndDictionary(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 | 325 |
| 326 bool OrderedSimpleTaskRunner::AdvanceNowCallback() { | 326 bool OrderedSimpleTaskRunner::AdvanceNowCallback() { |
| 327 base::TimeTicks next_task_time = NextTaskTime(); | 327 base::TimeTicks next_task_time = NextTaskTime(); |
| 328 if (now_src_->Now() < next_task_time) { | 328 if (now_src_->Now() < next_task_time) { |
| 329 now_src_->SetNow(next_task_time); | 329 now_src_->SetNow(next_task_time); |
| 330 } | 330 } |
| 331 return true; | 331 return true; |
| 332 } | 332 } |
| 333 | 333 |
| 334 } // namespace cc | 334 } // namespace cc |
| OLD | NEW |