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

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

Issue 2246493002: Revert of Change VirtualTimePolicy::PAUSE_IF_NETWORK_FETCHES_PENDING (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | components/scheduler/renderer/renderer_scheduler_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 13 matching lines...) Expand all
24 #include "components/scheduler/renderer/web_view_scheduler_impl.h" 24 #include "components/scheduler/renderer/web_view_scheduler_impl.h"
25 #include "components/scheduler/scheduler_export.h" 25 #include "components/scheduler/scheduler_export.h"
26 26
27 namespace base { 27 namespace base {
28 namespace trace_event { 28 namespace trace_event {
29 class ConvertableToTraceFormat; 29 class ConvertableToTraceFormat;
30 } 30 }
31 } 31 }
32 32
33 namespace scheduler { 33 namespace scheduler {
34 class AutoAdvancingVirtualTimeDomain;
35 class RenderWidgetSchedulingState; 34 class RenderWidgetSchedulingState;
36 class WebViewSchedulerImpl; 35 class WebViewSchedulerImpl;
37 class ThrottlingHelper; 36 class ThrottlingHelper;
38 37
39 class SCHEDULER_EXPORT RendererSchedulerImpl 38 class SCHEDULER_EXPORT RendererSchedulerImpl
40 : public RendererScheduler, 39 : public RendererScheduler,
41 public IdleHelper::Delegate, 40 public IdleHelper::Delegate,
42 public SchedulerHelper::Observer, 41 public SchedulerHelper::Observer,
43 public RenderWidgetSignals::Observer, 42 public RenderWidgetSignals::Observer,
44 public TaskTimeTracker, 43 public TaskTimeTracker,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 137
139 // QueueingTimeEstimator::Client implementation: 138 // QueueingTimeEstimator::Client implementation:
140 void OnQueueingTimeForWindowEstimated(base::TimeDelta queueing_time) override; 139 void OnQueueingTimeForWindowEstimated(base::TimeDelta queueing_time) override;
141 140
142 // Returns a task runner where tasks run at the highest possible priority. 141 // Returns a task runner where tasks run at the highest possible priority.
143 scoped_refptr<TaskQueue> ControlTaskRunner(); 142 scoped_refptr<TaskQueue> ControlTaskRunner();
144 143
145 void RegisterTimeDomain(TimeDomain* time_domain); 144 void RegisterTimeDomain(TimeDomain* time_domain);
146 void UnregisterTimeDomain(TimeDomain* time_domain); 145 void UnregisterTimeDomain(TimeDomain* time_domain);
147 146
148 // Tells the scheduler that all TaskQueues should use virtual time.
149 void EnableVirtualTime();
150
151 void SetExpensiveTaskBlockingAllowed(bool allowed); 147 void SetExpensiveTaskBlockingAllowed(bool allowed);
152 148
153 void AddWebViewScheduler(WebViewSchedulerImpl* web_view_scheduler); 149 void AddWebViewScheduler(WebViewSchedulerImpl* web_view_scheduler);
154 void RemoveWebViewScheduler(WebViewSchedulerImpl* web_view_scheduler); 150 void RemoveWebViewScheduler(WebViewSchedulerImpl* web_view_scheduler);
155 151
156 LongTaskTracker::LongTaskTiming GetLongTaskTiming(); 152 LongTaskTracker::LongTaskTiming GetLongTaskTiming();
157 153
158 // Test helpers. 154 // Test helpers.
159 SchedulerHelper* GetSchedulerHelperForTesting(); 155 SchedulerHelper* GetSchedulerHelperForTesting();
160 TaskCostEstimator* GetLoadingTaskCostEstimatorForTesting(); 156 TaskCostEstimator* GetLoadingTaskCostEstimatorForTesting();
161 TaskCostEstimator* GetTimerTaskCostEstimatorForTesting(); 157 TaskCostEstimator* GetTimerTaskCostEstimatorForTesting();
162 IdleTimeEstimator* GetIdleTimeEstimatorForTesting(); 158 IdleTimeEstimator* GetIdleTimeEstimatorForTesting();
163 base::TimeTicks CurrentIdleTaskDeadlineForTesting() const; 159 base::TimeTicks CurrentIdleTaskDeadlineForTesting() const;
164 void RunIdleTasksForTesting(const base::Closure& callback); 160 void RunIdleTasksForTesting(const base::Closure& callback);
165 void EndIdlePeriodForTesting(const base::Closure& callback, 161 void EndIdlePeriodForTesting(const base::Closure& callback,
166 base::TimeTicks time_remaining); 162 base::TimeTicks time_remaining);
167 bool PolicyNeedsUpdateForTesting(); 163 bool PolicyNeedsUpdateForTesting();
168 164
169 base::TickClock* tick_clock() const; 165 base::TickClock* tick_clock() const;
170 166
171 RealTimeDomain* real_time_domain() const { 167 RealTimeDomain* real_time_domain() const {
172 return helper_.real_time_domain(); 168 return helper_.real_time_domain();
173 } 169 }
174 170
175 AutoAdvancingVirtualTimeDomain* GetVirtualTimeDomain();
176
177 ThrottlingHelper* throttling_helper() { return throttling_helper_.get(); } 171 ThrottlingHelper* throttling_helper() { return throttling_helper_.get(); }
178 172
179 private: 173 private:
180 friend class RendererSchedulerImplTest; 174 friend class RendererSchedulerImplTest;
181 friend class RendererSchedulerImplForTest; 175 friend class RendererSchedulerImplForTest;
182 friend class RenderWidgetSchedulingState; 176 friend class RenderWidgetSchedulingState;
183 177
184 enum class ExpensiveTaskPolicy { RUN, BLOCK, THROTTLE }; 178 enum class ExpensiveTaskPolicy { RUN, BLOCK, THROTTLE };
185 179
186 enum class TimeDomainType { 180 enum class TimeDomainType {
187 REAL, 181 REAL,
188 THROTTLED, 182 THROTTLED,
189 VIRTUAL,
190 }; 183 };
191 184
192 struct TaskQueuePolicy { 185 struct TaskQueuePolicy {
193 TaskQueuePolicy() 186 TaskQueuePolicy()
194 : is_enabled(true), 187 : is_enabled(true),
195 priority(TaskQueue::NORMAL_PRIORITY), 188 priority(TaskQueue::NORMAL_PRIORITY),
196 time_domain_type(TimeDomainType::REAL) {} 189 time_domain_type(TimeDomainType::REAL) {}
197 190
198 bool is_enabled; 191 bool is_enabled;
199 TaskQueue::QueuePriority priority; 192 TaskQueue::QueuePriority priority;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 347
355 SchedulerHelper helper_; 348 SchedulerHelper helper_;
356 IdleHelper idle_helper_; 349 IdleHelper idle_helper_;
357 std::unique_ptr<ThrottlingHelper> throttling_helper_; 350 std::unique_ptr<ThrottlingHelper> throttling_helper_;
358 RenderWidgetSignals render_widget_scheduler_signals_; 351 RenderWidgetSignals render_widget_scheduler_signals_;
359 352
360 const scoped_refptr<TaskQueue> control_task_runner_; 353 const scoped_refptr<TaskQueue> control_task_runner_;
361 const scoped_refptr<TaskQueue> compositor_task_runner_; 354 const scoped_refptr<TaskQueue> compositor_task_runner_;
362 std::set<scoped_refptr<TaskQueue>> loading_task_runners_; 355 std::set<scoped_refptr<TaskQueue>> loading_task_runners_;
363 std::set<scoped_refptr<TaskQueue>> timer_task_runners_; 356 std::set<scoped_refptr<TaskQueue>> timer_task_runners_;
364 std::set<scoped_refptr<TaskQueue>> unthrottled_task_runners_;
365 scoped_refptr<TaskQueue> default_loading_task_runner_; 357 scoped_refptr<TaskQueue> default_loading_task_runner_;
366 scoped_refptr<TaskQueue> default_timer_task_runner_; 358 scoped_refptr<TaskQueue> default_timer_task_runner_;
367 359
368 // Note |virtual_time_domain_| is lazily created.
369 std::unique_ptr<AutoAdvancingVirtualTimeDomain> virtual_time_domain_;
370
371 base::Closure update_policy_closure_; 360 base::Closure update_policy_closure_;
372 DeadlineTaskRunner delayed_update_policy_runner_; 361 DeadlineTaskRunner delayed_update_policy_runner_;
373 CancelableClosureHolder end_renderer_hidden_idle_period_closure_; 362 CancelableClosureHolder end_renderer_hidden_idle_period_closure_;
374 CancelableClosureHolder suspend_timers_when_backgrounded_closure_; 363 CancelableClosureHolder suspend_timers_when_backgrounded_closure_;
375 364
376 // We have decided to improve thread safety at the cost of some boilerplate 365 // We have decided to improve thread safety at the cost of some boilerplate
377 // (the accessors) for the following data members. 366 // (the accessors) for the following data members.
378 367
379 struct MainThreadOnly { 368 struct MainThreadOnly {
380 MainThreadOnly(RendererSchedulerImpl* renderer_scheduler_impl, 369 MainThreadOnly(RendererSchedulerImpl* renderer_scheduler_impl,
(...skipping 24 matching lines...) Expand all
405 bool loading_tasks_seem_expensive; 394 bool loading_tasks_seem_expensive;
406 bool timer_tasks_seem_expensive; 395 bool timer_tasks_seem_expensive;
407 bool touchstart_expected_soon; 396 bool touchstart_expected_soon;
408 bool have_seen_a_begin_main_frame; 397 bool have_seen_a_begin_main_frame;
409 bool have_reported_blocking_intervention_in_current_policy; 398 bool have_reported_blocking_intervention_in_current_policy;
410 bool have_reported_blocking_intervention_since_navigation; 399 bool have_reported_blocking_intervention_since_navigation;
411 bool has_visible_render_widget_with_touch_handler; 400 bool has_visible_render_widget_with_touch_handler;
412 bool begin_frame_not_expected_soon; 401 bool begin_frame_not_expected_soon;
413 bool expensive_task_blocking_allowed; 402 bool expensive_task_blocking_allowed;
414 bool in_idle_period_for_testing; 403 bool in_idle_period_for_testing;
415 bool use_virtual_time;
416 std::set<WebViewSchedulerImpl*> web_view_schedulers; // Not owned. 404 std::set<WebViewSchedulerImpl*> web_view_schedulers; // Not owned.
417 RAILModeObserver* rail_mode_observer; // Not owned. 405 RAILModeObserver* rail_mode_observer; // Not owned.
418 }; 406 };
419 407
420 struct AnyThread { 408 struct AnyThread {
421 AnyThread(); 409 AnyThread();
422 ~AnyThread(); 410 ~AnyThread();
423 411
424 base::TimeTicks last_idle_period_end_time; 412 base::TimeTicks last_idle_period_end_time;
425 base::TimeTicks rails_loading_priority_deadline; 413 base::TimeTicks rails_loading_priority_deadline;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 471
484 PollableThreadSafeFlag policy_may_need_update_; 472 PollableThreadSafeFlag policy_may_need_update_;
485 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; 473 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_;
486 474
487 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); 475 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl);
488 }; 476 };
489 477
490 } // namespace scheduler 478 } // namespace scheduler
491 479
492 #endif // COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_IMPL_H_ 480 #endif // COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | components/scheduler/renderer/renderer_scheduler_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698