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 #include "components/scheduler/renderer/coarse_duration_timer.h" |
| 6 |
| 7 #include "base/message_loop/message_loop.h" |
| 8 |
| 9 namespace scheduler { |
| 10 |
| 11 void CoarseDurationTimer::OnUpdateRecentTime(base::TimeTicks recent_time) { |
| 12 most_recent_time_ = recent_time; |
| 13 if (state_ == State::WITHIN_INTERVAL_NEEDS_START) { |
| 14 start_time_ = recent_time; |
| 15 state_ = State::WITHIN_INTERVAL; |
| 16 } |
| 17 } |
| 18 |
| 19 void CoarseDurationTimer::BeginInterval() { |
| 20 // DCHECK(state_ == State::OUTSIDE_INTERVAL); |
| 21 state_ = State::WITHIN_INTERVAL_NEEDS_START; |
| 22 } |
| 23 |
| 24 base::TimeDelta CoarseDurationTimer::EndInterval() { |
| 25 base::TimeDelta duration; |
| 26 // DCHECK(state_ != State::OUTSIDE_INTERVAL); |
| 27 |
| 28 // If we haven't received a single time update within this interval, report |
| 29 // a duration of 0. |
| 30 if (state_ != State::WITHIN_INTERVAL_NEEDS_START) |
| 31 duration = most_recent_time_ - start_time_; |
| 32 state_ = State::OUTSIDE_INTERVAL; |
| 33 |
| 34 if (!duration.is_zero()) |
| 35 LOG(ERROR) << "DURATION IS " << duration.InMillisecondsF(); |
| 36 return duration; |
| 37 } |
| 38 |
| 39 } // namespace scheduler |
OLD | NEW |