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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl.cc

Issue 2118903002: scheduler: Move the Blink scheduler into Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another GYP fix Created 4 years, 5 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 "components/scheduler/renderer/renderer_scheduler_impl.h" 5 #include "platform/scheduler/renderer/renderer_scheduler_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/stack_trace.h" 8 #include "base/debug/stack_trace.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "base/trace_event/trace_event_argument.h" 13 #include "base/trace_event/trace_event_argument.h"
14 #include "cc/output/begin_frame_args.h" 14 #include "cc/output/begin_frame_args.h"
15 #include "components/scheduler/base/task_queue_impl.h" 15 #include "platform/scheduler/base/task_queue_impl.h"
16 #include "components/scheduler/base/task_queue_selector.h" 16 #include "platform/scheduler/base/task_queue_selector.h"
17 #include "components/scheduler/base/virtual_time_domain.h" 17 #include "platform/scheduler/base/virtual_time_domain.h"
18 #include "components/scheduler/child/scheduler_tqm_delegate.h" 18 #include "platform/scheduler/child/scheduler_tqm_delegate.h"
19 #include "components/scheduler/renderer/web_view_scheduler_impl.h" 19 #include "platform/scheduler/renderer/web_view_scheduler_impl.h"
20 #include "components/scheduler/renderer/webthread_impl_for_renderer_scheduler.h" 20 #include "platform/scheduler/renderer/webthread_impl_for_renderer_scheduler.h"
21 21
22 namespace blink {
22 namespace scheduler { 23 namespace scheduler {
23 namespace { 24 namespace {
24 // The run time of loading tasks is strongly bimodal. The vast majority are 25 // The run time of loading tasks is strongly bimodal. The vast majority are
25 // very cheap, but there are usually a handful of very expensive tasks (e.g ~1 26 // very cheap, but there are usually a handful of very expensive tasks (e.g ~1
26 // second on a mobile device) so we take a very pessimistic view when estimating 27 // second on a mobile device) so we take a very pessimistic view when estimating
27 // the cost of loading tasks. 28 // the cost of loading tasks.
28 const int kLoadingTaskEstimationSampleCount = 1000; 29 const int kLoadingTaskEstimationSampleCount = 1000;
29 const double kLoadingTaskEstimationPercentile = 99; 30 const double kLoadingTaskEstimationPercentile = 99;
30 const int kTimerTaskEstimationSampleCount = 1000; 31 const int kTimerTaskEstimationSampleCount = 1000;
31 const double kTimerTaskEstimationPercentile = 99; 32 const double kTimerTaskEstimationPercentile = 99;
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 641
641 base::TimeTicks RendererSchedulerImpl::CurrentIdleTaskDeadlineForTesting() 642 base::TimeTicks RendererSchedulerImpl::CurrentIdleTaskDeadlineForTesting()
642 const { 643 const {
643 return idle_helper_.CurrentIdleTaskDeadline(); 644 return idle_helper_.CurrentIdleTaskDeadline();
644 } 645 }
645 646
646 void RendererSchedulerImpl::RunIdleTasksForTesting( 647 void RendererSchedulerImpl::RunIdleTasksForTesting(
647 const base::Closure& callback) { 648 const base::Closure& callback) {
648 MainThreadOnly().in_idle_period_for_testing = true; 649 MainThreadOnly().in_idle_period_for_testing = true;
649 IdleTaskRunner()->PostIdleTask( 650 IdleTaskRunner()->PostIdleTask(
650 FROM_HERE, 651 FROM_HERE, base::Bind(&RendererSchedulerImpl::EndIdlePeriodForTesting,
651 base::Bind(&RendererSchedulerImpl::EndIdlePeriodForTesting, 652 weak_factory_.GetWeakPtr(), callback));
652 weak_factory_.GetWeakPtr(), callback));
653 idle_helper_.EnableLongIdlePeriod(); 653 idle_helper_.EnableLongIdlePeriod();
654 } 654 }
655 655
656 void RendererSchedulerImpl::MaybeUpdatePolicy() { 656 void RendererSchedulerImpl::MaybeUpdatePolicy() {
657 helper_.CheckOnValidThread(); 657 helper_.CheckOnValidThread();
658 if (policy_may_need_update_.IsSet()) { 658 if (policy_may_need_update_.IsSet()) {
659 UpdatePolicy(); 659 UpdatePolicy();
660 } 660 }
661 } 661 }
662 662
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 IdleTimeEstimator* RendererSchedulerImpl::GetIdleTimeEstimatorForTesting() { 1068 IdleTimeEstimator* RendererSchedulerImpl::GetIdleTimeEstimatorForTesting() {
1069 return &MainThreadOnly().idle_time_estimator; 1069 return &MainThreadOnly().idle_time_estimator;
1070 } 1070 }
1071 1071
1072 void RendererSchedulerImpl::SuspendTimerQueue() { 1072 void RendererSchedulerImpl::SuspendTimerQueue() {
1073 MainThreadOnly().timer_queue_suspend_count++; 1073 MainThreadOnly().timer_queue_suspend_count++;
1074 ForceUpdatePolicy(); 1074 ForceUpdatePolicy();
1075 #ifndef NDEBUG 1075 #ifndef NDEBUG
1076 DCHECK(!default_timer_task_runner_->IsQueueEnabled()); 1076 DCHECK(!default_timer_task_runner_->IsQueueEnabled());
1077 for (const auto& runner : timer_task_runners_) { 1077 for (const auto& runner : timer_task_runners_) {
1078 DCHECK(!runner->IsQueueEnabled()); 1078 DCHECK(!runner->IsQueueEnabled());
1079 } 1079 }
1080 #endif 1080 #endif
1081 } 1081 }
1082 1082
1083 void RendererSchedulerImpl::ResumeTimerQueue() { 1083 void RendererSchedulerImpl::ResumeTimerQueue() {
1084 MainThreadOnly().timer_queue_suspend_count--; 1084 MainThreadOnly().timer_queue_suspend_count--;
1085 DCHECK_GE(MainThreadOnly().timer_queue_suspend_count, 0); 1085 DCHECK_GE(MainThreadOnly().timer_queue_suspend_count, 0);
1086 ForceUpdatePolicy(); 1086 ForceUpdatePolicy();
1087 } 1087 }
1088 1088
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 1219
1220 void RendererSchedulerImpl::OnIdlePeriodEnded() { 1220 void RendererSchedulerImpl::OnIdlePeriodEnded() {
1221 base::AutoLock lock(any_thread_lock_); 1221 base::AutoLock lock(any_thread_lock_);
1222 AnyThread().last_idle_period_end_time = 1222 AnyThread().last_idle_period_end_time =
1223 helper_.scheduler_tqm_delegate()->NowTicks(); 1223 helper_.scheduler_tqm_delegate()->NowTicks();
1224 AnyThread().in_idle_period = false; 1224 AnyThread().in_idle_period = false;
1225 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); 1225 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED);
1226 } 1226 }
1227 1227
1228 void RendererSchedulerImpl::AddPendingNavigation( 1228 void RendererSchedulerImpl::AddPendingNavigation(
1229 blink::WebScheduler::NavigatingFrameType type) { 1229 blink::WebScheduler::NavigatingFrameType type) {
1230 helper_.CheckOnValidThread(); 1230 helper_.CheckOnValidThread();
1231 if (type == blink::WebScheduler::NavigatingFrameType::kMainFrame) { 1231 if (type == blink::WebScheduler::NavigatingFrameType::kMainFrame) {
1232 MainThreadOnly().navigation_task_expected_count++; 1232 MainThreadOnly().navigation_task_expected_count++;
1233 UpdatePolicy(); 1233 UpdatePolicy();
1234 } 1234 }
1235 } 1235 }
1236 1236
1237 void RendererSchedulerImpl::RemovePendingNavigation( 1237 void RendererSchedulerImpl::RemovePendingNavigation(
1238 blink::WebScheduler::NavigatingFrameType type) { 1238 blink::WebScheduler::NavigatingFrameType type) {
1239 helper_.CheckOnValidThread(); 1239 helper_.CheckOnValidThread();
1240 DCHECK_GT(MainThreadOnly().navigation_task_expected_count, 0); 1240 DCHECK_GT(MainThreadOnly().navigation_task_expected_count, 0);
1241 if (type == blink::WebScheduler::NavigatingFrameType::kMainFrame && 1241 if (type == blink::WebScheduler::NavigatingFrameType::kMainFrame &&
1242 MainThreadOnly().navigation_task_expected_count > 0) { 1242 MainThreadOnly().navigation_task_expected_count > 0) {
1243 MainThreadOnly().navigation_task_expected_count--; 1243 MainThreadOnly().navigation_task_expected_count--;
1244 UpdatePolicy(); 1244 UpdatePolicy();
1245 } 1245 }
1246 } 1246 }
1247 1247
1248 void RendererSchedulerImpl::OnNavigationStarted() { 1248 void RendererSchedulerImpl::OnNavigationStarted() {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 base::AutoLock lock(any_thread_lock_); 1376 base::AutoLock lock(any_thread_lock_);
1377 if (!AnyThread().have_seen_touchstart) 1377 if (!AnyThread().have_seen_touchstart)
1378 return; 1378 return;
1379 } 1379 }
1380 MainThreadOnly().have_reported_blocking_intervention_since_navigation = 1380 MainThreadOnly().have_reported_blocking_intervention_since_navigation =
1381 true; 1381 true;
1382 BroadcastConsoleWarning( 1382 BroadcastConsoleWarning(
1383 "Blink deferred a task in order to make scrolling smoother. " 1383 "Blink deferred a task in order to make scrolling smoother. "
1384 "Your timer and network tasks should take less than 50ms to run " 1384 "Your timer and network tasks should take less than 50ms to run "
1385 "to avoid this. Please see " 1385 "to avoid this. Please see "
1386 "https://developers.google.com/web/tools/chrome-devtools/profile/evaluat e-performance/rail" 1386 "https://developers.google.com/web/tools/chrome-devtools/profile/"
1387 "evaluate-performance/rail"
1387 " and https://crbug.com/574343#c40 for more information."); 1388 " and https://crbug.com/574343#c40 for more information.");
1388 } 1389 }
1389 } 1390 }
1390 1391
1391 void RendererSchedulerImpl::ReportTaskTime(base::TimeTicks start_time, 1392 void RendererSchedulerImpl::ReportTaskTime(base::TimeTicks start_time,
1392 base::TimeTicks end_time) { 1393 base::TimeTicks end_time) {
1393 MainThreadOnly().queueing_time_estimator.OnToplevelTaskCompleted(start_time, 1394 MainThreadOnly().queueing_time_estimator.OnToplevelTaskCompleted(start_time,
1394 end_time); 1395 end_time);
1395 } 1396 }
1396 1397
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1437 return "idle"; 1438 return "idle";
1438 case v8::PERFORMANCE_LOAD: 1439 case v8::PERFORMANCE_LOAD:
1439 return "load"; 1440 return "load";
1440 default: 1441 default:
1441 NOTREACHED(); 1442 NOTREACHED();
1442 return nullptr; 1443 return nullptr;
1443 } 1444 }
1444 } 1445 }
1445 1446
1446 } // namespace scheduler 1447 } // namespace scheduler
1448 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698