Chromium Code Reviews| Index: content/renderer/scheduler/task_queue_manager.cc |
| diff --git a/content/renderer/scheduler/task_queue_manager.cc b/content/renderer/scheduler/task_queue_manager.cc |
| index 227a7e87e20b74143446b7561706ab8305665612..ddb67ec597f2979235eb07a7e1ae9a26cc4df439 100644 |
| --- a/content/renderer/scheduler/task_queue_manager.cc |
| +++ b/content/renderer/scheduler/task_queue_manager.cc |
| @@ -6,6 +6,7 @@ |
| #include "base/bind.h" |
| #include "base/debug/trace_event.h" |
| +#include "base/debug/trace_event_argument.h" |
| #include "content/renderer/scheduler/task_queue_selector.h" |
| namespace content { |
| @@ -42,6 +43,8 @@ class TaskQueue : public base::SingleThreadTaskRunner { |
| base::TaskQueue& work_queue() { return work_queue_; } |
| + void AsValueInto(base::debug::TracedValue* state); |
| + |
| private: |
| virtual ~TaskQueue(); |
| @@ -175,7 +178,20 @@ void TaskQueue::PumpQueue() { |
| PumpQueueLocked(); |
| } |
| -} // namespace |
| +void TaskQueue::AsValueInto(base::debug::TracedValue* state) { |
| + base::AutoLock lock(lock_); |
| + state->BeginDictionary(); |
| + state->BeginArray("incoming_queue"); |
| + TaskQueueManager::QueueAsValueInto(incoming_queue_, state); |
| + state->EndArray(); |
| + state->BeginArray("work_queue"); |
| + TaskQueueManager::QueueAsValueInto(work_queue_, state); |
| + state->EndArray(); |
| + state->SetBoolean("auto_pump", auto_pump_); |
| + state->EndDictionary(); |
| +} |
| + |
| +} // namespace internal |
| TaskQueueManager::TaskQueueManager( |
| size_t task_queue_count, |
| @@ -292,4 +308,43 @@ bool TaskQueueManager::PostNonNestableDelayedTask( |
| return main_task_runner_->PostNonNestableDelayedTask(from_here, task, delay); |
| } |
| +void TaskQueueManager::AsValueInto(base::debug::TracedValue* state) const { |
| + main_thread_checker_.CalledOnValidThread(); |
| + state->BeginArray("queues"); |
| + for (auto& queue : queues_) |
| + queue->AsValueInto(state); |
| + state->EndArray(); |
| +} |
| + |
| +// static |
| +void TaskQueueManager::QueueAsValueInto(const base::TaskQueue& queue, |
| + base::debug::TracedValue* state) { |
| + base::TaskQueue queue_copy(queue); |
| + state->BeginDictionary(); |
| + state->BeginArray("tasks"); |
| + while (!queue_copy.empty()) { |
| + TaskAsValueInto(queue_copy.front(), state); |
| + queue_copy.pop(); |
| + } |
| + state->EndArray(); |
| + state->EndDictionary(); |
| +} |
| + |
| +// static |
| +void TaskQueueManager::TaskAsValueInto(const base::PendingTask& task, |
| + base::debug::TracedValue* state) { |
| + state->BeginDictionary(); |
| + state->SetString("posted_from", task.posted_from.ToString()); |
| + state->SetInteger("sequence_num", task.sequence_num); |
|
picksi1
2014/10/28 11:01:40
do we need the underscores in the strings here?
Sami
2014/10/28 12:57:47
As opposed to camelCase? I think underscores are c
picksi1
2014/10/28 13:38:59
As opposed to spaces! I assume this string ends in
Sami
2014/10/28 13:42:00
You could have spaces here per the json spec, but
|
| + state->SetBoolean("nestable", task.nestable); |
| + state->SetBoolean("is_high_res", task.is_high_res); |
| + state->SetDouble( |
| + "time_posted", |
| + (task.time_posted - base::TimeTicks()).InMicroseconds() / 1000.0L); |
| + state->SetDouble( |
|
picksi1
2014/10/28 11:01:40
ditto: InMillisecondsF?
Sami
2014/10/28 12:57:48
Done.
|
| + "delayed_run_time", |
| + (task.delayed_run_time - base::TimeTicks()).InMicroseconds() / 1000.0L); |
| + state->EndDictionary(); |
| +} |
| + |
| } // namespace content |