OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_QUEUEING_TIME_ESTI MATOR_H_ | 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_QUEUEING_TIME_ESTI MATOR_H_ |
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_QUEUEING_TIME_ESTI MATOR_H_ | 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_QUEUEING_TIME_ESTI MATOR_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "public/platform/WebCommon.h" | 10 #include "public/platform/WebCommon.h" |
11 | 11 |
12 #include <memory> | |
13 | |
12 namespace base { | 14 namespace base { |
13 class TickClock; | 15 class TickClock; |
14 } | 16 } |
15 | 17 |
16 namespace blink { | 18 namespace blink { |
17 namespace scheduler { | 19 namespace scheduler { |
18 | 20 |
19 // Records the expected queueing time for a high priority task occurring | 21 // Records the expected queueing time for a high priority task occurring |
20 // randomly during each interval of length |window_duration|. | 22 // randomly during each interval of length |window_duration|. |
21 class BLINK_PLATFORM_EXPORT QueueingTimeEstimator { | 23 class BLINK_PLATFORM_EXPORT QueueingTimeEstimator { |
22 public: | 24 public: |
23 class BLINK_PLATFORM_EXPORT Client { | 25 class BLINK_PLATFORM_EXPORT Client { |
24 public: | 26 public: |
25 virtual void OnQueueingTimeForWindowEstimated( | 27 virtual void OnQueueingTimeForWindowEstimated( |
26 base::TimeDelta queueing_time) = 0; | 28 base::TimeDelta queueing_time) = 0; |
27 Client() {} | 29 Client() {} |
28 virtual ~Client() {} | 30 virtual ~Client() {} |
29 | 31 |
30 private: | 32 private: |
31 DISALLOW_COPY_AND_ASSIGN(Client); | 33 DISALLOW_COPY_AND_ASSIGN(Client); |
32 }; | 34 }; |
33 | 35 |
34 QueueingTimeEstimator(Client* client, base::TimeDelta window_duration); | 36 QueueingTimeEstimator(Client* client, base::TimeDelta window_duration); |
35 | 37 |
36 void OnToplevelTaskCompleted(base::TimeTicks task_start_time, | 38 void OnTopLevelTaskStarted(base::TimeTicks task_start_time); |
39 void OnTopLevelTaskCompleted(base::TimeTicks task_start_time, | |
37 base::TimeTicks task_end_time); | 40 base::TimeTicks task_end_time); |
38 | 41 |
42 base::TimeDelta EstimateQueueingTimeIncludingCurrentTask(base::TimeTicks now) const; | |
43 | |
39 private: | 44 private: |
45 // Returns a clone of this object, with the |client_| set to |client|. | |
46 std::unique_ptr<QueueingTimeEstimator> CloneWithClient(Client* client) const; | |
Sami
2016/08/24 14:56:01
Is it necessary for this to be a heap allocation?
tdresser
2016/08/24 17:22:50
Done.
| |
40 bool TimePastWindowEnd(base::TimeTicks task_end_time); | 47 bool TimePastWindowEnd(base::TimeTicks task_end_time); |
41 Client* client_; // NOT OWNED. | 48 Client* client_; // NOT OWNED. |
42 | 49 |
43 base::TimeDelta current_expected_queueing_time_; | 50 base::TimeDelta current_expected_queueing_time_; |
44 base::TimeDelta window_duration_; | 51 base::TimeDelta window_duration_; |
45 base::TimeTicks window_start_time_; | 52 base::TimeTicks window_start_time_; |
46 | 53 |
54 // Only used when including active task in estimated queueing time. | |
55 base::TimeTicks current_task_start_time_; | |
56 | |
47 DISALLOW_COPY_AND_ASSIGN(QueueingTimeEstimator); | 57 DISALLOW_COPY_AND_ASSIGN(QueueingTimeEstimator); |
48 }; | 58 }; |
49 | 59 |
50 } // namespace scheduler | 60 } // namespace scheduler |
51 } // namespace blink | 61 } // namespace blink |
52 | 62 |
53 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_QUEUEING_TIME_E STIMATOR_H_ | 63 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_QUEUEING_TIME_E STIMATOR_H_ |
OLD | NEW |