Commit ad6171d8 authored by joaoe@opera.com's avatar joaoe@opera.com

Made SuspendableTimer smaller (removed redudant m_active field)

And fixed the FIXME in SuspendableTimer::resume()

Review URL: https://codereview.chromium.org/613163006

git-svn-id: svn://svn.chromium.org/blink/trunk@183986 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent bcad65bf
...@@ -29,11 +29,15 @@ ...@@ -29,11 +29,15 @@
namespace blink { namespace blink {
namespace {
// The lowest value returned by TimerBase::nextUnalignedFireInterval is 0.0
const double kNextFireIntervalInvalid = -1.0;
}
SuspendableTimer::SuspendableTimer(ExecutionContext* context) SuspendableTimer::SuspendableTimer(ExecutionContext* context)
: ActiveDOMObject(context) : ActiveDOMObject(context)
, m_nextFireInterval(0) , m_nextFireInterval(kNextFireIntervalInvalid)
, m_repeatInterval(0) , m_repeatInterval(0)
, m_active(false)
#if ENABLE(ASSERT) #if ENABLE(ASSERT)
, m_suspended(false) , m_suspended(false)
#endif #endif
...@@ -51,6 +55,7 @@ bool SuspendableTimer::hasPendingActivity() const ...@@ -51,6 +55,7 @@ bool SuspendableTimer::hasPendingActivity() const
void SuspendableTimer::stop() void SuspendableTimer::stop()
{ {
m_nextFireInterval = kNextFireIntervalInvalid;
TimerBase::stop(); TimerBase::stop();
} }
...@@ -60,9 +65,9 @@ void SuspendableTimer::suspend() ...@@ -60,9 +65,9 @@ void SuspendableTimer::suspend()
ASSERT(!m_suspended); ASSERT(!m_suspended);
m_suspended = true; m_suspended = true;
#endif #endif
m_active = isActive(); if (isActive()) {
if (m_active) {
m_nextFireInterval = nextUnalignedFireInterval(); m_nextFireInterval = nextUnalignedFireInterval();
ASSERT(m_nextFireInterval >= 0.0);
m_repeatInterval = repeatInterval(); m_repeatInterval = repeatInterval();
TimerBase::stop(); TimerBase::stop();
} }
...@@ -74,9 +79,12 @@ void SuspendableTimer::resume() ...@@ -74,9 +79,12 @@ void SuspendableTimer::resume()
ASSERT(m_suspended); ASSERT(m_suspended);
m_suspended = false; m_suspended = false;
#endif #endif
// FIXME: FROM_HERE is wrong here. if (m_nextFireInterval >= 0.0) {
if (m_active) // start() was called before, therefore location() is already set.
start(m_nextFireInterval, m_repeatInterval, FROM_HERE); // m_nextFireInterval is only set in suspend() if the Timer was active.
start(m_nextFireInterval, m_repeatInterval, location());
m_nextFireInterval = kNextFireIntervalInvalid;
}
} }
} // namespace blink } // namespace blink
...@@ -48,7 +48,6 @@ private: ...@@ -48,7 +48,6 @@ private:
double m_nextFireInterval; double m_nextFireInterval;
double m_repeatInterval; double m_repeatInterval;
bool m_active;
#if ENABLE(ASSERT) #if ENABLE(ASSERT)
bool m_suspended; bool m_suspended;
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment