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

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

Issue 1646583002: [Reland] Per WebViewScheduler virtual time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove some unneeded changes Created 4 years, 10 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 4dbaea668b3d160958b7f8a841bbf7e4de65d237..91acaac745988982eb5817e0c9a267e7f0b4200e 100644
--- a/third_party/WebKit/Source/platform/Timer.cpp
+++ b/third_party/WebKit/Source/platform/Timer.cpp
@@ -40,16 +40,21 @@
namespace blink {
-TimerBase::TimerBase() : TimerBase(Platform::current()->currentThread()->scheduler()->timerTaskRunner()) { }
+TimerBase::TimerBase()
+ : m_nextFireTime(0)
+ , m_repeatInterval(0)
+ , m_cancellableTimerTask(nullptr)
+ , m_thread(Platform::current()->currentThread())
+ , m_webTaskRunner(m_thread->scheduler()->timerTaskRunner())
+{
+}
TimerBase::TimerBase(WebTaskRunner* webTaskRunner)
: m_nextFireTime(0)
, m_repeatInterval(0)
, m_cancellableTimerTask(nullptr)
+ , m_thread(Platform::current()->currentThread())
, m_webTaskRunner(webTaskRunner)
-#if ENABLE(ASSERT)
- , m_thread(currentThread())
-#endif
{
ASSERT(m_webTaskRunner);
}
@@ -61,16 +66,16 @@ TimerBase::~TimerBase()
void TimerBase::start(double nextFireInterval, double repeatInterval, const WebTraceLocation& caller)
{
- ASSERT(m_thread == currentThread());
+ ASSERT(m_thread->isCurrentThread());
m_location = caller;
m_repeatInterval = repeatInterval;
- setNextFireTime(monotonicallyIncreasingTime(), nextFireInterval);
+ setNextFireTime(timerMonotonicallyIncreasingTime(), nextFireInterval);
}
void TimerBase::stop()
{
- ASSERT(m_thread == currentThread());
+ ASSERT(m_thread->isCurrentThread());
m_repeatInterval = 0;
m_nextFireTime = 0;
@@ -82,7 +87,7 @@ void TimerBase::stop()
double TimerBase::nextFireInterval() const
{
ASSERT(isActive());
- double current = monotonicallyIncreasingTime();
+ double current = timerMonotonicallyIncreasingTime();
if (m_nextFireTime < current)
return 0;
return m_nextFireTime - current;
@@ -95,7 +100,7 @@ WebTaskRunner* TimerBase::timerTaskRunner()
void TimerBase::setNextFireTime(double now, double delay)
{
- ASSERT(m_thread == currentThread());
+ ASSERT(m_thread->isCurrentThread());
double newTime = now + delay;
@@ -117,17 +122,17 @@ void TimerBase::runInternal()
return;
TRACE_EVENT0("blink", "TimerBase::run");
- ASSERT_WITH_MESSAGE(m_thread == currentThread(), "Timer posted by %s %s was run on a different thread", m_location.functionName(), m_location.fileName());
+ ASSERT_WITH_MESSAGE(m_thread->isCurrentThread(), "Timer posted by %s %s was run on a different thread", m_location.functionName(), m_location.fileName());
TRACE_EVENT_SET_SAMPLING_STATE("blink", "BlinkInternal");
if (m_repeatInterval) {
- double now = monotonicallyIncreasingTime();
+ double now = timerMonotonicallyIncreasingTime();
// 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_nextFireTime, m_repeatInterval);
- setNextFireTime(monotonicallyIncreasingTime(), intervalToNextFireTime);
+ setNextFireTime(timerMonotonicallyIncreasingTime(), intervalToNextFireTime);
} else {
m_nextFireTime = 0;
}

Powered by Google App Engine
This is Rietveld 408576698