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

Unified Diff: Source/platform/Timer.cpp

Issue 1211543004: Revert "Lazily constructed bespoke cancellable timer task. This is" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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
« no previous file with comments | « Source/platform/Timer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/Timer.cpp
diff --git a/Source/platform/Timer.cpp b/Source/platform/Timer.cpp
index 33f33481e0e166583ae9c0817637767e09da58e0..235966fbe161907dcd30d864fa748b1284e644e4 100644
--- a/Source/platform/Timer.cpp
+++ b/Source/platform/Timer.cpp
@@ -29,7 +29,6 @@
#include "platform/TraceEvent.h"
#include "public/platform/Platform.h"
-#include "public/platform/WebScheduler.h"
#include "wtf/AddressSanitizer.h"
#include "wtf/Atomics.h"
#include "wtf/CurrentTime.h"
@@ -45,7 +44,7 @@ TimerBase::TimerBase()
: m_nextFireTime(0)
, m_unalignedNextFireTime(0)
, m_repeatInterval(0)
- , m_cancellableTimerTask(nullptr)
+ , m_cancellableTaskFactory(WTF::bind(&TimerBase::run, this))
, m_webScheduler(Platform::current()->currentThread()->scheduler())
#if ENABLE(ASSERT)
, m_thread(currentThread())
@@ -73,9 +72,7 @@ void TimerBase::stop()
m_repeatInterval = 0;
m_nextFireTime = 0;
- if (m_cancellableTimerTask)
- m_cancellableTimerTask->cancel();
- m_cancellableTimerTask = nullptr;
+ m_cancellableTaskFactory.cancel();
}
double TimerBase::nextFireInterval() const
@@ -101,15 +98,12 @@ void TimerBase::setNextFireTime(double now, double delay)
long long delayMs = static_cast<long long>(ceil((newTime - now) * 1000.0));
if (delayMs < 0)
delayMs = 0;
- if (m_cancellableTimerTask)
- m_cancellableTimerTask->cancel();
- m_cancellableTimerTask = new CancellableTimerTask(this);
- m_webScheduler->postTimerTask(m_location, m_cancellableTimerTask, delayMs);
+ m_webScheduler->postTimerTask(m_location, m_cancellableTaskFactory.cancelAndCreate(), delayMs);
}
}
NO_LAZY_SWEEP_SANITIZE_ADDRESS
-void TimerBase::runInternal()
+void TimerBase::run()
{
if (!canFire())
return;
« no previous file with comments | « Source/platform/Timer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698