Chromium Code Reviews| Index: components/scheduler/renderer/idle_time_estimator.h |
| diff --git a/components/scheduler/renderer/idle_time_estimator.h b/components/scheduler/renderer/idle_time_estimator.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b93b4ac017bea6172de04f67557c8ae9c66dd877 |
| --- /dev/null |
| +++ b/components/scheduler/renderer/idle_time_estimator.h |
| @@ -0,0 +1,55 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_SCHEDULER_RENDERER_IDLE_TIME_ESTIMATOR_H_ |
| +#define COMPONENTS_SCHEDULER_RENDERER_IDLE_TIME_ESTIMATOR_H_ |
| + |
| +#include "base/message_loop/message_loop.h" |
| +#include "base/time/tick_clock.h" |
| +#include "cc/base/rolling_time_delta_history.h" |
| +#include "components/scheduler/scheduler_export.h" |
| + |
| +namespace scheduler { |
| + |
| +// Estimates how much idle time there is avaliable. |
|
Sami
2015/10/09 02:32:18
typo: available
alex clarke (OOO till 29th)
2015/10/15 13:24:01
Done.
|
| +class SCHEDULER_EXPORT IdleTimeEstimator |
| + : public base::MessageLoop::TaskObserver { |
| + public: |
| + IdleTimeEstimator(int sample_count, double estimation_percentile); |
|
Sami
2015/10/09 02:32:18
I think it would be slightly less error prone to p
alex clarke (OOO till 29th)
2015/10/15 13:24:01
Done.
|
| + |
| + ~IdleTimeEstimator() override; |
| + |
| + // Expected Idle time is defined as: expected frame duration minus |
| + // expected compositor task duration, where the frame duration is clamped to a |
| + // meximum of |max_frame_length|. |
|
Sami
2015/10/09 02:32:18
typo: maximum
alex clarke (OOO till 29th)
2015/10/15 13:24:01
Done.
|
| + base::TimeDelta GetExpectedIdleDuration( |
| + base::TimeDelta max_frame_length) const; |
| + |
| + void DidCommitFrameToCompositor(); |
| + |
| + void Clear(); |
| + |
| + // TaskObserver implementation: |
| + void WillProcessTask(const base::PendingTask& pending_task) override; |
| + void DidProcessTask(const base::PendingTask& pending_task) override; |
| + |
| + void SetTimeSourceForTesting(scoped_ptr<base::TickClock> time_source); |
| + |
| + private: |
| + cc::RollingTimeDeltaHistory frame_length_; |
| + cc::RollingTimeDeltaHistory per_frame_compositor_task_runtime_; |
| + scoped_ptr<base::TickClock> time_source_; |
| + double estimation_percentile_; |
| + |
| + base::TimeTicks task_start_time_; |
| + base::TimeTicks prev_commit_time_; |
| + base::TimeDelta cumulative_compositor_runtime_; |
| + bool did_commit_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(IdleTimeEstimator); |
| +}; |
| + |
| +} // namespace scheduler |
| + |
| +#endif // COMPONENTS_SCHEDULER_RENDERER_IDLE_TIME_ESTIMATOR_H_ |