| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 std::max(oneMillisecond, interval * oneMillisecond); | 100 std::max(oneMillisecond, interval * oneMillisecond); |
| 101 if (intervalMilliseconds < minimumInterval && | 101 if (intervalMilliseconds < minimumInterval && |
| 102 m_nestingLevel >= maxTimerNestingLevel) | 102 m_nestingLevel >= maxTimerNestingLevel) |
| 103 intervalMilliseconds = minimumInterval; | 103 intervalMilliseconds = minimumInterval; |
| 104 if (singleShot) | 104 if (singleShot) |
| 105 startOneShot(intervalMilliseconds, BLINK_FROM_HERE); | 105 startOneShot(intervalMilliseconds, BLINK_FROM_HERE); |
| 106 else | 106 else |
| 107 startRepeating(intervalMilliseconds, BLINK_FROM_HERE); | 107 startRepeating(intervalMilliseconds, BLINK_FROM_HERE); |
| 108 } | 108 } |
| 109 | 109 |
| 110 DOMTimer::~DOMTimer() {} | 110 DOMTimer::~DOMTimer() { |
| 111 if (m_action) |
| 112 m_action->dispose(); |
| 113 } |
| 111 | 114 |
| 112 void DOMTimer::stop() { | 115 void DOMTimer::stop() { |
| 113 InspectorInstrumentation::asyncTaskCanceled(getExecutionContext(), this); | 116 InspectorInstrumentation::asyncTaskCanceled(getExecutionContext(), this); |
| 114 m_userGestureToken = nullptr; | 117 m_userGestureToken = nullptr; |
| 115 // Need to release JS objects potentially protected by ScheduledAction | 118 // Need to release JS objects potentially protected by ScheduledAction |
| 116 // because they can form circular references back to the ExecutionContext | 119 // because they can form circular references back to the ExecutionContext |
| 117 // which will cause a memory leak. | 120 // which will cause a memory leak. |
| 121 if (m_action) |
| 122 m_action->dispose(); |
| 118 m_action = nullptr; | 123 m_action = nullptr; |
| 119 SuspendableTimer::stop(); | 124 SuspendableTimer::stop(); |
| 120 } | 125 } |
| 121 | 126 |
| 122 void DOMTimer::contextDestroyed() { | 127 void DOMTimer::contextDestroyed() { |
| 123 stop(); | 128 stop(); |
| 124 } | 129 } |
| 125 | 130 |
| 126 void DOMTimer::fired() { | 131 void DOMTimer::fired() { |
| 127 ExecutionContext* context = getExecutionContext(); | 132 ExecutionContext* context = getExecutionContext(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 InspectorUpdateCountersEvent::data()); | 170 InspectorUpdateCountersEvent::data()); |
| 166 | 171 |
| 167 // ExecutionContext might be already gone when we executed action->execute(). | 172 // ExecutionContext might be already gone when we executed action->execute(). |
| 168 ExecutionContext* executionContext = getExecutionContext(); | 173 ExecutionContext* executionContext = getExecutionContext(); |
| 169 if (!executionContext) | 174 if (!executionContext) |
| 170 return; | 175 return; |
| 171 | 176 |
| 172 executionContext->timers()->setTimerNestingLevel(0); | 177 executionContext->timers()->setTimerNestingLevel(0); |
| 173 // Eagerly unregister as ExecutionContext observer. | 178 // Eagerly unregister as ExecutionContext observer. |
| 174 clearContext(); | 179 clearContext(); |
| 180 // Eagerly clear out |action|'s resources. |
| 181 action->dispose(); |
| 175 } | 182 } |
| 176 | 183 |
| 177 WebTaskRunner* DOMTimer::timerTaskRunner() const { | 184 WebTaskRunner* DOMTimer::timerTaskRunner() const { |
| 178 return getExecutionContext()->timers()->timerTaskRunner(); | 185 return getExecutionContext()->timers()->timerTaskRunner(); |
| 179 } | 186 } |
| 180 | 187 |
| 181 DEFINE_TRACE(DOMTimer) { | 188 DEFINE_TRACE(DOMTimer) { |
| 182 visitor->trace(m_action); | 189 visitor->trace(m_action); |
| 183 SuspendableTimer::trace(visitor); | 190 SuspendableTimer::trace(visitor); |
| 184 } | 191 } |
| 185 | 192 |
| 186 } // namespace blink | 193 } // namespace blink |
| OLD | NEW |