OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #include "platform/scheduler/renderer/idle_time_estimator.h" | 5 #include "platform/scheduler/renderer/idle_time_estimator.h" |
6 | 6 |
7 #include "base/time/default_tick_clock.h" | 7 #include "base/time/default_tick_clock.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 namespace scheduler { | 10 namespace scheduler { |
(...skipping 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 | 25 |
26 IdleTimeEstimator::~IdleTimeEstimator() { | 26 IdleTimeEstimator::~IdleTimeEstimator() { |
27 compositor_task_runner_->RemoveTaskObserver(this); | 27 compositor_task_runner_->RemoveTaskObserver(this); |
28 } | 28 } |
29 | 29 |
30 base::TimeDelta IdleTimeEstimator::GetExpectedIdleDuration( | 30 base::TimeDelta IdleTimeEstimator::GetExpectedIdleDuration( |
31 base::TimeDelta compositor_frame_interval) const { | 31 base::TimeDelta compositor_frame_interval) const { |
32 base::TimeDelta expected_compositor_task_runtime_ = | 32 base::TimeDelta expected_compositor_task_runtime_ = |
33 per_frame_compositor_task_runtime_.Percentile(estimation_percentile_); | 33 per_frame_compositor_task_runtime_.Percentile(estimation_percentile_); |
34 return std::max(base::TimeDelta(), compositor_frame_interval - | 34 return std::max( |
35 expected_compositor_task_runtime_); | 35 base::TimeDelta(), |
| 36 compositor_frame_interval - expected_compositor_task_runtime_); |
36 } | 37 } |
37 | 38 |
38 void IdleTimeEstimator::DidCommitFrameToCompositor() { | 39 void IdleTimeEstimator::DidCommitFrameToCompositor() { |
39 // This will run inside of a WillProcessTask / DidProcessTask pair, let | 40 // This will run inside of a WillProcessTask / DidProcessTask pair, let |
40 // DidProcessTask know a frame was comitted. | 41 // DidProcessTask know a frame was comitted. |
41 if (nesting_level_ == 1) | 42 if (nesting_level_ == 1) |
42 did_commit_ = true; | 43 did_commit_ = true; |
43 } | 44 } |
44 | 45 |
45 void IdleTimeEstimator::Clear() { | 46 void IdleTimeEstimator::Clear() { |
(...skipping 21 matching lines...) Expand all Loading... |
67 if (did_commit_) { | 68 if (did_commit_) { |
68 per_frame_compositor_task_runtime_.InsertSample( | 69 per_frame_compositor_task_runtime_.InsertSample( |
69 cumulative_compositor_runtime_); | 70 cumulative_compositor_runtime_); |
70 cumulative_compositor_runtime_ = base::TimeDelta(); | 71 cumulative_compositor_runtime_ = base::TimeDelta(); |
71 did_commit_ = false; | 72 did_commit_ = false; |
72 } | 73 } |
73 } | 74 } |
74 | 75 |
75 } // namespace scheduler | 76 } // namespace scheduler |
76 } // namespace blink | 77 } // namespace blink |
OLD | NEW |