| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "CCDelayBasedTimeSource.h" | 7 #include "CCDelayBasedTimeSource.h" |
| 8 | 8 |
| 9 #include "TraceEvent.h" | 9 #include "TraceEvent.h" |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 base::TimeTicks CCDelayBasedTimeSource::lastTickTime() | 83 base::TimeTicks CCDelayBasedTimeSource::lastTickTime() |
| 84 { | 84 { |
| 85 return m_lastTickTime; | 85 return m_lastTickTime; |
| 86 } | 86 } |
| 87 | 87 |
| 88 base::TimeTicks CCDelayBasedTimeSource::nextTickTime() | 88 base::TimeTicks CCDelayBasedTimeSource::nextTickTime() |
| 89 { | 89 { |
| 90 return active() ? m_currentParameters.tickTarget : base::TimeTicks(); | 90 return active() ? m_currentParameters.tickTarget : base::TimeTicks(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 base::TimeDelta CCDelayBasedTimeSource::interval() |
| 94 { |
| 95 return m_currentParameters.interval; |
| 96 } |
| 97 |
| 93 void CCDelayBasedTimeSource::onTimerFired() | 98 void CCDelayBasedTimeSource::onTimerFired() |
| 94 { | 99 { |
| 95 ASSERT(m_state != STATE_INACTIVE); | 100 ASSERT(m_state != STATE_INACTIVE); |
| 96 | 101 |
| 97 base::TimeTicks now = this->now(); | 102 base::TimeTicks now = this->now(); |
| 98 m_lastTickTime = now; | 103 m_lastTickTime = now; |
| 99 | 104 |
| 100 if (m_state == STATE_STARTING) { | 105 if (m_state == STATE_STARTING) { |
| 101 setTimebaseAndInterval(now, m_currentParameters.interval); | 106 setTimebaseAndInterval(now, m_currentParameters.interval); |
| 102 m_state = STATE_ACTIVE; | 107 m_state = STATE_ACTIVE; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 base::TimeDelta delay = newTickTarget - now; | 228 base::TimeDelta delay = newTickTarget - now; |
| 224 ASSERT(delay.InMillisecondsF() <= | 229 ASSERT(delay.InMillisecondsF() <= |
| 225 m_nextParameters.interval.InMillisecondsF() * (1.0 + doubleTickThresh
old)); | 230 m_nextParameters.interval.InMillisecondsF() * (1.0 + doubleTickThresh
old)); |
| 226 m_timer.startOneShot(delay.InSecondsF()); | 231 m_timer.startOneShot(delay.InSecondsF()); |
| 227 | 232 |
| 228 m_nextParameters.tickTarget = newTickTarget; | 233 m_nextParameters.tickTarget = newTickTarget; |
| 229 m_currentParameters = m_nextParameters; | 234 m_currentParameters = m_nextParameters; |
| 230 } | 235 } |
| 231 | 236 |
| 232 } | 237 } |
| OLD | NEW |