| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 std::max(oneMillisecond, interval * oneMillisecond); | 97 std::max(oneMillisecond, interval * oneMillisecond); |
| 98 if (intervalMilliseconds < minimumInterval && | 98 if (intervalMilliseconds < minimumInterval && |
| 99 m_nestingLevel >= maxTimerNestingLevel) | 99 m_nestingLevel >= maxTimerNestingLevel) |
| 100 intervalMilliseconds = minimumInterval; | 100 intervalMilliseconds = minimumInterval; |
| 101 if (singleShot) | 101 if (singleShot) |
| 102 startOneShot(intervalMilliseconds, BLINK_FROM_HERE); | 102 startOneShot(intervalMilliseconds, BLINK_FROM_HERE); |
| 103 else | 103 else |
| 104 startRepeating(intervalMilliseconds, BLINK_FROM_HERE); | 104 startRepeating(intervalMilliseconds, BLINK_FROM_HERE); |
| 105 | 105 |
| 106 suspendIfNeeded(); | 106 suspendIfNeeded(); |
| 107 InspectorInstrumentation::asyncTaskScheduledBreakable( | 107 probe::asyncTaskScheduledBreakable( |
| 108 context, singleShot ? "setTimeout" : "setInterval", this, !singleShot); | 108 context, singleShot ? "setTimeout" : "setInterval", this, !singleShot); |
| 109 } | 109 } |
| 110 | 110 |
| 111 DOMTimer::~DOMTimer() { | 111 DOMTimer::~DOMTimer() { |
| 112 if (m_action) | 112 if (m_action) |
| 113 m_action->dispose(); | 113 m_action->dispose(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void DOMTimer::stop() { | 116 void DOMTimer::stop() { |
| 117 InspectorInstrumentation::asyncTaskCanceledBreakable( | 117 probe::asyncTaskCanceledBreakable( |
| 118 getExecutionContext(), | 118 getExecutionContext(), |
| 119 repeatInterval() ? "clearInterval" : "clearTimeout", this); | 119 repeatInterval() ? "clearInterval" : "clearTimeout", this); |
| 120 | 120 |
| 121 m_userGestureToken = nullptr; | 121 m_userGestureToken = nullptr; |
| 122 // Need to release JS objects potentially protected by ScheduledAction | 122 // Need to release JS objects potentially protected by ScheduledAction |
| 123 // because they can form circular references back to the ExecutionContext | 123 // because they can form circular references back to the ExecutionContext |
| 124 // which will cause a memory leak. | 124 // which will cause a memory leak. |
| 125 if (m_action) | 125 if (m_action) |
| 126 m_action->dispose(); | 126 m_action->dispose(); |
| 127 m_action = nullptr; | 127 m_action = nullptr; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 138 context->timers()->setTimerNestingLevel(m_nestingLevel); | 138 context->timers()->setTimerNestingLevel(m_nestingLevel); |
| 139 DCHECK(!context->isContextSuspended()); | 139 DCHECK(!context->isContextSuspended()); |
| 140 // Only the first execution of a multi-shot timer should get an affirmative | 140 // Only the first execution of a multi-shot timer should get an affirmative |
| 141 // user gesture indicator. | 141 // user gesture indicator. |
| 142 UserGestureIndicator gestureIndicator(std::move(m_userGestureToken)); | 142 UserGestureIndicator gestureIndicator(std::move(m_userGestureToken)); |
| 143 | 143 |
| 144 TRACE_EVENT1("devtools.timeline", "TimerFire", "data", | 144 TRACE_EVENT1("devtools.timeline", "TimerFire", "data", |
| 145 InspectorTimerFireEvent::data(context, m_timeoutID)); | 145 InspectorTimerFireEvent::data(context, m_timeoutID)); |
| 146 PerformanceMonitor::HandlerCall handlerCall( | 146 PerformanceMonitor::HandlerCall handlerCall( |
| 147 context, repeatInterval() ? "setInterval" : "setTimeout", true); | 147 context, repeatInterval() ? "setInterval" : "setTimeout", true); |
| 148 InspectorInstrumentation::AsyncTask asyncTask(context, this, "timerFired"); | 148 probe::AsyncTask asyncTask(context, this, "timerFired"); |
| 149 | 149 |
| 150 // Simple case for non-one-shot timers. | 150 // Simple case for non-one-shot timers. |
| 151 if (isActive()) { | 151 if (isActive()) { |
| 152 if (repeatInterval() && repeatInterval() < minimumInterval) { | 152 if (repeatInterval() && repeatInterval() < minimumInterval) { |
| 153 m_nestingLevel++; | 153 m_nestingLevel++; |
| 154 if (m_nestingLevel >= maxTimerNestingLevel) | 154 if (m_nestingLevel >= maxTimerNestingLevel) |
| 155 augmentRepeatInterval(minimumInterval - repeatInterval()); | 155 augmentRepeatInterval(minimumInterval - repeatInterval()); |
| 156 } | 156 } |
| 157 | 157 |
| 158 // No access to member variables after this point, it can delete the timer. | 158 // No access to member variables after this point, it can delete the timer. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 189 RefPtr<WebTaskRunner> DOMTimer::timerTaskRunner() const { | 189 RefPtr<WebTaskRunner> DOMTimer::timerTaskRunner() const { |
| 190 return getExecutionContext()->timers()->timerTaskRunner(); | 190 return getExecutionContext()->timers()->timerTaskRunner(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 DEFINE_TRACE(DOMTimer) { | 193 DEFINE_TRACE(DOMTimer) { |
| 194 visitor->trace(m_action); | 194 visitor->trace(m_action); |
| 195 SuspendableTimer::trace(visitor); | 195 SuspendableTimer::trace(visitor); |
| 196 } | 196 } |
| 197 | 197 |
| 198 } // namespace blink | 198 } // namespace blink |
| OLD | NEW |