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

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

Issue 2860263002: NOT FOR COMMIT: Move background pausing to the WebView level
Patch Set: Created 3 years, 7 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 THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDULER _IMPL_H_ 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDULER _IMPL_H_
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDULER _IMPL_H_ 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDULER _IMPL_H_
7 7
8 #include "base/atomicops.h" 8 #include "base/atomicops.h"
9 #include "base/gtest_prod_util.h" 9 #include "base/gtest_prod_util.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 void BeginFrameNotExpectedSoon() override; 92 void BeginFrameNotExpectedSoon() override;
93 void DidCommitFrameToCompositor() override; 93 void DidCommitFrameToCompositor() override;
94 void DidHandleInputEventOnCompositorThread( 94 void DidHandleInputEventOnCompositorThread(
95 const WebInputEvent& web_input_event, 95 const WebInputEvent& web_input_event,
96 InputEventState event_state) override; 96 InputEventState event_state) override;
97 void DidHandleInputEventOnMainThread(const WebInputEvent& web_input_event, 97 void DidHandleInputEventOnMainThread(const WebInputEvent& web_input_event,
98 WebInputEventResult result) override; 98 WebInputEventResult result) override;
99 void DidAnimateForInputOnCompositorThread() override; 99 void DidAnimateForInputOnCompositorThread() override;
100 void OnRendererBackgrounded() override; 100 void OnRendererBackgrounded() override;
101 void OnRendererForegrounded() override; 101 void OnRendererForegrounded() override;
102 void SuspendRenderer() override;
103 void ResumeRenderer() override;
104 void AddPendingNavigation(NavigatingFrameType type) override; 102 void AddPendingNavigation(NavigatingFrameType type) override;
105 void RemovePendingNavigation(NavigatingFrameType type) override; 103 void RemovePendingNavigation(NavigatingFrameType type) override;
106 void OnNavigationStarted() override; 104 void OnNavigationStarted() override;
107 bool IsHighPriorityWorkAnticipated() override; 105 bool IsHighPriorityWorkAnticipated() override;
108 bool ShouldYieldForHighPriorityWork() override; 106 bool ShouldYieldForHighPriorityWork() override;
109 bool CanExceedIdleDeadlineIfRequired() const override; 107 bool CanExceedIdleDeadlineIfRequired() const override;
110 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override; 108 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override;
111 void RemoveTaskObserver( 109 void RemoveTaskObserver(
112 base::MessageLoop::TaskObserver* task_observer) override; 110 base::MessageLoop::TaskObserver* task_observer) override;
113 void Shutdown() override; 111 void Shutdown() override;
114 void SuspendTimerQueue() override; 112 void SuspendTimerQueue() override;
115 void ResumeTimerQueue() override; 113 void ResumeTimerQueue() override;
116 void SetTimerQueueSuspensionWhenBackgroundedEnabled(bool enabled) override;
117 void SetTopLevelBlameContext( 114 void SetTopLevelBlameContext(
118 base::trace_event::BlameContext* blame_context) override; 115 base::trace_event::BlameContext* blame_context) override;
119 void SetRAILModeObserver(RAILModeObserver* observer) override; 116 void SetRAILModeObserver(RAILModeObserver* observer) override;
120 bool MainThreadSeemsUnresponsive( 117 bool MainThreadSeemsUnresponsive(
121 base::TimeDelta main_thread_responsiveness_threshold) override; 118 base::TimeDelta main_thread_responsiveness_threshold) override;
122 119
123 // RenderWidgetSignals::Observer implementation: 120 // RenderWidgetSignals::Observer implementation:
124 void SetAllRenderWidgetsHidden(bool hidden) override; 121 void SetAllRenderWidgetsHidden(bool hidden) override;
125 void SetHasVisibleRenderWidgetWithTouchHandler( 122 void SetHasVisibleRenderWidgetWithTouchHandler(
126 bool has_visible_render_widget_with_touch_handler) override; 123 bool has_visible_render_widget_with_touch_handler) override;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 static bool ShouldPrioritizeInputEvent(const WebInputEvent& web_input_event); 313 static bool ShouldPrioritizeInputEvent(const WebInputEvent& web_input_event);
317 314
318 // The amount of time which idle periods can continue being scheduled when the 315 // The amount of time which idle periods can continue being scheduled when the
319 // renderer has been hidden, before going to sleep for good. 316 // renderer has been hidden, before going to sleep for good.
320 static const int kEndIdleWhenHiddenDelayMillis = 10000; 317 static const int kEndIdleWhenHiddenDelayMillis = 10000;
321 318
322 // The amount of time in milliseconds we have to respond to user input as 319 // The amount of time in milliseconds we have to respond to user input as
323 // defined by RAILS. 320 // defined by RAILS.
324 static const int kRailsResponseTimeMillis = 50; 321 static const int kRailsResponseTimeMillis = 50;
325 322
326 // The amount of time to wait before suspending shared timers after the
327 // renderer has been backgrounded. This is used only if background suspension
328 // of shared timers is enabled.
329 static const int kSuspendTimersWhenBackgroundedDelayMillis = 5 * 60 * 1000;
330
331 // The time we should stay in a priority-escalated mode after a call to 323 // The time we should stay in a priority-escalated mode after a call to
332 // DidAnimateForInputOnCompositorThread(). 324 // DidAnimateForInputOnCompositorThread().
333 static const int kFlingEscalationLimitMillis = 100; 325 static const int kFlingEscalationLimitMillis = 100;
334 326
335 // Schedules an immediate PolicyUpdate, if there isn't one already pending and 327 // Schedules an immediate PolicyUpdate, if there isn't one already pending and
336 // sets |policy_may_need_update_|. Note |any_thread_lock_| must be 328 // sets |policy_may_need_update_|. Note |any_thread_lock_| must be
337 // locked. 329 // locked.
338 void EnsureUrgentPolicyUpdatePostedOnMainThread( 330 void EnsureUrgentPolicyUpdatePostedOnMainThread(
339 const tracked_objects::Location& from_here); 331 const tracked_objects::Location& from_here);
340 332
(...skipping 23 matching lines...) Expand all
364 // scheduled. Must be called with |any_thread_lock_| held. Can be called from 356 // scheduled. Must be called with |any_thread_lock_| held. Can be called from
365 // any thread. 357 // any thread.
366 UseCase ComputeCurrentUseCase( 358 UseCase ComputeCurrentUseCase(
367 base::TimeTicks now, 359 base::TimeTicks now,
368 base::TimeDelta* expected_use_case_duration) const; 360 base::TimeDelta* expected_use_case_duration) const;
369 361
370 // An input event of some sort happened, the policy may need updating. 362 // An input event of some sort happened, the policy may need updating.
371 void UpdateForInputEventOnCompositorThread(WebInputEvent::Type type, 363 void UpdateForInputEventOnCompositorThread(WebInputEvent::Type type,
372 InputEventState input_event_state); 364 InputEventState input_event_state);
373 365
374 // Helpers for safely suspending/resuming the timer queue after a
375 // background/foreground signal.
376 void SuspendTimerQueueWhenBackgrounded();
377 void ResumeTimerQueueWhenForegroundedOrResumed();
378
379 // The task cost estimators and the UserModel need to be reset upon page 366 // The task cost estimators and the UserModel need to be reset upon page
380 // nagigation. This function does that. Must be called from the main thread. 367 // nagigation. This function does that. Must be called from the main thread.
381 void ResetForNavigationLocked(); 368 void ResetForNavigationLocked();
382 369
383 // Estimates the maximum task length that won't cause a jank based on the 370 // Estimates the maximum task length that won't cause a jank based on the
384 // current system state. Must be called from the main thread. 371 // current system state. Must be called from the main thread.
385 base::TimeDelta EstimateLongestJankFreeTaskDuration() const; 372 base::TimeDelta EstimateLongestJankFreeTaskDuration() const;
386 373
387 // Report an intervention to all WebViews in this process. 374 // Report an intervention to all WebViews in this process.
388 void BroadcastIntervention(const std::string& message); 375 void BroadcastIntervention(const std::string& message);
(...skipping 30 matching lines...) Expand all
419 std::set<scoped_refptr<TaskQueue>> unthrottled_task_runners_; 406 std::set<scoped_refptr<TaskQueue>> unthrottled_task_runners_;
420 scoped_refptr<TaskQueue> default_loading_task_queue_; 407 scoped_refptr<TaskQueue> default_loading_task_queue_;
421 scoped_refptr<TaskQueue> default_timer_task_queue_; 408 scoped_refptr<TaskQueue> default_timer_task_queue_;
422 409
423 // Note |virtual_time_domain_| is lazily created. 410 // Note |virtual_time_domain_| is lazily created.
424 std::unique_ptr<AutoAdvancingVirtualTimeDomain> virtual_time_domain_; 411 std::unique_ptr<AutoAdvancingVirtualTimeDomain> virtual_time_domain_;
425 412
426 base::Closure update_policy_closure_; 413 base::Closure update_policy_closure_;
427 DeadlineTaskRunner delayed_update_policy_runner_; 414 DeadlineTaskRunner delayed_update_policy_runner_;
428 CancelableClosureHolder end_renderer_hidden_idle_period_closure_; 415 CancelableClosureHolder end_renderer_hidden_idle_period_closure_;
429 CancelableClosureHolder suspend_timers_when_backgrounded_closure_;
430 416
431 using SeqLockQueueingTimeEstimator = 417 using SeqLockQueueingTimeEstimator =
432 device::SharedMemorySeqLockBuffer<QueueingTimeEstimator>; 418 device::SharedMemorySeqLockBuffer<QueueingTimeEstimator>;
433 419
434 SeqLockQueueingTimeEstimator seqlock_queueing_time_estimator_; 420 SeqLockQueueingTimeEstimator seqlock_queueing_time_estimator_;
435 421
436 // We have decided to improve thread safety at the cost of some boilerplate 422 // We have decided to improve thread safety at the cost of some boilerplate
437 // (the accessors) for the following data members. 423 // (the accessors) for the following data members.
438 424
439 struct MainThreadOnly { 425 struct MainThreadOnly {
(...skipping 14 matching lines...) Expand all
454 base::TimeTicks estimated_next_frame_begin; 440 base::TimeTicks estimated_next_frame_begin;
455 base::TimeTicks current_task_start_time; 441 base::TimeTicks current_task_start_time;
456 base::TimeDelta compositor_frame_interval; 442 base::TimeDelta compositor_frame_interval;
457 base::TimeDelta longest_jank_free_task_duration; 443 base::TimeDelta longest_jank_free_task_duration;
458 base::Optional<base::TimeTicks> last_audio_state_change; 444 base::Optional<base::TimeTicks> last_audio_state_change;
459 int timer_queue_suspend_count; // TIMER_TASK_QUEUE suspended if non-zero. 445 int timer_queue_suspend_count; // TIMER_TASK_QUEUE suspended if non-zero.
460 int navigation_task_expected_count; 446 int navigation_task_expected_count;
461 ExpensiveTaskPolicy expensive_task_policy; 447 ExpensiveTaskPolicy expensive_task_policy;
462 bool renderer_hidden; 448 bool renderer_hidden;
463 bool renderer_backgrounded; 449 bool renderer_backgrounded;
464 bool renderer_suspended;
465 bool timer_queue_suspension_when_backgrounded_enabled;
466 bool timer_queue_suspended_when_backgrounded;
467 bool was_shutdown; 450 bool was_shutdown;
468 bool loading_tasks_seem_expensive; 451 bool loading_tasks_seem_expensive;
469 bool timer_tasks_seem_expensive; 452 bool timer_tasks_seem_expensive;
470 bool touchstart_expected_soon; 453 bool touchstart_expected_soon;
471 bool have_seen_a_begin_main_frame; 454 bool have_seen_a_begin_main_frame;
472 bool have_reported_blocking_intervention_in_current_policy; 455 bool have_reported_blocking_intervention_in_current_policy;
473 bool have_reported_blocking_intervention_since_navigation; 456 bool have_reported_blocking_intervention_since_navigation;
474 bool has_visible_render_widget_with_touch_handler; 457 bool has_visible_render_widget_with_touch_handler;
475 bool begin_frame_not_expected_soon; 458 bool begin_frame_not_expected_soon;
476 bool in_idle_period_for_testing; 459 bool in_idle_period_for_testing;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 533
551 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; 534 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_;
552 535
553 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); 536 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl);
554 }; 537 };
555 538
556 } // namespace scheduler 539 } // namespace scheduler
557 } // namespace blink 540 } // namespace blink
558 541
559 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDU LER_IMPL_H_ 542 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDU LER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698