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 CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_
6 #define CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_
8 #include "base/message_loop/message_loop.h"
9 #include "content/child/scheduler/child_scheduler.h"
10 #include "content/child/scheduler/single_thread_idle_task_runner.h"
11 #include "content/common/content_export.h"
12 #include "third_party/WebKit/public/web/WebInputEvent.h"
15 struct BeginFrameArgs
;
20 class CONTENT_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
<base::SingleThreadTaskRunner
> 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 // Tells the scheduler that the system received an input event. Called by the
49 // compositor (impl) thread.
50 virtual void DidReceiveInputEventOnCompositorThread(
51 const blink::WebInputEvent
& web_input_event
) = 0;
53 // Tells the scheduler that the system is displaying an input animation (e.g.
54 // a fling). Called by the compositor (impl) thread.
55 virtual void DidAnimateForInputOnCompositorThread() = 0;
57 // Tells the scheduler that all render widgets managed by this renderer
58 // process have been hidden. The renderer is assumed to be visible when the
59 // scheduler is constructed. Must be called on the main thread.
60 virtual void OnRendererHidden() = 0;
62 // Tells the scheduler that at least one render widget managed by this
63 // renderer process has become visible and the renderer is no longer hidden.
64 // The renderer is assumed to be visible when the scheduler is constructed.
65 // Must be called on the main thread.
66 virtual void OnRendererVisible() = 0;
68 // Returns true if the scheduler has reason to believe that high priority work
69 // may soon arrive on the main thread, e.g., if gesture events were observed
71 // Must be called from the main thread.
72 virtual bool IsHighPriorityWorkAnticipated() = 0;
74 // Suspends the timer queue and increments the timer queue suspension count.
75 // May only be called from the main thread.
76 virtual void SuspendTimerQueue() = 0;
78 // Decrements the timer queue suspension count and re-enables the timer queue
79 // if the suspension count is zero and the current schduler policy allows it.
80 virtual void ResumeTimerQueue() = 0;
84 DISALLOW_COPY_AND_ASSIGN(RendererScheduler
);
87 } // namespace content
89 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_