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

Side by Side Diff: components/scheduler/renderer/renderer_scheduler_impl.cc

Issue 2093983002: scheduler: Tell v8 about the current RAIL mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing gyp dependencies 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 "components/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"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 was_shutdown(false), 125 was_shutdown(false),
126 loading_tasks_seem_expensive(false), 126 loading_tasks_seem_expensive(false),
127 timer_tasks_seem_expensive(false), 127 timer_tasks_seem_expensive(false),
128 touchstart_expected_soon(false), 128 touchstart_expected_soon(false),
129 have_seen_a_begin_main_frame(false), 129 have_seen_a_begin_main_frame(false),
130 have_reported_blocking_intervention_in_current_policy(false), 130 have_reported_blocking_intervention_in_current_policy(false),
131 have_reported_blocking_intervention_since_navigation(false), 131 have_reported_blocking_intervention_since_navigation(false),
132 has_visible_render_widget_with_touch_handler(false), 132 has_visible_render_widget_with_touch_handler(false),
133 begin_frame_not_expected_soon(false), 133 begin_frame_not_expected_soon(false),
134 expensive_task_blocking_allowed(true), 134 expensive_task_blocking_allowed(true),
135 in_idle_period_for_testing(false) {} 135 in_idle_period_for_testing(false),
136 rail_mode_observer(nullptr) {}
136 137
137 RendererSchedulerImpl::MainThreadOnly::~MainThreadOnly() {} 138 RendererSchedulerImpl::MainThreadOnly::~MainThreadOnly() {}
138 139
139 RendererSchedulerImpl::AnyThread::AnyThread() 140 RendererSchedulerImpl::AnyThread::AnyThread()
140 : awaiting_touch_start_response(false), 141 : awaiting_touch_start_response(false),
141 in_idle_period(false), 142 in_idle_period(false),
142 begin_main_frame_on_critical_path(false), 143 begin_main_frame_on_critical_path(false),
143 last_gesture_was_compositor_driven(false), 144 last_gesture_was_compositor_driven(false),
144 default_gesture_prevented(true), 145 default_gesture_prevented(true),
145 have_seen_touchstart(false) {} 146 have_seen_touchstart(false) {}
146 147
147 RendererSchedulerImpl::AnyThread::~AnyThread() {} 148 RendererSchedulerImpl::AnyThread::~AnyThread() {}
148 149
149 RendererSchedulerImpl::CompositorThreadOnly::CompositorThreadOnly() 150 RendererSchedulerImpl::CompositorThreadOnly::CompositorThreadOnly()
150 : last_input_type(blink::WebInputEvent::Undefined) {} 151 : last_input_type(blink::WebInputEvent::Undefined) {}
151 152
152 RendererSchedulerImpl::CompositorThreadOnly::~CompositorThreadOnly() {} 153 RendererSchedulerImpl::CompositorThreadOnly::~CompositorThreadOnly() {}
153 154
154 void RendererSchedulerImpl::Shutdown() { 155 void RendererSchedulerImpl::Shutdown() {
155 throttling_helper_.reset(); 156 throttling_helper_.reset();
156 helper_.Shutdown(); 157 helper_.Shutdown();
157 MainThreadOnly().was_shutdown = true; 158 MainThreadOnly().was_shutdown = true;
159 MainThreadOnly().rail_mode_observer = nullptr;
158 } 160 }
159 161
160 std::unique_ptr<blink::WebThread> RendererSchedulerImpl::CreateMainThread() { 162 std::unique_ptr<blink::WebThread> RendererSchedulerImpl::CreateMainThread() {
161 return base::WrapUnique(new WebThreadImplForRendererScheduler(this)); 163 return base::WrapUnique(new WebThreadImplForRendererScheduler(this));
162 } 164 }
163 165
164 scoped_refptr<TaskQueue> RendererSchedulerImpl::DefaultTaskRunner() { 166 scoped_refptr<TaskQueue> RendererSchedulerImpl::DefaultTaskRunner() {
165 return helper_.DefaultTaskRunner(); 167 return helper_.DefaultTaskRunner();
166 } 168 }
167 169
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 // Avoid prioritizing main thread compositing (e.g., rAF) if it is extremely 726 // Avoid prioritizing main thread compositing (e.g., rAF) if it is extremely
725 // slow, because that can cause starvation in other task sources. 727 // slow, because that can cause starvation in other task sources.
726 bool main_thread_compositing_is_fast = 728 bool main_thread_compositing_is_fast =
727 MainThreadOnly().idle_time_estimator.GetExpectedIdleDuration( 729 MainThreadOnly().idle_time_estimator.GetExpectedIdleDuration(
728 MainThreadOnly().compositor_frame_interval) > 730 MainThreadOnly().compositor_frame_interval) >
729 MainThreadOnly().compositor_frame_interval * 731 MainThreadOnly().compositor_frame_interval *
730 kFastCompositingIdleTimeThreshold; 732 kFastCompositingIdleTimeThreshold;
731 733
732 Policy new_policy; 734 Policy new_policy;
733 ExpensiveTaskPolicy expensive_task_policy = ExpensiveTaskPolicy::RUN; 735 ExpensiveTaskPolicy expensive_task_policy = ExpensiveTaskPolicy::RUN;
736 new_policy.rail_mode = v8::PERFORMANCE_ANIMATION;
737
734 switch (use_case) { 738 switch (use_case) {
735 case UseCase::COMPOSITOR_GESTURE: 739 case UseCase::COMPOSITOR_GESTURE:
736 if (touchstart_expected_soon) { 740 if (touchstart_expected_soon) {
741 new_policy.rail_mode = v8::PERFORMANCE_RESPONSE;
737 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; 742 expensive_task_policy = ExpensiveTaskPolicy::BLOCK;
738 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY; 743 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY;
739 } else { 744 } else {
740 // What we really want to do is priorize loading tasks, but that doesn't 745 // What we really want to do is priorize loading tasks, but that doesn't
741 // seem to be safe. Instead we do that by proxy by deprioritizing 746 // seem to be safe. Instead we do that by proxy by deprioritizing
742 // compositor tasks. This should be safe since we've already gone to the 747 // compositor tasks. This should be safe since we've already gone to the
743 // pain of fixing ordering issues with them. 748 // pain of fixing ordering issues with them.
744 new_policy.compositor_queue_policy.priority = 749 new_policy.compositor_queue_policy.priority =
745 TaskQueue::BEST_EFFORT_PRIORITY; 750 TaskQueue::BEST_EFFORT_PRIORITY;
746 } 751 }
747 break; 752 break;
748 753
749 case UseCase::SYNCHRONIZED_GESTURE: 754 case UseCase::SYNCHRONIZED_GESTURE:
750 new_policy.compositor_queue_policy.priority = 755 new_policy.compositor_queue_policy.priority =
751 main_thread_compositing_is_fast ? TaskQueue::HIGH_PRIORITY 756 main_thread_compositing_is_fast ? TaskQueue::HIGH_PRIORITY
752 : TaskQueue::NORMAL_PRIORITY; 757 : TaskQueue::NORMAL_PRIORITY;
753 if (touchstart_expected_soon) { 758 if (touchstart_expected_soon) {
759 new_policy.rail_mode = v8::PERFORMANCE_RESPONSE;
754 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; 760 expensive_task_policy = ExpensiveTaskPolicy::BLOCK;
755 } else { 761 } else {
756 expensive_task_policy = ExpensiveTaskPolicy::THROTTLE; 762 expensive_task_policy = ExpensiveTaskPolicy::THROTTLE;
757 } 763 }
758 break; 764 break;
759 765
760 case UseCase::MAIN_THREAD_CUSTOM_INPUT_HANDLING: 766 case UseCase::MAIN_THREAD_CUSTOM_INPUT_HANDLING:
761 // In main thread input handling scenarios we don't have perfect knowledge 767 // In main thread input handling scenarios we don't have perfect knowledge
762 // about which things we should be prioritizing, so we don't attempt to 768 // about which things we should be prioritizing, so we don't attempt to
763 // block expensive tasks because we don't know whether they were integral 769 // block expensive tasks because we don't know whether they were integral
764 // to the page's functionality or not. 770 // to the page's functionality or not.
765 new_policy.compositor_queue_policy.priority = 771 new_policy.compositor_queue_policy.priority =
766 main_thread_compositing_is_fast ? TaskQueue::HIGH_PRIORITY 772 main_thread_compositing_is_fast ? TaskQueue::HIGH_PRIORITY
767 : TaskQueue::NORMAL_PRIORITY; 773 : TaskQueue::NORMAL_PRIORITY;
768 break; 774 break;
769 775
770 case UseCase::MAIN_THREAD_GESTURE: 776 case UseCase::MAIN_THREAD_GESTURE:
771 // A main thread gesture is for example a scroll gesture which is handled 777 // A main thread gesture is for example a scroll gesture which is handled
772 // by the main thread. Since we know the established gesture type, we can 778 // by the main thread. Since we know the established gesture type, we can
773 // be a little more aggressive about prioritizing compositing and input 779 // be a little more aggressive about prioritizing compositing and input
774 // handling over other tasks. 780 // handling over other tasks.
775 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY; 781 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY;
776 if (touchstart_expected_soon) { 782 if (touchstart_expected_soon) {
783 new_policy.rail_mode = v8::PERFORMANCE_RESPONSE;
777 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; 784 expensive_task_policy = ExpensiveTaskPolicy::BLOCK;
778 } else { 785 } else {
779 expensive_task_policy = ExpensiveTaskPolicy::THROTTLE; 786 expensive_task_policy = ExpensiveTaskPolicy::THROTTLE;
780 } 787 }
781 break; 788 break;
782 789
783 case UseCase::TOUCHSTART: 790 case UseCase::TOUCHSTART:
791 new_policy.rail_mode = v8::PERFORMANCE_RESPONSE;
784 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY; 792 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY;
785 new_policy.loading_queue_policy.is_enabled = false; 793 new_policy.loading_queue_policy.is_enabled = false;
786 new_policy.timer_queue_policy.is_enabled = false; 794 new_policy.timer_queue_policy.is_enabled = false;
787 // NOTE this is a nop due to the above. 795 // NOTE this is a nop due to the above.
788 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; 796 expensive_task_policy = ExpensiveTaskPolicy::BLOCK;
789 break; 797 break;
790 798
791 case UseCase::NONE: 799 case UseCase::NONE:
792 // It's only safe to block tasks that if we are expecting a compositor 800 // It's only safe to block tasks that if we are expecting a compositor
793 // driven gesture. 801 // driven gesture.
794 if (touchstart_expected_soon && 802 if (touchstart_expected_soon &&
795 AnyThread().last_gesture_was_compositor_driven) { 803 AnyThread().last_gesture_was_compositor_driven) {
804 new_policy.rail_mode = v8::PERFORMANCE_RESPONSE;
796 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; 805 expensive_task_policy = ExpensiveTaskPolicy::BLOCK;
797 } 806 }
798 break; 807 break;
799 808
800 case UseCase::LOADING: 809 case UseCase::LOADING:
810 new_policy.rail_mode = v8::PERFORMANCE_LOAD;
801 new_policy.loading_queue_policy.priority = TaskQueue::HIGH_PRIORITY; 811 new_policy.loading_queue_policy.priority = TaskQueue::HIGH_PRIORITY;
802 new_policy.default_queue_policy.priority = TaskQueue::HIGH_PRIORITY; 812 new_policy.default_queue_policy.priority = TaskQueue::HIGH_PRIORITY;
803 break; 813 break;
804 814
805 default: 815 default:
806 NOTREACHED(); 816 NOTREACHED();
807 } 817 }
808 818
819 // TODO(skyostil): Add an idle state for foreground tabs too.
820 if (MainThreadOnly().renderer_hidden)
821 new_policy.rail_mode = v8::PERFORMANCE_IDLE;
822
809 if (expensive_task_policy == ExpensiveTaskPolicy::BLOCK && 823 if (expensive_task_policy == ExpensiveTaskPolicy::BLOCK &&
810 (!MainThreadOnly().expensive_task_blocking_allowed || 824 (!MainThreadOnly().expensive_task_blocking_allowed ||
811 !MainThreadOnly().have_seen_a_begin_main_frame || 825 !MainThreadOnly().have_seen_a_begin_main_frame ||
812 MainThreadOnly().navigation_task_expected_count > 0)) { 826 MainThreadOnly().navigation_task_expected_count > 0)) {
813 expensive_task_policy = ExpensiveTaskPolicy::RUN; 827 expensive_task_policy = ExpensiveTaskPolicy::RUN;
814 } 828 }
815 829
816 switch (expensive_task_policy) { 830 switch (expensive_task_policy) {
817 case ExpensiveTaskPolicy::RUN: 831 case ExpensiveTaskPolicy::RUN:
818 break; 832 break;
(...skipping 30 matching lines...) Expand all
849 DCHECK(!new_policy.timer_queue_policy.is_enabled); 863 DCHECK(!new_policy.timer_queue_policy.is_enabled);
850 } 864 }
851 865
852 // Tracing is done before the early out check, because it's quite possible we 866 // Tracing is done before the early out check, because it's quite possible we
853 // will otherwise miss this information in traces. 867 // will otherwise miss this information in traces.
854 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( 868 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
855 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", 869 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler",
856 this, AsValueLocked(now)); 870 this, AsValueLocked(now));
857 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "use_case", 871 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "use_case",
858 use_case); 872 use_case);
873 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "rail_mode",
874 new_policy.rail_mode);
859 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), 875 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"),
860 "touchstart_expected_soon", 876 "touchstart_expected_soon",
861 MainThreadOnly().touchstart_expected_soon); 877 MainThreadOnly().touchstart_expected_soon);
862 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), 878 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"),
863 "expensive_task_policy", expensive_task_policy); 879 "expensive_task_policy", expensive_task_policy);
864 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), 880 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"),
865 "RendererScheduler.loading_tasks_seem_expensive", 881 "RendererScheduler.loading_tasks_seem_expensive",
866 MainThreadOnly().loading_tasks_seem_expensive); 882 MainThreadOnly().loading_tasks_seem_expensive);
867 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), 883 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"),
868 "RendererScheduler.timer_tasks_seem_expensive", 884 "RendererScheduler.timer_tasks_seem_expensive",
(...skipping 22 matching lines...) Expand all
891 } 907 }
892 MainThreadOnly().have_reported_blocking_intervention_in_current_policy = 908 MainThreadOnly().have_reported_blocking_intervention_in_current_policy =
893 false; 909 false;
894 910
895 // TODO(alexclarke): We shouldn't have to prioritize the default queue, but it 911 // TODO(alexclarke): We shouldn't have to prioritize the default queue, but it
896 // appears to be necessary since the order of loading tasks and IPCs (which 912 // appears to be necessary since the order of loading tasks and IPCs (which
897 // are mostly dispatched on the default queue) need to be preserved. 913 // are mostly dispatched on the default queue) need to be preserved.
898 ApplyTaskQueuePolicy(helper_.DefaultTaskRunner().get(), 914 ApplyTaskQueuePolicy(helper_.DefaultTaskRunner().get(),
899 MainThreadOnly().current_policy.default_queue_policy, 915 MainThreadOnly().current_policy.default_queue_policy,
900 new_policy.default_queue_policy); 916 new_policy.default_queue_policy);
917 if (MainThreadOnly().rail_mode_observer &&
918 new_policy.rail_mode != MainThreadOnly().current_policy.rail_mode) {
919 MainThreadOnly().rail_mode_observer->OnRAILModeChanged(
920 new_policy.rail_mode);
921 }
901 922
902 DCHECK(compositor_task_runner_->IsQueueEnabled()); 923 DCHECK(compositor_task_runner_->IsQueueEnabled());
903 MainThreadOnly().current_policy = new_policy; 924 MainThreadOnly().current_policy = new_policy;
904 } 925 }
905 926
906 void RendererSchedulerImpl::ApplyTaskQueuePolicy( 927 void RendererSchedulerImpl::ApplyTaskQueuePolicy(
907 TaskQueue* task_queue, 928 TaskQueue* task_queue,
908 const TaskQueuePolicy& old_task_queue_policy, 929 const TaskQueuePolicy& old_task_queue_policy,
909 const TaskQueuePolicy& new_task_queue_policy) const { 930 const TaskQueuePolicy& new_task_queue_policy) const {
910 if (old_task_queue_policy.is_enabled != new_task_queue_policy.is_enabled) { 931 if (old_task_queue_policy.is_enabled != new_task_queue_policy.is_enabled) {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 1108
1088 if (optional_now.is_null()) 1109 if (optional_now.is_null())
1089 optional_now = helper_.scheduler_tqm_delegate()->NowTicks(); 1110 optional_now = helper_.scheduler_tqm_delegate()->NowTicks();
1090 std::unique_ptr<base::trace_event::TracedValue> state( 1111 std::unique_ptr<base::trace_event::TracedValue> state(
1091 new base::trace_event::TracedValue()); 1112 new base::trace_event::TracedValue());
1092 state->SetBoolean( 1113 state->SetBoolean(
1093 "has_visible_render_widget_with_touch_handler", 1114 "has_visible_render_widget_with_touch_handler",
1094 MainThreadOnly().has_visible_render_widget_with_touch_handler); 1115 MainThreadOnly().has_visible_render_widget_with_touch_handler);
1095 state->SetString("current_use_case", 1116 state->SetString("current_use_case",
1096 UseCaseToString(MainThreadOnly().current_use_case)); 1117 UseCaseToString(MainThreadOnly().current_use_case));
1118 state->SetString("rail_mode",
1119 RAILModeToString(MainThreadOnly().current_policy.rail_mode));
1097 state->SetBoolean("expensive_task_blocking_allowed", 1120 state->SetBoolean("expensive_task_blocking_allowed",
1098 MainThreadOnly().expensive_task_blocking_allowed); 1121 MainThreadOnly().expensive_task_blocking_allowed);
1099 state->SetBoolean("loading_tasks_seem_expensive", 1122 state->SetBoolean("loading_tasks_seem_expensive",
1100 MainThreadOnly().loading_tasks_seem_expensive); 1123 MainThreadOnly().loading_tasks_seem_expensive);
1101 state->SetBoolean("timer_tasks_seem_expensive", 1124 state->SetBoolean("timer_tasks_seem_expensive",
1102 MainThreadOnly().timer_tasks_seem_expensive); 1125 MainThreadOnly().timer_tasks_seem_expensive);
1103 state->SetBoolean("begin_frame_not_expected_soon", 1126 state->SetBoolean("begin_frame_not_expected_soon",
1104 MainThreadOnly().begin_frame_not_expected_soon); 1127 MainThreadOnly().begin_frame_not_expected_soon);
1105 state->SetBoolean("touchstart_expected_soon", 1128 state->SetBoolean("touchstart_expected_soon",
1106 MainThreadOnly().touchstart_expected_soon); 1129 MainThreadOnly().touchstart_expected_soon);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 // Per-frame task runners (loading, timers, etc.) are configured with a more 1289 // Per-frame task runners (loading, timers, etc.) are configured with a more
1267 // specific blame context by WebFrameSchedulerImpl. 1290 // specific blame context by WebFrameSchedulerImpl.
1268 control_task_runner_->SetBlameContext(blame_context); 1291 control_task_runner_->SetBlameContext(blame_context);
1269 DefaultTaskRunner()->SetBlameContext(blame_context); 1292 DefaultTaskRunner()->SetBlameContext(blame_context);
1270 default_loading_task_runner_->SetBlameContext(blame_context); 1293 default_loading_task_runner_->SetBlameContext(blame_context);
1271 default_timer_task_runner_->SetBlameContext(blame_context); 1294 default_timer_task_runner_->SetBlameContext(blame_context);
1272 compositor_task_runner_->SetBlameContext(blame_context); 1295 compositor_task_runner_->SetBlameContext(blame_context);
1273 idle_helper_.IdleTaskRunner()->SetBlameContext(blame_context); 1296 idle_helper_.IdleTaskRunner()->SetBlameContext(blame_context);
1274 } 1297 }
1275 1298
1299 void RendererSchedulerImpl::SetRAILModeObserver(RAILModeObserver* observer) {
1300 MainThreadOnly().rail_mode_observer = observer;
1301 }
1302
1276 void RendererSchedulerImpl::RegisterTimeDomain(TimeDomain* time_domain) { 1303 void RendererSchedulerImpl::RegisterTimeDomain(TimeDomain* time_domain) {
1277 helper_.RegisterTimeDomain(time_domain); 1304 helper_.RegisterTimeDomain(time_domain);
1278 } 1305 }
1279 1306
1280 void RendererSchedulerImpl::UnregisterTimeDomain(TimeDomain* time_domain) { 1307 void RendererSchedulerImpl::UnregisterTimeDomain(TimeDomain* time_domain) {
1281 helper_.UnregisterTimeDomain(time_domain); 1308 helper_.UnregisterTimeDomain(time_domain);
1282 } 1309 }
1283 1310
1284 void RendererSchedulerImpl::SetExpensiveTaskBlockingAllowed(bool allowed) { 1311 void RendererSchedulerImpl::SetExpensiveTaskBlockingAllowed(bool allowed) {
1285 MainThreadOnly().expensive_task_blocking_allowed = allowed; 1312 MainThreadOnly().expensive_task_blocking_allowed = allowed;
1286 } 1313 }
1287 1314
1288 base::TickClock* RendererSchedulerImpl::tick_clock() const { 1315 base::TickClock* RendererSchedulerImpl::tick_clock() const {
1289 return helper_.scheduler_tqm_delegate().get(); 1316 return helper_.scheduler_tqm_delegate().get();
1290 } 1317 }
1291 1318
1292 void RendererSchedulerImpl::AddWebViewScheduler( 1319 void RendererSchedulerImpl::AddWebViewScheduler(
1293 WebViewSchedulerImpl* web_view_scheduler) { 1320 WebViewSchedulerImpl* web_view_scheduler) {
1294 MainThreadOnly().web_view_schedulers_.insert(web_view_scheduler); 1321 MainThreadOnly().web_view_schedulers.insert(web_view_scheduler);
1295 } 1322 }
1296 1323
1297 void RendererSchedulerImpl::RemoveWebViewScheduler( 1324 void RendererSchedulerImpl::RemoveWebViewScheduler(
1298 WebViewSchedulerImpl* web_view_scheduler) { 1325 WebViewSchedulerImpl* web_view_scheduler) {
1299 DCHECK(MainThreadOnly().web_view_schedulers_.find(web_view_scheduler) != 1326 DCHECK(MainThreadOnly().web_view_schedulers.find(web_view_scheduler) !=
1300 MainThreadOnly().web_view_schedulers_.end()); 1327 MainThreadOnly().web_view_schedulers.end());
1301 MainThreadOnly().web_view_schedulers_.erase(web_view_scheduler); 1328 MainThreadOnly().web_view_schedulers.erase(web_view_scheduler);
1302 } 1329 }
1303 1330
1304 void RendererSchedulerImpl::BroadcastConsoleWarning( 1331 void RendererSchedulerImpl::BroadcastConsoleWarning(
1305 const std::string& message) { 1332 const std::string& message) {
1306 helper_.CheckOnValidThread(); 1333 helper_.CheckOnValidThread();
1307 for (auto& web_view_scheduler : MainThreadOnly().web_view_schedulers_) 1334 for (auto& web_view_scheduler : MainThreadOnly().web_view_schedulers)
1308 web_view_scheduler->AddConsoleWarning(message); 1335 web_view_scheduler->AddConsoleWarning(message);
1309 } 1336 }
1310 1337
1311 void RendererSchedulerImpl::OnTriedToExecuteBlockedTask( 1338 void RendererSchedulerImpl::OnTriedToExecuteBlockedTask(
1312 const TaskQueue& queue, 1339 const TaskQueue& queue,
1313 const base::PendingTask& task) { 1340 const base::PendingTask& task) {
1314 if (!MainThreadOnly().expensive_task_blocking_allowed || 1341 if (!MainThreadOnly().expensive_task_blocking_allowed ||
1315 MainThreadOnly().current_use_case == UseCase::TOUCHSTART || 1342 MainThreadOnly().current_use_case == UseCase::TOUCHSTART ||
1316 MainThreadOnly().longest_jank_free_task_duration < 1343 MainThreadOnly().longest_jank_free_task_duration <
1317 base::TimeDelta::FromMilliseconds(kRailsResponseTimeMillis) || 1344 base::TimeDelta::FromMilliseconds(kRailsResponseTimeMillis) ||
(...skipping 23 matching lines...) Expand all
1341 true; 1368 true;
1342 BroadcastConsoleWarning( 1369 BroadcastConsoleWarning(
1343 "Blink deferred a task in order to make scrolling smoother. " 1370 "Blink deferred a task in order to make scrolling smoother. "
1344 "Your timer and network tasks should take less than 50ms to run " 1371 "Your timer and network tasks should take less than 50ms to run "
1345 "to avoid this. Please see " 1372 "to avoid this. Please see "
1346 "https://developers.google.com/web/tools/chrome-devtools/profile/evaluat e-performance/rail" 1373 "https://developers.google.com/web/tools/chrome-devtools/profile/evaluat e-performance/rail"
1347 " and https://crbug.com/574343#c40 for more information."); 1374 " and https://crbug.com/574343#c40 for more information.");
1348 } 1375 }
1349 } 1376 }
1350 1377
1378 // static
1379 const char* RendererSchedulerImpl::UseCaseToString(UseCase use_case) {
1380 switch (use_case) {
1381 case UseCase::NONE:
1382 return "none";
1383 case UseCase::COMPOSITOR_GESTURE:
1384 return "compositor_gesture";
1385 case UseCase::MAIN_THREAD_CUSTOM_INPUT_HANDLING:
1386 return "main_thread_custom_input_handling";
1387 case UseCase::SYNCHRONIZED_GESTURE:
1388 return "synchronized_gesture";
1389 case UseCase::TOUCHSTART:
1390 return "touchstart";
1391 case UseCase::LOADING:
1392 return "loading";
1393 case UseCase::MAIN_THREAD_GESTURE:
1394 return "main_thread_gesture";
1395 default:
1396 NOTREACHED();
1397 return nullptr;
1398 }
1399 }
1400
1401 // static
1402 const char* RendererSchedulerImpl::RAILModeToString(v8::RAILMode rail_mode) {
1403 switch (rail_mode) {
1404 case v8::PERFORMANCE_RESPONSE:
1405 return "response";
1406 case v8::PERFORMANCE_ANIMATION:
1407 return "animation";
1408 case v8::PERFORMANCE_IDLE:
1409 return "idle";
1410 case v8::PERFORMANCE_LOAD:
1411 return "load";
1412 default:
1413 NOTREACHED();
1414 return nullptr;
1415 }
1416 }
1417
1351 } // namespace scheduler 1418 } // namespace scheduler
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698