| 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 #include "platform/scheduler/base/thread_load_tracker.h" | 5 #include "platform/scheduler/base/thread_load_tracker.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 namespace scheduler { | 10 namespace scheduler { |
| 11 | 11 |
| 12 ThreadLoadTracker::ThreadLoadTracker(base::TimeTicks now, | 12 ThreadLoadTracker::ThreadLoadTracker(base::TimeTicks now, |
| 13 const Callback& callback, | 13 const Callback& callback, |
| 14 base::TimeDelta reporting_interval, | 14 base::TimeDelta reporting_interval, |
| 15 base::TimeDelta waiting_period) | 15 base::TimeDelta waiting_period) |
| 16 : time_(now), | 16 : time_(now), |
| 17 thread_state_(ThreadState::ACTIVE), | 17 thread_state_(ThreadState::PAUSED), |
| 18 last_state_change_time_(now), | 18 last_state_change_time_(now), |
| 19 waiting_period_(waiting_period), | 19 waiting_period_(waiting_period), |
| 20 reporting_interval_(reporting_interval), | 20 reporting_interval_(reporting_interval), |
| 21 callback_(callback) { | 21 callback_(callback) { |
| 22 next_reporting_time_ = now + waiting_period_; | 22 next_reporting_time_ = now + waiting_period_; |
| 23 } | 23 } |
| 24 | 24 |
| 25 ThreadLoadTracker::~ThreadLoadTracker() {} | 25 ThreadLoadTracker::~ThreadLoadTracker() {} |
| 26 | 26 |
| 27 void ThreadLoadTracker::Pause(base::TimeTicks now) { | 27 void ThreadLoadTracker::Pause(base::TimeTicks now) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 double ThreadLoadTracker::Load() { | 118 double ThreadLoadTracker::Load() { |
| 119 return run_time_inside_window_.InSecondsF() / | 119 return run_time_inside_window_.InSecondsF() / |
| 120 reporting_interval_.InSecondsF(); | 120 reporting_interval_.InSecondsF(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 } // namespace scheduler | 123 } // namespace scheduler |
| 124 } // namespace blink | 124 } // namespace blink |
| OLD | NEW |