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

Unified Diff: Source/core/page/DOMTimer.cpp

Issue 19494002: Distinguish actions registered with setTimeout() and setInterval(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase again. Created 7 years, 5 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/page/DOMTimer.h ('k') | Source/core/page/DOMWindowTimers.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/DOMTimer.cpp
diff --git a/Source/core/page/DOMTimer.cpp b/Source/core/page/DOMTimer.cpp
index ee3157f4233b063b06c00e79943bdcbc09ce3cb6..e5529e9a1ab8e69a72a9e7b70fa347fc53ad11fa 100644
--- a/Source/core/page/DOMTimer.cpp
+++ b/Source/core/page/DOMTimer.cpp
@@ -68,21 +68,23 @@ double DOMTimer::visiblePageAlignmentInterval()
return 0;
}
-int DOMTimer::install(ScriptExecutionContext* context, PassOwnPtr<ScheduledAction> action, int timeout, bool singleShot)
+int DOMTimer::install(ScriptExecutionContext* context, Type type, PassOwnPtr<ScheduledAction> action, int timeout)
{
- int timeoutID = context->installNewTimeout(action, timeout, singleShot);
- InspectorInstrumentation::didInstallTimer(context, timeoutID, timeout, singleShot);
+ int timeoutID = context->installNewTimeout(type, action, timeout);
+ InspectorInstrumentation::didInstallTimer(context, timeoutID, timeout, type == TimeoutType); // FIXME: Fix inspector so it can accept a DOMTimer::Type value.
return timeoutID;
}
-void DOMTimer::removeByID(ScriptExecutionContext* context, int timeoutID)
+void DOMTimer::removeByIDIfTypeMatches(ScriptExecutionContext* context, Type type, int timeoutID)
{
- context->removeTimeoutByID(timeoutID);
+ // FIXME: Invoke didRemoveTimer() if a timer is actually removed.
+ context->removeTimeoutByIDIfTypeMatches(type, timeoutID);
InspectorInstrumentation::didRemoveTimer(context, timeoutID);
}
-DOMTimer::DOMTimer(ScriptExecutionContext* context, PassOwnPtr<ScheduledAction> action, int interval, bool singleShot, int timeoutID)
+DOMTimer::DOMTimer(ScriptExecutionContext* context, Type type, PassOwnPtr<ScheduledAction> action, int interval, int timeoutID)
: SuspendableTimer(context)
+ , m_type(type)
, m_timeoutID(timeoutID)
, m_nestingLevel(timerNestingLevel + 1)
, m_action(action)
@@ -94,10 +96,14 @@ DOMTimer::DOMTimer(ScriptExecutionContext* context, PassOwnPtr<ScheduledAction>
double intervalMilliseconds = max(oneMillisecond, interval * oneMillisecond);
if (intervalMilliseconds < minimumInterval && m_nestingLevel >= maxTimerNestingLevel)
intervalMilliseconds = minimumInterval;
- if (singleShot)
+ switch (type) {
+ case TimeoutType:
startOneShot(intervalMilliseconds);
- else
+ break;
+ case IntervalType:
startRepeating(intervalMilliseconds);
+ break;
+ }
}
DOMTimer::~DOMTimer()
@@ -109,6 +115,11 @@ int DOMTimer::timeoutID() const
return m_timeoutID;
}
+DOMTimer::Type DOMTimer::type() const
+{
+ return m_type;
+}
+
void DOMTimer::fired()
{
ScriptExecutionContext* context = scriptExecutionContext();
@@ -139,7 +150,8 @@ void DOMTimer::fired()
OwnPtr<ScheduledAction> action = m_action.release();
// This timer is being deleted; no access to member variables allowed after this point.
- context->removeTimeoutByID(m_timeoutID);
+ bool removed = context->removeTimeoutByIDIfTypeMatches(m_type, m_timeoutID);
+ ASSERT_UNUSED(removed, removed);
action->execute(context);
« no previous file with comments | « Source/core/page/DOMTimer.h ('k') | Source/core/page/DOMWindowTimers.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698