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 "content/renderer/scheduler/single_thread_idle_task_runner.h"
9 #include "content/renderer/scheduler/task_queue_manager.h"
10 #include "third_party/WebKit/public/web/WebInputEvent.h"
13 struct BeginFrameArgs
;
18 class CONTENT_EXPORT RendererScheduler
{
20 virtual ~RendererScheduler();
21 static scoped_ptr
<RendererScheduler
> Create();
23 // Returns the default task runner.
24 virtual scoped_refptr
<base::SingleThreadTaskRunner
> DefaultTaskRunner() = 0;
26 // Returns the compositor task runner.
27 virtual scoped_refptr
<base::SingleThreadTaskRunner
>
28 CompositorTaskRunner() = 0;
30 // Returns the idle task runner. Tasks posted to this runner may be reordered
31 // relative to other task types and may be starved for an arbitrarily long
32 // time if no idle time is available.
33 virtual scoped_refptr
<SingleThreadIdleTaskRunner
> IdleTaskRunner() = 0;
35 // Returns the loading task runner. This queue is intended for tasks related
36 // to resource dispatch, foreground HTML parsing, etc...
37 virtual scoped_refptr
<base::SingleThreadTaskRunner
> LoadingTaskRunner() = 0;
39 // Called to notify about the start of a new frame. Must be called from the
41 virtual void WillBeginFrame(const cc::BeginFrameArgs
& args
) = 0;
43 // Called to notify that a previously begun frame was committed. Must be
44 // called from the main thread.
45 virtual void DidCommitFrameToCompositor() = 0;
47 // Tells the scheduler that the system received an input event. Called by the
48 // compositor (impl) thread.
49 virtual void DidReceiveInputEventOnCompositorThread(
50 blink::WebInputEvent::Type type
) = 0;
52 // Tells the scheduler that the system is displaying an input animation (e.g.
53 // a fling). Called by the compositor (impl) thread.
54 virtual void DidAnimateForInputOnCompositorThread() = 0;
56 // Returns true if there is high priority work pending on the main thread
57 // and the caller should yield to let the scheduler service that work.
58 // Must be called from the main thread.
59 virtual bool ShouldYieldForHighPriorityWork() = 0;
61 // Shuts down the scheduler by dropping any remaining pending work in the work
62 // queues. After this call any work posted to the task runners will be
64 virtual void Shutdown() = 0;
68 DISALLOW_COPY_AND_ASSIGN(RendererScheduler
);
71 } // namespace content
73 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_