Chromium Code Reviews| Index: Source/core/page/DOMTimer.cpp |
| diff --git a/Source/core/page/DOMTimer.cpp b/Source/core/page/DOMTimer.cpp |
| index 08a9ba99912a79b687581192168a7210dba4b0fd..908dade80a61f4909cff299329835e2ce2b918e6 100644 |
| --- a/Source/core/page/DOMTimer.cpp |
| +++ b/Source/core/page/DOMTimer.cpp |
| @@ -69,21 +69,22 @@ double DOMTimer::visiblePageAlignmentInterval() |
| return 0; |
| } |
| -int DOMTimer::install(ScriptExecutionContext* context, PassOwnPtr<ScheduledAction> action, int timeout, bool singleShot) |
| +int DOMTimer::install(ScriptExecutionContext* context, TimerType timerType, PassOwnPtr<ScheduledAction> action, int timeout) |
| { |
| - int timeoutID = context->installNewTimeout(action, timeout, singleShot); |
| - InspectorInstrumentation::didInstallTimer(context, timeoutID, timeout, singleShot); |
| + int timeoutID = context->installNewTimeout(timerType, action, timeout); |
| + InspectorInstrumentation::didInstallTimer(context, timeoutID, timeout, timerType == TimerTypeTimeout); // FIXME: Fix inspector so it can accept a TimerType value. |
| return timeoutID; |
| } |
| -void DOMTimer::removeByID(ScriptExecutionContext* context, int timeoutID) |
| +void DOMTimer::removeByIDIfTypeMatches(ScriptExecutionContext* context, TimerType timerType, int timeoutID) |
| { |
| - context->removeTimeoutByID(timeoutID); |
| - InspectorInstrumentation::didRemoveTimer(context, timeoutID); |
| + context->removeTimeoutByIDIfTypeMatches(timerType, timeoutID); |
| + InspectorInstrumentation::didRemoveTimer(context, timeoutID == TimerTypeTimeout); // FIXME: Ditto. |
|
Ken Russell (switch to Gerrit)
2013/07/18 19:05:13
Shouldn't didRemoveTimer only be called if ScriptE
Yuta Kitamura
2013/07/19 05:14:08
Sounds like a good idea, but when I tried locally,
Ken Russell (switch to Gerrit)
2013/07/19 20:28:36
Yes, thanks for trying to make the change. Sounds
|
| } |
| -DOMTimer::DOMTimer(ScriptExecutionContext* context, PassOwnPtr<ScheduledAction> action, int interval, bool singleShot, int timeoutID) |
| +DOMTimer::DOMTimer(ScriptExecutionContext* context, TimerType timerType, PassOwnPtr<ScheduledAction> action, int interval, int timeoutID) |
| : SuspendableTimer(context) |
| + , m_timerType(timerType) |
| , m_timeoutID(timeoutID) |
| , m_nestingLevel(timerNestingLevel + 1) |
| , m_action(action) |
| @@ -95,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 (timerType) { |
| + case TimerTypeTimeout: |
| startOneShot(intervalMilliseconds); |
| - else |
| + break; |
| + case TimerTypeInterval: |
| startRepeating(intervalMilliseconds); |
| + break; |
| + } |
| } |
| DOMTimer::~DOMTimer() |
| @@ -110,6 +115,11 @@ int DOMTimer::timeoutID() const |
| return m_timeoutID; |
| } |
| +DOMTimer::TimerType DOMTimer::timerType() const |
| +{ |
| + return m_timerType; |
| +} |
| + |
| void DOMTimer::fired() |
| { |
| ScriptExecutionContext* context = scriptExecutionContext(); |
| @@ -140,7 +150,7 @@ 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); |
| + context->removeTimeoutByIDIfTypeMatches(m_timerType, m_timeoutID); |
| action->execute(context); |