OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_SCHEDULER_RENDERER_IDLE_TIME_ESTIMATOR_H_ | |
6 #define COMPONENTS_SCHEDULER_RENDERER_IDLE_TIME_ESTIMATOR_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/message_loop/message_loop.h" | |
10 #include "base/time/tick_clock.h" | |
11 #include "cc/base/rolling_time_delta_history.h" | |
12 #include "components/scheduler/base/task_queue.h" | |
13 #include "components/scheduler/scheduler_export.h" | |
14 | |
15 namespace scheduler { | |
16 | |
17 // Estimates how much idle time there is available. Ignores nested tasks. | |
18 class SCHEDULER_EXPORT IdleTimeEstimator | |
19 : public base::MessageLoop::TaskObserver { | |
20 public: | |
21 IdleTimeEstimator(const scoped_refptr<TaskQueue>& compositor_task_runner, | |
22 base::TickClock* time_source, | |
23 int sample_count, | |
24 double estimation_percentile); | |
25 | |
26 ~IdleTimeEstimator() override; | |
27 | |
28 // Expected Idle time is defined as: |compositor_frame_interval| minus | |
29 // expected compositor task duration. | |
30 base::TimeDelta GetExpectedIdleDuration( | |
31 base::TimeDelta compositor_frame_interval) const; | |
32 | |
33 void DidCommitFrameToCompositor(); | |
34 | |
35 void Clear(); | |
36 | |
37 // TaskObserver implementation: | |
38 void WillProcessTask(const base::PendingTask& pending_task) override; | |
39 void DidProcessTask(const base::PendingTask& pending_task) override; | |
40 | |
41 private: | |
42 scoped_refptr<TaskQueue> compositor_task_runner_; | |
43 cc::RollingTimeDeltaHistory per_frame_compositor_task_runtime_; | |
44 base::TickClock* time_source_; // NOT OWNED | |
45 double estimation_percentile_; | |
46 | |
47 base::TimeTicks task_start_time_; | |
48 base::TimeTicks prev_commit_time_; | |
49 base::TimeDelta cumulative_compositor_runtime_; | |
50 int nesting_level_; | |
51 bool did_commit_; | |
52 | |
53 DISALLOW_COPY_AND_ASSIGN(IdleTimeEstimator); | |
54 }; | |
55 | |
56 } // namespace scheduler | |
57 | |
58 #endif // COMPONENTS_SCHEDULER_RENDERER_IDLE_TIME_ESTIMATOR_H_ | |
OLD | NEW |