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

Unified Diff: Source/core/frame/SuspendableTimer.cpp

Issue 613163006: Made SuspendableTimer smaller (removed redudant m_active field) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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/core/frame/SuspendableTimer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/SuspendableTimer.cpp
diff --git a/Source/core/frame/SuspendableTimer.cpp b/Source/core/frame/SuspendableTimer.cpp
index 64f082928ced7822dc69e77401c7c0d37b002ea7..8a9d0485fad87b493ee2d9790b50393e7fa28e1e 100644
--- a/Source/core/frame/SuspendableTimer.cpp
+++ b/Source/core/frame/SuspendableTimer.cpp
@@ -29,11 +29,15 @@
namespace blink {
+namespace {
+// The lowest 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 >= 0.0);
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 >= 0.0) {
+ // 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
« no previous file with comments | « Source/core/frame/SuspendableTimer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698