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

Side by Side Diff: third_party/WebKit/Source/core/frame/DOMTimer.cpp

Issue 2568103002: Revert of Eagerly dispose of ScheduledActions. (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ScriptSourceCode.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
114 111
115 void DOMTimer::stop() { 112 void DOMTimer::stop() {
116 InspectorInstrumentation::asyncTaskCanceled(getExecutionContext(), this); 113 InspectorInstrumentation::asyncTaskCanceled(getExecutionContext(), this);
117 m_userGestureToken = nullptr; 114 m_userGestureToken = nullptr;
118 // Need to release JS objects potentially protected by ScheduledAction 115 // Need to release JS objects potentially protected by ScheduledAction
119 // because they can form circular references back to the ExecutionContext 116 // because they can form circular references back to the ExecutionContext
120 // which will cause a memory leak. 117 // which will cause a memory leak.
121 if (m_action)
122 m_action->dispose();
123 m_action = nullptr; 118 m_action = nullptr;
124 SuspendableTimer::stop(); 119 SuspendableTimer::stop();
125 } 120 }
126 121
127 void DOMTimer::contextDestroyed() { 122 void DOMTimer::contextDestroyed() {
128 stop(); 123 stop();
129 } 124 }
130 125
131 void DOMTimer::fired() { 126 void DOMTimer::fired() {
132 ExecutionContext* context = getExecutionContext(); 127 ExecutionContext* context = getExecutionContext();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 InspectorUpdateCountersEvent::data()); 165 InspectorUpdateCountersEvent::data());
171 166
172 // ExecutionContext might be already gone when we executed action->execute(). 167 // ExecutionContext might be already gone when we executed action->execute().
173 ExecutionContext* executionContext = getExecutionContext(); 168 ExecutionContext* executionContext = getExecutionContext();
174 if (!executionContext) 169 if (!executionContext)
175 return; 170 return;
176 171
177 executionContext->timers()->setTimerNestingLevel(0); 172 executionContext->timers()->setTimerNestingLevel(0);
178 // Eagerly unregister as ExecutionContext observer. 173 // Eagerly unregister as ExecutionContext observer.
179 clearContext(); 174 clearContext();
180 // Eagerly clear out |action|'s resources.
181 action->dispose();
182 } 175 }
183 176
184 WebTaskRunner* DOMTimer::timerTaskRunner() const { 177 WebTaskRunner* DOMTimer::timerTaskRunner() const {
185 return getExecutionContext()->timers()->timerTaskRunner(); 178 return getExecutionContext()->timers()->timerTaskRunner();
186 } 179 }
187 180
188 DEFINE_TRACE(DOMTimer) { 181 DEFINE_TRACE(DOMTimer) {
189 visitor->trace(m_action); 182 visitor->trace(m_action);
190 SuspendableTimer::trace(visitor); 183 SuspendableTimer::trace(visitor);
191 } 184 }
192 185
193 } // namespace blink 186 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ScriptSourceCode.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698