Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: content/renderer/scheduler/task_queue_manager.cc

Issue 892213004: Mechanical rename of base::debug -> base::trace_event for /content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_trace_part3_1
Patch Set: Rebase. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/renderer/scheduler/task_queue_manager.h" 5 #include "content/renderer/scheduler/task_queue_manager.h"
6 6
7 #include <queue> 7 #include <queue>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 bool UpdateWorkQueue(base::TimeTicks* next_pending_delayed_task); 50 bool UpdateWorkQueue(base::TimeTicks* next_pending_delayed_task);
51 base::PendingTask TakeTaskFromWorkQueue(); 51 base::PendingTask TakeTaskFromWorkQueue();
52 52
53 void WillDeleteTaskQueueManager(); 53 void WillDeleteTaskQueueManager();
54 54
55 base::TaskQueue& work_queue() { return work_queue_; } 55 base::TaskQueue& work_queue() { return work_queue_; }
56 56
57 void set_name(const char* name) { name_ = name; } 57 void set_name(const char* name) { name_ = name; }
58 58
59 void AsValueInto(base::debug::TracedValue* state) const; 59 void AsValueInto(base::trace_event::TracedValue* state) const;
60 60
61 private: 61 private:
62 ~TaskQueue() override; 62 ~TaskQueue() override;
63 63
64 bool PostDelayedTaskImpl(const tracked_objects::Location& from_here, 64 bool PostDelayedTaskImpl(const tracked_objects::Location& from_here,
65 const base::Closure& task, 65 const base::Closure& task,
66 base::TimeDelta delay, 66 base::TimeDelta delay,
67 bool nestable); 67 bool nestable);
68 68
69 void PumpQueueLocked(); 69 void PumpQueueLocked();
70 void EnqueueTaskLocked(const base::PendingTask& pending_task); 70 void EnqueueTaskLocked(const base::PendingTask& pending_task);
71 71
72 void TraceWorkQueueSize() const; 72 void TraceWorkQueueSize() const;
73 static void QueueAsValueInto(const base::TaskQueue& queue, 73 static void QueueAsValueInto(const base::TaskQueue& queue,
74 base::debug::TracedValue* state); 74 base::trace_event::TracedValue* state);
75 static void TaskAsValueInto(const base::PendingTask& task, 75 static void TaskAsValueInto(const base::PendingTask& task,
76 base::debug::TracedValue* state); 76 base::trace_event::TracedValue* state);
77 77
78 // This lock protects all members except the work queue. 78 // This lock protects all members except the work queue.
79 mutable base::Lock lock_; 79 mutable base::Lock lock_;
80 TaskQueueManager* task_queue_manager_; 80 TaskQueueManager* task_queue_manager_;
81 base::TaskQueue incoming_queue_; 81 base::TaskQueue incoming_queue_;
82 bool auto_pump_; 82 bool auto_pump_;
83 const char* name_; 83 const char* name_;
84 std::priority_queue<base::TimeTicks, 84 std::priority_queue<base::TimeTicks,
85 std::vector<base::TimeTicks>, 85 std::vector<base::TimeTicks>,
86 std::greater<base::TimeTicks>> delayed_task_run_times_; 86 std::greater<base::TimeTicks>> delayed_task_run_times_;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 } 217 }
218 if (!work_queue_.empty()) 218 if (!work_queue_.empty())
219 task_queue_manager_->MaybePostDoWorkOnMainRunner(); 219 task_queue_manager_->MaybePostDoWorkOnMainRunner();
220 } 220 }
221 221
222 void TaskQueue::PumpQueue() { 222 void TaskQueue::PumpQueue() {
223 base::AutoLock lock(lock_); 223 base::AutoLock lock(lock_);
224 PumpQueueLocked(); 224 PumpQueueLocked();
225 } 225 }
226 226
227 void TaskQueue::AsValueInto(base::debug::TracedValue* state) const { 227 void TaskQueue::AsValueInto(base::trace_event::TracedValue* state) const {
228 base::AutoLock lock(lock_); 228 base::AutoLock lock(lock_);
229 state->BeginDictionary(); 229 state->BeginDictionary();
230 if (name_) 230 if (name_)
231 state->SetString("name", name_); 231 state->SetString("name", name_);
232 state->SetBoolean("auto_pump", auto_pump_); 232 state->SetBoolean("auto_pump", auto_pump_);
233 state->BeginArray("incoming_queue"); 233 state->BeginArray("incoming_queue");
234 QueueAsValueInto(incoming_queue_, state); 234 QueueAsValueInto(incoming_queue_, state);
235 state->EndArray(); 235 state->EndArray();
236 state->BeginArray("work_queue"); 236 state->BeginArray("work_queue");
237 QueueAsValueInto(work_queue_, state); 237 QueueAsValueInto(work_queue_, state);
238 state->EndArray(); 238 state->EndArray();
239 state->EndDictionary(); 239 state->EndDictionary();
240 } 240 }
241 241
242 // static 242 // static
243 void TaskQueue::QueueAsValueInto(const base::TaskQueue& queue, 243 void TaskQueue::QueueAsValueInto(const base::TaskQueue& queue,
244 base::debug::TracedValue* state) { 244 base::trace_event::TracedValue* state) {
245 base::TaskQueue queue_copy(queue); 245 base::TaskQueue queue_copy(queue);
246 while (!queue_copy.empty()) { 246 while (!queue_copy.empty()) {
247 TaskAsValueInto(queue_copy.front(), state); 247 TaskAsValueInto(queue_copy.front(), state);
248 queue_copy.pop(); 248 queue_copy.pop();
249 } 249 }
250 } 250 }
251 251
252 // static 252 // static
253 void TaskQueue::TaskAsValueInto(const base::PendingTask& task, 253 void TaskQueue::TaskAsValueInto(const base::PendingTask& task,
254 base::debug::TracedValue* state) { 254 base::trace_event::TracedValue* state) {
255 state->BeginDictionary(); 255 state->BeginDictionary();
256 state->SetString("posted_from", task.posted_from.ToString()); 256 state->SetString("posted_from", task.posted_from.ToString());
257 state->SetInteger("sequence_num", task.sequence_num); 257 state->SetInteger("sequence_num", task.sequence_num);
258 state->SetBoolean("nestable", task.nestable); 258 state->SetBoolean("nestable", task.nestable);
259 state->SetBoolean("is_high_res", task.is_high_res); 259 state->SetBoolean("is_high_res", task.is_high_res);
260 state->SetDouble( 260 state->SetDouble(
261 "delayed_run_time", 261 "delayed_run_time",
262 (task.delayed_run_time - base::TimeTicks()).InMicroseconds() / 1000.0L); 262 (task.delayed_run_time - base::TimeTicks()).InMicroseconds() / 1000.0L);
263 state->EndDictionary(); 263 state->EndDictionary();
264 } 264 }
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 void TaskQueueManager::SetTimeSourceForTesting( 445 void TaskQueueManager::SetTimeSourceForTesting(
446 scoped_refptr<cc::TestNowSource> time_source) { 446 scoped_refptr<cc::TestNowSource> time_source) {
447 DCHECK(main_thread_checker_.CalledOnValidThread()); 447 DCHECK(main_thread_checker_.CalledOnValidThread());
448 time_source_ = time_source; 448 time_source_ = time_source;
449 } 449 }
450 450
451 base::TimeTicks TaskQueueManager::Now() const { 451 base::TimeTicks TaskQueueManager::Now() const {
452 return UNLIKELY(time_source_) ? time_source_->Now() : base::TimeTicks::Now(); 452 return UNLIKELY(time_source_) ? time_source_->Now() : base::TimeTicks::Now();
453 } 453 }
454 454
455 scoped_refptr<base::debug::ConvertableToTraceFormat> 455 scoped_refptr<base::trace_event::ConvertableToTraceFormat>
456 TaskQueueManager::AsValueWithSelectorResult(bool should_run, 456 TaskQueueManager::AsValueWithSelectorResult(bool should_run,
457 size_t selected_queue) const { 457 size_t selected_queue) const {
458 DCHECK(main_thread_checker_.CalledOnValidThread()); 458 DCHECK(main_thread_checker_.CalledOnValidThread());
459 scoped_refptr<base::debug::TracedValue> state = 459 scoped_refptr<base::trace_event::TracedValue> state =
460 new base::debug::TracedValue(); 460 new base::trace_event::TracedValue();
461 state->BeginArray("queues"); 461 state->BeginArray("queues");
462 for (auto& queue : queues_) 462 for (auto& queue : queues_)
463 queue->AsValueInto(state.get()); 463 queue->AsValueInto(state.get());
464 state->EndArray(); 464 state->EndArray();
465 state->BeginDictionary("selector"); 465 state->BeginDictionary("selector");
466 selector_->AsValueInto(state.get()); 466 selector_->AsValueInto(state.get());
467 state->EndDictionary(); 467 state->EndDictionary();
468 if (should_run) 468 if (should_run)
469 state->SetInteger("selected_queue", selected_queue); 469 state->SetInteger("selected_queue", selected_queue);
470 return state; 470 return state;
471 } 471 }
472 472
473 } // namespace content 473 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/scheduler/task_queue_manager.h ('k') | content/renderer/scheduler/task_queue_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698