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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_H_
6 #define COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_H_
8 #include "base/message_loop/message_loop.h"
9 #include "components/scheduler/child/child_scheduler.h"
10 #include "components/scheduler/child/single_thread_idle_task_runner.h"
11 #include "components/scheduler/scheduler_export.h"
12 #include "third_party/WebKit/public/web/WebInputEvent.h"
15 struct BeginFrameArgs
;
20 class SCHEDULER_EXPORT RendererScheduler
: public ChildScheduler
{
22 ~RendererScheduler() override
;
23 static scoped_ptr
<RendererScheduler
> Create();
25 // Returns the compositor task runner.
26 virtual scoped_refptr
<base::SingleThreadTaskRunner
>
27 CompositorTaskRunner() = 0;
29 // Returns the loading task runner. This queue is intended for tasks related
30 // to resource dispatch, foreground HTML parsing, etc...
31 virtual scoped_refptr
<base::SingleThreadTaskRunner
> LoadingTaskRunner() = 0;
33 // Returns the timer task runner. This queue is intended for DOM Timers.
34 virtual scoped_refptr
<TaskQueue
> TimerTaskRunner() = 0;
36 // Called to notify about the start of an extended period where no frames
37 // need to be drawn. Must be called from the main thread.
38 virtual void BeginFrameNotExpectedSoon() = 0;
40 // Called to notify about the start of a new frame. Must be called from the
42 virtual void WillBeginFrame(const cc::BeginFrameArgs
& args
) = 0;
44 // Called to notify that a previously begun frame was committed. Must be
45 // called from the main thread.
46 virtual void DidCommitFrameToCompositor() = 0;
48 enum class InputEventState
{
49 EVENT_CONSUMED_BY_COMPOSITOR
,
50 EVENT_FORWARDED_TO_MAIN_THREAD
,
53 // Tells the scheduler that the system processed an input event. Called by the
54 // compositor (impl) thread. Note it's expected that every call to
55 // DidHandleInputEventOnCompositorThread where |event_state| is
56 // EVENT_FORWARDED_TO_MAIN_THREAD will be followed by a corresponding call
57 // to DidHandleInputEventOnMainThread.
58 virtual void DidHandleInputEventOnCompositorThread(
59 const blink::WebInputEvent
& web_input_event
,
60 InputEventState event_state
) = 0;
62 // Tells the scheduler that the system processed an input event. Must be
63 // called from the main thread.
64 virtual void DidHandleInputEventOnMainThread(
65 const blink::WebInputEvent
& web_input_event
) = 0;
67 // Tells the scheduler that the system is displaying an input animation (e.g.
68 // a fling). Called by the compositor (impl) thread.
69 virtual void DidAnimateForInputOnCompositorThread() = 0;
71 // Tells the scheduler that all render widgets managed by this renderer
72 // process have been hidden. The renderer is assumed to be visible when the
73 // scheduler is constructed. Must be called on the main thread.
74 virtual void OnRendererHidden() = 0;
76 // Tells the scheduler that at least one render widget managed by this
77 // renderer process has become visible and the renderer is no longer hidden.
78 // The renderer is assumed to be visible when the scheduler is constructed.
79 // Must be called on the main thread.
80 virtual void OnRendererVisible() = 0;
82 // Tells the scheduler that a page load has started. The scheduler will
83 // prioritize loading tasks for a short duration afterwards.
84 // Must be called from the main thread.
85 virtual void OnPageLoadStarted() = 0;
87 // Returns true if the scheduler has reason to believe that high priority work
88 // may soon arrive on the main thread, e.g., if gesture events were observed
90 // Must be called from the main thread.
91 virtual bool IsHighPriorityWorkAnticipated() = 0;
93 // Suspends the timer queue and increments the timer queue suspension count.
94 // May only be called from the main thread.
95 virtual void SuspendTimerQueue() = 0;
97 // Decrements the timer queue suspension count and re-enables the timer queue
98 // if the suspension count is zero and the current schduler policy allows it.
99 virtual void ResumeTimerQueue() = 0;
103 DISALLOW_COPY_AND_ASSIGN(RendererScheduler
);
106 } // namespace scheduler
108 #endif // COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_H_