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

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: m_nextFireInterval can be zero if the timer is active 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..c4d5a88da309e2b3b1db5df91bd92eabb26e3d27 100644
--- a/Source/core/frame/SuspendableTimer.cpp
+++ b/Source/core/frame/SuspendableTimer.cpp
@@ -27,13 +27,18 @@
#include "config.h"
#include "core/frame/SuspendableTimer.h"
+#include <cfloat>
+
namespace blink {
+namespace {
+const double kNextFireIntervalInvalid = -DBL_MAX;
João Eiras 2014/10/17 16:04:10 m_nextFireInterval could be zero for the case of s
Mike West 2014/10/18 09:06:42 Hrm. This kills some of the elegance of the previo
+}
+
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 +56,7 @@ bool SuspendableTimer::hasPendingActivity() const
void SuspendableTimer::stop()
{
+ m_nextFireInterval = kNextFireIntervalInvalid;
TimerBase::stop();
}
@@ -60,8 +66,7 @@ void SuspendableTimer::suspend()
ASSERT(!m_suspended);
m_suspended = true;
#endif
- m_active = isActive();
- if (m_active) {
+ if (isActive()) {
m_nextFireInterval = nextUnalignedFireInterval();
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) {
+ // 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