OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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_QUEUEING_TIME_ESTIMATOR_H_ |
| 6 #define COMPONENTS_SCHEDULER_RENDERER_QUEUEING_TIME_ESTIMATOR_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/time/time.h" |
| 11 #include "cc/base/rolling_time_delta_history.h" |
| 12 #include "components/scheduler/scheduler_export.h" |
| 13 |
| 14 namespace scheduler { |
| 15 |
| 16 class CoarseDurationTimer; |
| 17 |
| 18 // Records the expected queueing time for a high priority task occurring |
| 19 // randomly during each interval of length |window_duration|. |
| 20 class SCHEDULER_EXPORT QueueingTimeEstimator |
| 21 : public base::MessageLoop::TaskObserver { |
| 22 public: |
| 23 class Client { |
| 24 public: |
| 25 virtual void OnQueueingTimeForWindowEstimated( |
| 26 base::TimeDelta queueing_time) = 0; |
| 27 virtual ~Client() {} |
| 28 }; |
| 29 |
| 30 QueueingTimeEstimator(Client* client, |
| 31 CoarseDurationTimer* timer, |
| 32 base::TimeDelta window_duration); |
| 33 ~QueueingTimeEstimator() override; |
| 34 |
| 35 // TaskObserver implementation: |
| 36 void WillProcessTask(const base::PendingTask& pending_task) override; |
| 37 void DidProcessTask(const base::PendingTask& pending_task) override; |
| 38 |
| 39 private: |
| 40 Client* client_; // NOT OWNED. |
| 41 CoarseDurationTimer* timer_; |
| 42 int outstanding_task_count_; |
| 43 |
| 44 base::TimeDelta current_expected_queueing_time_; |
| 45 base::TimeDelta window_duration_; |
| 46 base::TimeTicks window_start_time_; |
| 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(QueueingTimeEstimator); |
| 49 }; |
| 50 |
| 51 } // namespace scheduler |
| 52 |
| 53 #endif // COMPONENTS_SCHEDULER_RENDERER_QUEUEING_TIME_ESTIMATOR_H_ |
OLD | NEW |