Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Unified Diff: third_party/WebKit/Source/platform/Timer.cpp

Issue 2155143002: Fix a bug that could occasionaly cause setInterval to stop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 14ee907247ac45fc3ef7835e73de28cb590fddbc..61d8556e6e62f58ca6ab21333aac9fb52cded6e5 100644
--- a/third_party/WebKit/Source/platform/Timer.cpp
+++ b/third_party/WebKit/Source/platform/Timer.cpp
@@ -97,17 +97,13 @@ void TimerBase::setNextFireTime(double now, double delay)
{
ASSERT(m_thread == currentThread());
- double newTime = now + delay;
-
- if (m_nextFireTime != newTime) {
- m_nextFireTime = newTime;
- if (m_cancellableTimerTask)
- m_cancellableTimerTask->cancel();
- m_cancellableTimerTask = new CancellableTimerTask(this);
+ m_nextFireTime = now + delay;
+ if (m_cancellableTimerTask)
+ m_cancellableTimerTask->cancel();
+ m_cancellableTimerTask = new CancellableTimerTask(this);
- double delayMs = 1000.0 * (newTime - now);
- timerTaskRunner()->postDelayedTask(m_location, m_cancellableTimerTask, delayMs);
- }
+ double delayMs = 1000.0 * delay;
+ timerTaskRunner()->postDelayedTask(m_location, m_cancellableTimerTask, delayMs);
}
NO_LAZY_SWEEP_SANITIZE_ADDRESS
@@ -129,7 +125,7 @@ void TimerBase::runInternal()
// called slightly before m_unalignedNextFireTime, which can happen due to lack
// of timer precision.
double intervalToNextFireTime = m_repeatInterval - fmod(now - m_nextFireTime, m_repeatInterval);
- setNextFireTime(timerMonotonicallyIncreasingTime(), intervalToNextFireTime);
+ setNextFireTime(now, intervalToNextFireTime);
} else {
m_nextFireTime = 0;
}

Powered by Google App Engine
This is Rietveld 408576698