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

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

Issue 1381273002: A better idle time estimator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 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 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/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
10 #include "components/scheduler/base/pollable_thread_safe_flag.h" 10 #include "components/scheduler/base/pollable_thread_safe_flag.h"
11 #include "components/scheduler/child/idle_helper.h" 11 #include "components/scheduler/child/idle_helper.h"
12 #include "components/scheduler/child/scheduler_helper.h" 12 #include "components/scheduler/child/scheduler_helper.h"
13 #include "components/scheduler/renderer/deadline_task_runner.h" 13 #include "components/scheduler/renderer/deadline_task_runner.h"
14 #include "components/scheduler/renderer/idle_time_estimator.h"
14 #include "components/scheduler/renderer/renderer_scheduler.h" 15 #include "components/scheduler/renderer/renderer_scheduler.h"
15 #include "components/scheduler/renderer/task_cost_estimator.h" 16 #include "components/scheduler/renderer/task_cost_estimator.h"
16 #include "components/scheduler/renderer/user_model.h" 17 #include "components/scheduler/renderer/user_model.h"
17 #include "components/scheduler/scheduler_export.h" 18 #include "components/scheduler/scheduler_export.h"
18 19
19 namespace base { 20 namespace base {
20 namespace trace_event { 21 namespace trace_event {
21 class ConvertableToTraceFormat; 22 class ConvertableToTraceFormat;
22 } 23 }
23 } 24 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 void ResumeTimerQueue() override; 69 void ResumeTimerQueue() override;
69 void SetTimerQueueSuspensionWhenBackgroundedEnabled(bool enabled) override; 70 void SetTimerQueueSuspensionWhenBackgroundedEnabled(bool enabled) override;
70 71
71 // TaskQueueManager::Observer implementation: 72 // TaskQueueManager::Observer implementation:
72 void OnUnregisterTaskQueue(const scoped_refptr<TaskQueue>& queue) override; 73 void OnUnregisterTaskQueue(const scoped_refptr<TaskQueue>& queue) override;
73 74
74 // Test helpers. 75 // Test helpers.
75 SchedulerHelper* GetSchedulerHelperForTesting(); 76 SchedulerHelper* GetSchedulerHelperForTesting();
76 TaskCostEstimator* GetLoadingTaskCostEstimatorForTesting(); 77 TaskCostEstimator* GetLoadingTaskCostEstimatorForTesting();
77 TaskCostEstimator* GetTimerTaskCostEstimatorForTesting(); 78 TaskCostEstimator* GetTimerTaskCostEstimatorForTesting();
79 IdleTimeEstimator* GetIdleTimeEstimatorForTesting();
78 base::TimeTicks CurrentIdleTaskDeadlineForTesting() const; 80 base::TimeTicks CurrentIdleTaskDeadlineForTesting() const;
79 81
80 private: 82 private:
81 friend class RendererSchedulerImplTest; 83 friend class RendererSchedulerImplTest;
82 friend class RendererSchedulerImplForTest; 84 friend class RendererSchedulerImplForTest;
83 85
84 struct Policy { 86 struct Policy {
85 Policy(); 87 Policy();
86 88
87 TaskQueue::QueuePriority compositor_queue_priority; 89 TaskQueue::QueuePriority compositor_queue_priority;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 const blink::WebInputEvent& web_input_event); 137 const blink::WebInputEvent& web_input_event);
136 138
137 // The amount of time which idle periods can continue being scheduled when the 139 // The amount of time which idle periods can continue being scheduled when the
138 // renderer has been hidden, before going to sleep for good. 140 // renderer has been hidden, before going to sleep for good.
139 static const int kEndIdleWhenHiddenDelayMillis = 10000; 141 static const int kEndIdleWhenHiddenDelayMillis = 10000;
140 142
141 // The amount of time for which loading tasks will be prioritized over 143 // The amount of time for which loading tasks will be prioritized over
142 // other tasks during the initial page load. 144 // other tasks during the initial page load.
143 static const int kRailsInitialLoadingPrioritizationMillis = 1000; 145 static const int kRailsInitialLoadingPrioritizationMillis = 1000;
144 146
147 // The ammount of time in milliseconds we have to respond to user input as
Sami 2015/10/09 02:32:19 typo: amount
alex clarke (OOO till 29th) 2015/10/15 13:24:01 Done.
148 // defined by RAILS.
149 static const int kRailsResponseTimeMillis = 50;
150
145 // For the purposes of deciding whether or not it's safe to turn timers and 151 // For the purposes of deciding whether or not it's safe to turn timers and
146 // loading tasks on only in idle periods, we regard the system as being as 152 // loading tasks on only in idle periods, we regard the system as being as
147 // being "idle period" starved if there hasn't been an idle period in the last 153 // being "idle period" starved if there hasn't been an idle period in the last
148 // 10 seconds. This was chosen to be long enough to cover most anticipated 154 // 10 seconds. This was chosen to be long enough to cover most anticipated
149 // user gestures. 155 // user gestures.
150 static const int kIdlePeriodStarvationThresholdMillis = 10000; 156 static const int kIdlePeriodStarvationThresholdMillis = 10000;
151 157
152 // The amount of time to wait before suspending shared timers after the 158 // The amount of time to wait before suspending shared timers after the
153 // renderer has been backgrounded. This is used only if background suspension 159 // renderer has been backgrounded. This is used only if background suspension
154 // of shared timers is enabled. 160 // of shared timers is enabled.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 233
228 // We have decided to improve thread safety at the cost of some boilerplate 234 // We have decided to improve thread safety at the cost of some boilerplate
229 // (the accessors) for the following data members. 235 // (the accessors) for the following data members.
230 236
231 struct MainThreadOnly { 237 struct MainThreadOnly {
232 MainThreadOnly(); 238 MainThreadOnly();
233 ~MainThreadOnly(); 239 ~MainThreadOnly();
234 240
235 TaskCostEstimator loading_task_cost_estimator; 241 TaskCostEstimator loading_task_cost_estimator;
236 TaskCostEstimator timer_task_cost_estimator; 242 TaskCostEstimator timer_task_cost_estimator;
237 cc::RollingTimeDeltaHistory short_idle_period_duration; 243 IdleTimeEstimator idle_time_estimator;
238 UseCase current_use_case; 244 UseCase current_use_case;
239 Policy current_policy; 245 Policy current_policy;
240 base::TimeTicks current_policy_expiration_time; 246 base::TimeTicks current_policy_expiration_time;
241 base::TimeTicks estimated_next_frame_begin; 247 base::TimeTicks estimated_next_frame_begin;
242 base::TimeDelta expected_short_idle_period_duration; 248 base::TimeDelta compositor_frame_interval;
249 base::TimeDelta expected_idle_duration;
243 int timer_queue_suspend_count; // TIMER_TASK_QUEUE suspended if non-zero. 250 int timer_queue_suspend_count; // TIMER_TASK_QUEUE suspended if non-zero.
244 int navigation_task_expected_count; 251 int navigation_task_expected_count;
245 bool renderer_hidden; 252 bool renderer_hidden;
246 bool renderer_backgrounded; 253 bool renderer_backgrounded;
247 bool timer_queue_suspension_when_backgrounded_enabled; 254 bool timer_queue_suspension_when_backgrounded_enabled;
248 bool timer_queue_suspended_when_backgrounded; 255 bool timer_queue_suspended_when_backgrounded;
249 bool was_shutdown; 256 bool was_shutdown;
250 bool loading_tasks_seem_expensive; 257 bool loading_tasks_seem_expensive;
251 bool timer_tasks_seem_expensive; 258 bool timer_tasks_seem_expensive;
252 bool touchstart_expected_soon; 259 bool touchstart_expected_soon;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 321
315 PollableThreadSafeFlag policy_may_need_update_; 322 PollableThreadSafeFlag policy_may_need_update_;
316 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; 323 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_;
317 324
318 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); 325 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl);
319 }; 326 };
320 327
321 } // namespace scheduler 328 } // namespace scheduler
322 329
323 #endif // COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_IMPL_H_ 330 #endif // COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698