OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_ | 5 #ifndef CONTENT_CHILD_SCHEDULER_WORKER_SCHEDULER_H_ |
6 #define CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_ | 6 #define CONTENT_CHILD_SCHEDULER_WORKER_SCHEDULER_H_ |
7 | 7 |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "content/child/scheduler/single_thread_idle_task_runner.h" | 9 #include "content/child/scheduler/single_thread_idle_task_runner.h" |
10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
11 #include "third_party/WebKit/public/web/WebInputEvent.h" | |
12 | 11 |
13 namespace cc { | 12 namespace base { |
14 struct BeginFrameArgs; | 13 class MessageLoop; |
15 } | 14 } |
16 | 15 |
17 namespace content { | 16 namespace content { |
18 | 17 |
19 class CONTENT_EXPORT RendererScheduler { | 18 class CONTENT_EXPORT WorkerScheduler { |
20 public: | 19 public: |
21 virtual ~RendererScheduler(); | 20 virtual ~WorkerScheduler(); |
22 static scoped_ptr<RendererScheduler> Create(); | 21 static scoped_ptr<WorkerScheduler> Create(base::MessageLoop* message_loop); |
22 | |
23 // Must be called before the scheduler can be used. Does any post construction | |
24 // initialization needed such as initiating long idle periods. | |
rmcilroy
2015/04/08 18:34:24
nit - /s/initiating long idle periods/initializing
alex clarke (OOO till 29th)
2015/04/09 10:02:37
Done.
| |
25 virtual void Init() = 0; | |
23 | 26 |
24 // Returns the default task runner. | 27 // Returns the default task runner. |
25 virtual scoped_refptr<base::SingleThreadTaskRunner> DefaultTaskRunner() = 0; | 28 virtual scoped_refptr<base::SingleThreadTaskRunner> DefaultTaskRunner() = 0; |
26 | 29 |
27 // Returns the compositor task runner. | |
28 virtual scoped_refptr<base::SingleThreadTaskRunner> | |
29 CompositorTaskRunner() = 0; | |
30 | |
31 // Returns the idle task runner. Tasks posted to this runner may be reordered | 30 // Returns the idle task runner. Tasks posted to this runner may be reordered |
32 // relative to other task types and may be starved for an arbitrarily long | 31 // relative to other task types and may be starved for an arbitrarily long |
33 // time if no idle time is available. | 32 // time if no idle time is available. |
34 virtual scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner() = 0; | 33 virtual scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner() = 0; |
35 | 34 |
36 // Returns the loading task runner. This queue is intended for tasks related | |
37 // to resource dispatch, foreground HTML parsing, etc... | |
38 virtual scoped_refptr<base::SingleThreadTaskRunner> LoadingTaskRunner() = 0; | |
39 | |
40 // Called to notify about the start of an extended period where no frames | |
41 // need to be drawn. Must be called from the main thread. | |
42 virtual void BeginFrameNotExpectedSoon() = 0; | |
43 | |
44 // Called to notify about the start of a new frame. Must be called from the | |
45 // main thread. | |
46 virtual void WillBeginFrame(const cc::BeginFrameArgs& args) = 0; | |
47 | |
48 // Called to notify that a previously begun frame was committed. Must be | |
49 // called from the main thread. | |
50 virtual void DidCommitFrameToCompositor() = 0; | |
51 | |
52 // Tells the scheduler that the system received an input event. Called by the | |
53 // compositor (impl) thread. | |
54 virtual void DidReceiveInputEventOnCompositorThread( | |
55 const blink::WebInputEvent& web_input_event) = 0; | |
56 | |
57 // Tells the scheduler that the system is displaying an input animation (e.g. | |
58 // a fling). Called by the compositor (impl) thread. | |
59 virtual void DidAnimateForInputOnCompositorThread() = 0; | |
60 | |
61 // Returns true if the scheduler has reason to believe that high priority work | |
62 // may soon arrive on the main thread, e.g., if gesture events were observed | |
63 // recently. | |
64 // Must be called from the main thread. | |
65 virtual bool IsHighPriorityWorkAnticipated() = 0; | |
66 | |
67 // Returns true if there is high priority work pending on the main thread | |
68 // and the caller should yield to let the scheduler service that work. Note | |
69 // that this is a stricter condition than |IsHighPriorityWorkAnticipated|, | |
70 // restricted to the case where real work is pending. | |
71 // Must be called from the main thread. | |
72 virtual bool ShouldYieldForHighPriorityWork() = 0; | |
73 | |
74 // Returns true if a currently running idle task could exceed its deadline | 35 // Returns true if a currently running idle task could exceed its deadline |
75 // without impacting user experience too much. This should only be used if | 36 // without impacting user experience too much. This should only be used if |
76 // there is a task which cannot be pre-empted and is likely to take longer | 37 // there is a task which cannot be pre-empted and is likely to take longer |
77 // than the largest expected idle task deadline. It should NOT be polled to | 38 // than the largest expected idle task deadline. It should NOT be polled to |
78 // check whether more work can be performed on the current idle task after | 39 // check whether more work can be performed on the current idle task after |
79 // its deadline has expired - post a new idle task for the continuation of the | 40 // its deadline has expired - post a new idle task for the continuation of the |
80 // work in this case. | 41 // work in this case. |
81 // Must be called from the main thread. | 42 // Must be called from the main thread. |
rmcilroy
2015/04/08 18:34:24
'main thread' should be 'the worker's thread' righ
alex clarke (OOO till 29th)
2015/04/09 10:02:37
Done.
| |
82 virtual bool CanExceedIdleDeadlineIfRequired() const = 0; | 43 virtual bool CanExceedIdleDeadlineIfRequired() const = 0; |
83 | 44 |
84 // Adds or removes a task observer from the scheduler. The observer will be | 45 // Adds or removes a task observer from the scheduler. The observer will be |
85 // notified before and after every executed task. These functions can only be | 46 // notified before and after every executed task. These functions can only be |
86 // called on the main thread. | 47 // called on the main thread. |
87 virtual void AddTaskObserver( | 48 virtual void AddTaskObserver( |
88 base::MessageLoop::TaskObserver* task_observer) = 0; | 49 base::MessageLoop::TaskObserver* task_observer) = 0; |
89 virtual void RemoveTaskObserver( | 50 virtual void RemoveTaskObserver( |
90 base::MessageLoop::TaskObserver* task_observer) = 0; | 51 base::MessageLoop::TaskObserver* task_observer) = 0; |
91 | 52 |
92 // Shuts down the scheduler by dropping any remaining pending work in the work | 53 // Shuts down the scheduler by dropping any remaining pending work in the work |
93 // queues. After this call any work posted to the task runners will be | 54 // queues. After this call any work posted to the task runners will be |
94 // silently dropped. | 55 // silently dropped. |
95 virtual void Shutdown() = 0; | 56 virtual void Shutdown() = 0; |
96 | 57 |
97 protected: | 58 protected: |
98 RendererScheduler(); | 59 WorkerScheduler(); |
99 DISALLOW_COPY_AND_ASSIGN(RendererScheduler); | 60 DISALLOW_COPY_AND_ASSIGN(WorkerScheduler); |
100 }; | 61 }; |
101 | 62 |
102 } // namespace content | 63 } // namespace content |
103 | 64 |
104 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_ | 65 #endif // CONTENT_CHILD_SCHEDULER_WORKER_SCHEDULER_H_ |
OLD | NEW |