Chromium Code Reviews| 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 base { | |
| 15 class TickClock; | |
| 16 } | |
| 17 | |
| 18 namespace scheduler { | |
| 19 | |
| 20 // Records the expected queueing time for a high priority task occurring | |
| 21 // randomly during each interval of length |window_duration|. | |
| 22 class SCHEDULER_EXPORT QueueingTimeEstimator | |
| 23 : public base::MessageLoop::TaskObserver { | |
| 24 public: | |
| 25 class QueueingTimeEstimatorClient { | |
|
Sami
2016/04/20 09:51:27
naming nit: This could just be called |Client| sin
tdresser
2016/04/20 15:13:33
Done.
| |
| 26 public: | |
|
Sami
2016/04/20 09:51:27
Please add a virtual destructor.
tdresser
2016/04/20 15:13:32
Done.
| |
| 27 virtual void OnQueueingTimeForWindowEstimated( | |
| 28 base::TimeDelta queueing_time) = 0; | |
| 29 }; | |
| 30 | |
| 31 QueueingTimeEstimator(QueueingTimeEstimatorClient* client, | |
| 32 base::TickClock* time_source, | |
| 33 base::TimeDelta window_duration); | |
| 34 ~QueueingTimeEstimator() override; | |
| 35 | |
| 36 // TaskObserver implementation: | |
| 37 void WillProcessTask(const base::PendingTask& pending_task) override; | |
| 38 void DidProcessTask(const base::PendingTask& pending_task) override; | |
| 39 | |
| 40 private: | |
| 41 QueueingTimeEstimatorClient* client_; // NOT OWNED. | |
| 42 base::TickClock* time_source_; // NOT OWNED. | |
| 43 int outstanding_task_count_; | |
| 44 | |
| 45 base::TimeTicks task_start_time_; | |
| 46 base::TimeDelta current_expected_queueing_time_; | |
| 47 base::TimeDelta window_duration_; | |
| 48 base::TimeTicks window_start_time_; | |
| 49 | |
| 50 DISALLOW_COPY_AND_ASSIGN(QueueingTimeEstimator); | |
| 51 }; | |
| 52 | |
| 53 } // namespace scheduler | |
| 54 | |
| 55 #endif // COMPONENTS_SCHEDULER_RENDERER_QUEUEING_TIME_ESTIMATOR_H_ | |
| OLD | NEW |