OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #ifndef CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_ | |
6 #define CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_ | |
7 | |
8 #include "base/atomicops.h" | |
9 #include "base/task/task_queue_manager.h" | |
10 #include "base/threading/thread_checker.h" | |
11 | |
12 namespace cc { | |
13 struct BeginFrameArgs; | |
14 } | |
15 | |
16 namespace content { | |
17 | |
18 class RendererSchedulerSelector; | |
19 | |
20 class RendererScheduler { | |
21 public: | |
22 enum QueueId { | |
23 kDefaultTaskQueue, | |
24 kCompositorTaskQueue, | |
25 kIdleTaskQueue, | |
26 // Must be the last entry. | |
27 kTaskQueueCount, | |
28 }; | |
29 | |
30 RendererScheduler(); | |
31 ~RendererScheduler(); | |
32 | |
33 // Returns the task runner which targets the queue selected by |queue_index|. | |
34 scoped_refptr<base::SingleThreadTaskRunner> TaskRunnerForQueue(QueueId queue); | |
35 | |
36 // Called to notify about the start of a new frame. Must be called from the | |
37 // main thread. | |
38 void WillBeginFrame(const cc::BeginFrameArgs& args); | |
39 | |
40 // Called to notify that a previously begun frame was committed. Must be | |
41 // called from the main thread. | |
42 void DidCommitFrameToCompositor(); | |
43 | |
44 // Tells the scheduler that the system received an input event. Can be called | |
45 // on any thread. | |
46 void DidReceiveInputEvent(); | |
47 | |
48 // Returns true if there is high priority work pending on the main thread | |
49 // and the caller should yield to let the scheduler service that work. | |
50 // Can be called on any thread. | |
51 bool ShouldYieldForHighPriorityWork(); | |
52 | |
53 // Returns the deadline by which an idle task should finish by for the | |
54 // current frame. Must be called from the main thread. | |
55 base::TimeTicks CurrentFrameDeadlineForIdleTasks() const; | |
56 | |
57 private: | |
58 enum Policy { | |
59 kNormalPriorityPolicy, | |
60 kCompositorPriorityPolicy, | |
61 }; | |
62 | |
63 size_t kControlQueue = kTaskQueueCount; | |
64 size_t kTaskAndControlQueueCount = kControlQueue + 1; | |
65 | |
picksi1
2014/10/20 11:42:04
Why are these not part of the enum?
rmcilroy
2014/10/21 17:21:27
Because they are not public (I don't want someone
| |
66 // The time we should stay in CompositorPriority mode for after a touch event. | |
67 base::TimeDelta kCompositoryPriorityAfterTouchTime = | |
68 base::TimeDelta::FromMilliseconds(100); | |
69 | |
70 // Returns the current scheduler policy. Can be called on any thread. | |
71 Policy SchedulerPolicy() const; | |
72 | |
73 // Enters the scheduler policy. Must be called from the main thread. | |
74 void EnterSchedulerPolicy(Policy policy); | |
75 | |
76 // Start and end an idle period. | |
77 void StartIdlePeriod(); | |
78 void EndIdlePeriod(); | |
79 | |
80 base::ThreadChecker main_thread_checker_; | |
81 scoped_ptr<RendererSchedulerSelector> renderer_scheduler_selector_; | |
82 base::TaskQueueManager task_queue_manager_; | |
83 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner_; | |
84 | |
85 // Don't access scheduler_policy_ directly, use EnterSchedulerPolicy | |
86 // and SchedulerPolicy instead. | |
87 base::subtle::AtomicWord current_policy_; | |
88 | |
89 base::TimeTicks estimated_next_frame_begin_; | |
90 }; | |
91 | |
92 } // namespace content | |
93 | |
94 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_ | |
OLD | NEW |