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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc

Issue 2416803003: Record PendingTaskCount when a backgrounded renderer is suspended. (Closed)
Patch Set: Add GetNumberOfPendingTasks to TaskQueueManager Created 4 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "platform/scheduler/base/task_queue_impl.h" 5 #include "platform/scheduler/base/task_queue_impl.h"
6 6
7 #include "base/trace_event/blame_context.h" 7 #include "base/trace_event/blame_context.h"
8 #include "platform/scheduler/base/task_queue_manager.h" 8 #include "platform/scheduler/base/task_queue_manager.h"
9 #include "platform/scheduler/base/task_queue_manager_delegate.h" 9 #include "platform/scheduler/base/task_queue_manager_delegate.h"
10 #include "platform/scheduler/base/time_domain.h" 10 #include "platform/scheduler/base/time_domain.h"
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 if (!main_thread_only().delayed_work_queue->Empty() || 314 if (!main_thread_only().delayed_work_queue->Empty() ||
315 !main_thread_only().delayed_incoming_queue.empty() || 315 !main_thread_only().delayed_incoming_queue.empty() ||
316 !main_thread_only().immediate_work_queue->Empty()) { 316 !main_thread_only().immediate_work_queue->Empty()) {
317 return false; 317 return false;
318 } 318 }
319 319
320 base::AutoLock lock(any_thread_lock_); 320 base::AutoLock lock(any_thread_lock_);
321 return any_thread().immediate_incoming_queue.empty(); 321 return any_thread().immediate_incoming_queue.empty();
322 } 322 }
323 323
324 size_t TaskQueueImpl::GetNumberOfPendingTasks() const {
325 size_t task_count = 0;
326 task_count += main_thread_only().delayed_work_queue->Size();
327 task_count += main_thread_only().delayed_incoming_queue.size();
328 task_count += main_thread_only().immediate_work_queue->Size();
329
330 base::AutoLock lock(any_thread_lock_);
331 task_count += any_thread().immediate_incoming_queue.size();
332 return task_count;
333 }
334
324 bool TaskQueueImpl::HasPendingImmediateWork() const { 335 bool TaskQueueImpl::HasPendingImmediateWork() const {
325 // Any work queue tasks count as immediate work. 336 // Any work queue tasks count as immediate work.
326 if (!main_thread_only().delayed_work_queue->Empty() || 337 if (!main_thread_only().delayed_work_queue->Empty() ||
327 !main_thread_only().immediate_work_queue->Empty()) { 338 !main_thread_only().immediate_work_queue->Empty()) {
328 return true; 339 return true;
329 } 340 }
330 341
331 // Tasks on |delayed_incoming_queue| that could run now, count as 342 // Tasks on |delayed_incoming_queue| that could run now, count as
332 // immediate work. 343 // immediate work.
333 if (!main_thread_only().delayed_incoming_queue.empty() && 344 if (!main_thread_only().delayed_incoming_queue.empty() &&
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 state->SetBoolean("is_cancelled", task.task.IsCancelled()); 707 state->SetBoolean("is_cancelled", task.task.IsCancelled());
697 state->SetDouble( 708 state->SetDouble(
698 "delayed_run_time", 709 "delayed_run_time",
699 (task.delayed_run_time - base::TimeTicks()).InMicroseconds() / 1000.0L); 710 (task.delayed_run_time - base::TimeTicks()).InMicroseconds() / 1000.0L);
700 state->EndDictionary(); 711 state->EndDictionary();
701 } 712 }
702 713
703 } // namespace internal 714 } // namespace internal
704 } // namespace scheduler 715 } // namespace scheduler
705 } // namespace blink 716 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698