Chromium Code Reviews| Index: Source/core/frame/SuspendableTimer.cpp |
| diff --git a/Source/core/frame/SuspendableTimer.cpp b/Source/core/frame/SuspendableTimer.cpp |
| index 64f082928ced7822dc69e77401c7c0d37b002ea7..fb5521112d9b01bf92ac3dfeaaa208f4881dfd7c 100644 |
| --- a/Source/core/frame/SuspendableTimer.cpp |
| +++ b/Source/core/frame/SuspendableTimer.cpp |
| @@ -29,11 +29,15 @@ |
| namespace blink { |
| +namespace { |
| +// The smallest valid value returned by TimerBase::nextUnalignedFireInterval is 0.0 |
| +const double kNextFireIntervalInvalid = -1.0; |
| +} |
| + |
| SuspendableTimer::SuspendableTimer(ExecutionContext* context) |
| : ActiveDOMObject(context) |
| - , m_nextFireInterval(0) |
| + , m_nextFireInterval(kNextFireIntervalInvalid) |
| , m_repeatInterval(0) |
| - , m_active(false) |
| #if ENABLE(ASSERT) |
| , m_suspended(false) |
| #endif |
| @@ -51,6 +55,7 @@ bool SuspendableTimer::hasPendingActivity() const |
| void SuspendableTimer::stop() |
| { |
| + m_nextFireInterval = kNextFireIntervalInvalid; |
| TimerBase::stop(); |
| } |
| @@ -60,9 +65,9 @@ void SuspendableTimer::suspend() |
| ASSERT(!m_suspended); |
| m_suspended = true; |
| #endif |
| - m_active = isActive(); |
| - if (m_active) { |
| + if (isActive()) { |
| m_nextFireInterval = nextUnalignedFireInterval(); |
| + ASSERT(m_nextFireInterval > kNextFireIntervalInvalid); |
|
Mike West
2014/10/20 10:13:51
Can you please change this check to `m_nextFireInt
|
| m_repeatInterval = repeatInterval(); |
| TimerBase::stop(); |
| } |
| @@ -74,9 +79,12 @@ void SuspendableTimer::resume() |
| ASSERT(m_suspended); |
| m_suspended = false; |
| #endif |
| - // FIXME: FROM_HERE is wrong here. |
| - if (m_active) |
| - start(m_nextFireInterval, m_repeatInterval, FROM_HERE); |
| + if (m_nextFireInterval > kNextFireIntervalInvalid) { |
|
Mike West
2014/10/20 10:13:51
Here as well, please.
|
| + // start() was called before, therefore location() is already set. |
| + // m_nextFireInterval is only set in suspend() if the Timer was active. |
| + start(m_nextFireInterval, m_repeatInterval, location()); |
| + m_nextFireInterval = kNextFireIntervalInvalid; |
| + } |
| } |
| } // namespace blink |