| Index: third_party/WebKit/Source/platform/Timer.cpp
|
| diff --git a/third_party/WebKit/Source/platform/Timer.cpp b/third_party/WebKit/Source/platform/Timer.cpp
|
| index ad619a3cf12d69041cb403d9afafdd874e4e1037..e27520d7f0a88df31102229e70df637a1ccbab0b 100644
|
| --- a/third_party/WebKit/Source/platform/Timer.cpp
|
| +++ b/third_party/WebKit/Source/platform/Timer.cpp
|
| @@ -43,7 +43,6 @@ namespace blink {
|
|
|
| TimerBase::TimerBase()
|
| : m_nextFireTime(0)
|
| - , m_unalignedNextFireTime(0)
|
| , m_repeatInterval(0)
|
| , m_cancellableTimerTask(nullptr)
|
| , m_webScheduler(Platform::current()->currentThread()->scheduler())
|
| @@ -96,23 +95,16 @@ void TimerBase::setNextFireTime(double now, double delay)
|
| {
|
| ASSERT(m_thread == currentThread());
|
|
|
| - m_unalignedNextFireTime = now + delay;
|
| + double newTime = now + delay;
|
|
|
| - double newTime = alignedFireTime(m_unalignedNextFireTime);
|
| if (m_nextFireTime != newTime) {
|
| m_nextFireTime = newTime;
|
| if (m_cancellableTimerTask)
|
| m_cancellableTimerTask->cancel();
|
| m_cancellableTimerTask = new CancellableTimerTask(this);
|
| - if (newTime != m_unalignedNextFireTime) {
|
| - // If the timer is being aligned, use postTimerTaskAt() to schedule it
|
| - // so that the relative order of aligned timers is preserved.
|
| - // TODO(skyostil): Move timer alignment into the scheduler.
|
| - m_webScheduler->postTimerTaskAt(m_location, m_cancellableTimerTask, m_nextFireTime);
|
| - } else {
|
| - double delayMs = 1000.0 * (newTime - now);
|
| - m_webScheduler->timerTaskRunner()->postDelayedTask(m_location, m_cancellableTimerTask, delayMs);
|
| - }
|
| +
|
| + double delayMs = 1000.0 * (newTime - now);
|
| + timerTaskRunner()->postDelayedTask(m_location, m_cancellableTimerTask, delayMs);
|
| }
|
| }
|
|
|
| @@ -126,34 +118,24 @@ void TimerBase::runInternal()
|
| ASSERT_WITH_MESSAGE(m_thread == currentThread(), "Timer posted by %s %s was run on a different thread", m_location.functionName(), m_location.fileName());
|
| TRACE_EVENT_SET_SAMPLING_STATE("blink", "BlinkInternal");
|
|
|
| - m_nextFireTime = 0;
|
| if (m_repeatInterval) {
|
| double now = monotonicallyIncreasingTime();
|
| // This computation should be drift free, and it will cope if we miss a beat,
|
| // which can easily happen if the thread is busy. It will also cope if we get
|
| // called slightly before m_unalignedNextFireTime, which can happen due to lack
|
| // of timer precision.
|
| - double intervalToNextFireTime = m_repeatInterval - fmod(now - m_unalignedNextFireTime, m_repeatInterval);
|
| + double intervalToNextFireTime = m_repeatInterval - fmod(now - m_nextFireTime, m_repeatInterval);
|
| setNextFireTime(monotonicallyIncreasingTime(), intervalToNextFireTime);
|
| + } else {
|
| + m_nextFireTime = 0;
|
| }
|
| fired();
|
| TRACE_EVENT_SET_SAMPLING_STATE("blink", "Sleeping");
|
| }
|
|
|
| -void TimerBase::didChangeAlignmentInterval(double now)
|
| -{
|
| - setNextFireTime(now, m_unalignedNextFireTime - now);
|
| -}
|
| -
|
| -double TimerBase::nextUnalignedFireInterval() const
|
| -{
|
| - ASSERT(isActive());
|
| - return std::max(m_unalignedNextFireTime - monotonicallyIncreasingTime(), 0.0);
|
| -}
|
| -
|
| bool TimerBase::Comparator::operator()(const TimerBase* a, const TimerBase* b) const
|
| {
|
| - return a->m_unalignedNextFireTime < b->m_unalignedNextFireTime;
|
| + return a->m_nextFireTime < b->m_nextFireTime;
|
| }
|
|
|
| } // namespace blink
|
|
|