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

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

Issue 2093983002: scheduler: Tell v8 about the current RAIL mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 #ifndef COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_IMPL_H_ 5 #ifndef COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_IMPL_H_
6 #define COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_IMPL_H_ 6 #define COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_IMPL_H_
7 7
8 #include "base/atomicops.h" 8 #include "base/atomicops.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
11 #include "components/scheduler/base/pollable_thread_safe_flag.h" 11 #include "components/scheduler/base/pollable_thread_safe_flag.h"
12 #include "components/scheduler/child/idle_helper.h" 12 #include "components/scheduler/child/idle_helper.h"
13 #include "components/scheduler/child/scheduler_helper.h" 13 #include "components/scheduler/child/scheduler_helper.h"
14 #include "components/scheduler/renderer/deadline_task_runner.h" 14 #include "components/scheduler/renderer/deadline_task_runner.h"
15 #include "components/scheduler/renderer/idle_time_estimator.h" 15 #include "components/scheduler/renderer/idle_time_estimator.h"
16 #include "components/scheduler/renderer/render_widget_signals.h" 16 #include "components/scheduler/renderer/render_widget_signals.h"
17 #include "components/scheduler/renderer/renderer_scheduler.h" 17 #include "components/scheduler/renderer/renderer_scheduler.h"
18 #include "components/scheduler/renderer/task_cost_estimator.h" 18 #include "components/scheduler/renderer/task_cost_estimator.h"
19 #include "components/scheduler/renderer/throttling_helper.h" 19 #include "components/scheduler/renderer/throttling_helper.h"
20 #include "components/scheduler/renderer/user_model.h" 20 #include "components/scheduler/renderer/user_model.h"
21 #include "components/scheduler/renderer/web_view_scheduler_impl.h" 21 #include "components/scheduler/renderer/web_view_scheduler_impl.h"
22 #include "components/scheduler/scheduler_export.h" 22 #include "components/scheduler/scheduler_export.h"
23 #include "v8/include/v8.h"
23 24
24 namespace base { 25 namespace base {
25 namespace trace_event { 26 namespace trace_event {
26 class ConvertableToTraceFormat; 27 class ConvertableToTraceFormat;
27 } 28 }
28 } 29 }
29 30
30 namespace scheduler { 31 namespace scheduler {
31 class RenderWidgetSchedulingState; 32 class RenderWidgetSchedulingState;
32 class WebViewSchedulerImpl; 33 class WebViewSchedulerImpl;
33 class ThrottlingHelper; 34 class ThrottlingHelper;
34 35
35 class SCHEDULER_EXPORT RendererSchedulerImpl 36 class SCHEDULER_EXPORT RendererSchedulerImpl
36 : public RendererScheduler, 37 : public RendererScheduler,
37 public IdleHelper::Delegate, 38 public IdleHelper::Delegate,
38 public SchedulerHelper::Observer, 39 public SchedulerHelper::Observer,
39 public RenderWidgetSignals::Observer { 40 public RenderWidgetSignals::Observer {
40 public: 41 public:
42 // Keep RendererScheduler::UseCaseToString in sync with this enum.
43 enum class UseCase {
44 // No active use case detected.
45 NONE,
46 // A continuous gesture (e.g., scroll, pinch) which is being driven by the
47 // compositor thread.
48 COMPOSITOR_GESTURE,
49 // An unspecified touch gesture which is being handled by the main thread.
50 // Note that since we don't have a full view of the use case, we should be
51 // careful to prioritize all work equally.
52 MAIN_THREAD_CUSTOM_INPUT_HANDLING,
53 // A continuous gesture (e.g., scroll, pinch) which is being driven by the
54 // compositor thread but also observed by the main thread. An example is
55 // synchronized scrolling where a scroll listener on the main thread changes
56 // page layout based on the current scroll position.
57 SYNCHRONIZED_GESTURE,
58 // A gesture has recently started and we are about to run main thread touch
59 // listeners to find out the actual gesture type. To minimize touch latency,
60 // only input handling work should run in this state.
61 TOUCHSTART,
62 // The page is loading.
63 LOADING,
64 // A continuous gesture (e.g., scroll) which is being handled by the main
65 // thread.
66 MAIN_THREAD_GESTURE,
67 // Must be the last entry.
68 USE_CASE_COUNT,
69 FIRST_USE_CASE = NONE,
70 };
71 static const char* UseCaseToString(UseCase use_case);
72 static const char* RAILModeToString(v8::RAILMode rail_mode);
73
41 RendererSchedulerImpl(scoped_refptr<SchedulerTqmDelegate> main_task_runner); 74 RendererSchedulerImpl(scoped_refptr<SchedulerTqmDelegate> main_task_runner);
42 ~RendererSchedulerImpl() override; 75 ~RendererSchedulerImpl() override;
43 76
44 // RendererScheduler implementation: 77 // RendererScheduler implementation:
45 std::unique_ptr<blink::WebThread> CreateMainThread() override; 78 std::unique_ptr<blink::WebThread> CreateMainThread() override;
46 scoped_refptr<TaskQueue> DefaultTaskRunner() override; 79 scoped_refptr<TaskQueue> DefaultTaskRunner() override;
47 scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner() override; 80 scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner() override;
48 scoped_refptr<TaskQueue> CompositorTaskRunner() override; 81 scoped_refptr<TaskQueue> CompositorTaskRunner() override;
49 scoped_refptr<TaskQueue> LoadingTaskRunner() override; 82 scoped_refptr<TaskQueue> LoadingTaskRunner() override;
50 scoped_refptr<TaskQueue> TimerTaskRunner() override; 83 scoped_refptr<TaskQueue> TimerTaskRunner() override;
(...skipping 23 matching lines...) Expand all
74 bool CanExceedIdleDeadlineIfRequired() const override; 107 bool CanExceedIdleDeadlineIfRequired() const override;
75 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override; 108 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override;
76 void RemoveTaskObserver( 109 void RemoveTaskObserver(
77 base::MessageLoop::TaskObserver* task_observer) override; 110 base::MessageLoop::TaskObserver* task_observer) override;
78 void Shutdown() override; 111 void Shutdown() override;
79 void SuspendTimerQueue() override; 112 void SuspendTimerQueue() override;
80 void ResumeTimerQueue() override; 113 void ResumeTimerQueue() override;
81 void SetTimerQueueSuspensionWhenBackgroundedEnabled(bool enabled) override; 114 void SetTimerQueueSuspensionWhenBackgroundedEnabled(bool enabled) override;
82 void SetTopLevelBlameContext( 115 void SetTopLevelBlameContext(
83 base::trace_event::BlameContext* blame_context) override; 116 base::trace_event::BlameContext* blame_context) override;
117 void SetMainThreadIsolate(v8::Isolate* isolate) override;
84 118
85 // RenderWidgetSignals::Observer implementation: 119 // RenderWidgetSignals::Observer implementation:
86 void SetAllRenderWidgetsHidden(bool hidden) override; 120 void SetAllRenderWidgetsHidden(bool hidden) override;
87 void SetHasVisibleRenderWidgetWithTouchHandler( 121 void SetHasVisibleRenderWidgetWithTouchHandler(
88 bool has_visible_render_widget_with_touch_handler) override; 122 bool has_visible_render_widget_with_touch_handler) override;
89 123
90 // SchedulerHelper::Observer implementation: 124 // SchedulerHelper::Observer implementation:
91 void OnUnregisterTaskQueue(const scoped_refptr<TaskQueue>& queue) override; 125 void OnUnregisterTaskQueue(const scoped_refptr<TaskQueue>& queue) override;
92 void OnTriedToExecuteBlockedTask(const TaskQueue& queue, 126 void OnTriedToExecuteBlockedTask(const TaskQueue& queue,
93 const base::PendingTask& task) override; 127 const base::PendingTask& task) override;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 return is_enabled == other.is_enabled && priority == other.priority && 182 return is_enabled == other.is_enabled && priority == other.priority &&
149 time_domain_type == other.time_domain_type; 183 time_domain_type == other.time_domain_type;
150 } 184 }
151 }; 185 };
152 186
153 struct Policy { 187 struct Policy {
154 TaskQueuePolicy compositor_queue_policy; 188 TaskQueuePolicy compositor_queue_policy;
155 TaskQueuePolicy loading_queue_policy; 189 TaskQueuePolicy loading_queue_policy;
156 TaskQueuePolicy timer_queue_policy; 190 TaskQueuePolicy timer_queue_policy;
157 TaskQueuePolicy default_queue_policy; 191 TaskQueuePolicy default_queue_policy;
192 v8::RAILMode rail_mode = v8::PERFORMANCE_DEFAULT;
158 193
159 bool operator==(const Policy& other) const { 194 bool operator==(const Policy& other) const {
160 return compositor_queue_policy == other.compositor_queue_policy && 195 return compositor_queue_policy == other.compositor_queue_policy &&
161 loading_queue_policy == other.loading_queue_policy && 196 loading_queue_policy == other.loading_queue_policy &&
162 timer_queue_policy == other.timer_queue_policy && 197 timer_queue_policy == other.timer_queue_policy &&
163 default_queue_policy == other.default_queue_policy; 198 default_queue_policy == other.default_queue_policy &&
199 rail_mode == other.rail_mode;
164 } 200 }
165 }; 201 };
166 202
167 class PollableNeedsUpdateFlag { 203 class PollableNeedsUpdateFlag {
168 public: 204 public:
169 PollableNeedsUpdateFlag(base::Lock* write_lock); 205 PollableNeedsUpdateFlag(base::Lock* write_lock);
170 ~PollableNeedsUpdateFlag(); 206 ~PollableNeedsUpdateFlag();
171 207
172 // Set the flag. May only be called if |write_lock| is held. 208 // Set the flag. May only be called if |write_lock| is held.
173 void SetWhileLocked(bool value); 209 void SetWhileLocked(bool value);
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 bool loading_tasks_seem_expensive; 377 bool loading_tasks_seem_expensive;
342 bool timer_tasks_seem_expensive; 378 bool timer_tasks_seem_expensive;
343 bool touchstart_expected_soon; 379 bool touchstart_expected_soon;
344 bool have_seen_a_begin_main_frame; 380 bool have_seen_a_begin_main_frame;
345 bool have_reported_blocking_intervention_in_current_policy; 381 bool have_reported_blocking_intervention_in_current_policy;
346 bool have_reported_blocking_intervention_since_navigation; 382 bool have_reported_blocking_intervention_since_navigation;
347 bool has_visible_render_widget_with_touch_handler; 383 bool has_visible_render_widget_with_touch_handler;
348 bool begin_frame_not_expected_soon; 384 bool begin_frame_not_expected_soon;
349 bool expensive_task_blocking_allowed; 385 bool expensive_task_blocking_allowed;
350 bool in_idle_period_for_testing; 386 bool in_idle_period_for_testing;
351 std::set<WebViewSchedulerImpl*> web_view_schedulers_; // Not owned. 387 std::set<WebViewSchedulerImpl*> web_view_schedulers; // Not owned.
388 v8::Isolate* isolate; // Not owned.
352 }; 389 };
353 390
354 struct AnyThread { 391 struct AnyThread {
355 AnyThread(); 392 AnyThread();
356 ~AnyThread(); 393 ~AnyThread();
357 394
358 base::TimeTicks last_idle_period_end_time; 395 base::TimeTicks last_idle_period_end_time;
359 base::TimeTicks rails_loading_priority_deadline; 396 base::TimeTicks rails_loading_priority_deadline;
360 base::TimeTicks fling_compositor_escalation_deadline; 397 base::TimeTicks fling_compositor_escalation_deadline;
361 UserModel user_model; 398 UserModel user_model;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 454
418 PollableThreadSafeFlag policy_may_need_update_; 455 PollableThreadSafeFlag policy_may_need_update_;
419 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; 456 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_;
420 457
421 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); 458 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl);
422 }; 459 };
423 460
424 } // namespace scheduler 461 } // namespace scheduler
425 462
426 #endif // COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_IMPL_H_ 463 #endif // COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698