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

Unified Diff: third_party/WebKit/Source/core/frame/DOMTimer.cpp

Issue 1972663002: Eagerly remove disposed DOMTimers as observers upon completion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 7 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 | « no previous file | third_party/WebKit/Source/core/frame/DOMTimerCoordinator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/frame/DOMTimer.cpp
diff --git a/third_party/WebKit/Source/core/frame/DOMTimer.cpp b/third_party/WebKit/Source/core/frame/DOMTimer.cpp
index 4f189211b3c8082861f080ad304db4440fc68427..e92c3d27fa9091f5feaf6476c5cecf5c649d8c7d 100644
--- a/third_party/WebKit/Source/core/frame/DOMTimer.cpp
+++ b/third_party/WebKit/Source/core/frame/DOMTimer.cpp
@@ -61,9 +61,12 @@ int DOMTimer::install(ExecutionContext* context, ScheduledAction* action, int ti
void DOMTimer::removeByID(ExecutionContext* context, int timeoutID)
{
- context->timers()->removeTimeoutByID(timeoutID);
+ DOMTimer* timer = context->timers()->removeTimeoutByID(timeoutID);
TRACE_EVENT_INSTANT1("devtools.timeline", "TimerRemove", TRACE_EVENT_SCOPE_THREAD, "data", InspectorTimerRemoveEvent::data(context, timeoutID));
InspectorInstrumentation::NativeBreakpoint nativeBreakpoint(context, "clearTimer", true);
+ // Eagerly unregister as ExecutionContext observer.
+ if (timer)
+ timer->clearContext();
}
DOMTimer::DOMTimer(ExecutionContext* context, ScheduledAction* action, int interval, bool singleShot, int timeoutID)
@@ -134,8 +137,13 @@ void DOMTimer::fired()
TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data());
// ExecutionContext might be already gone when we executed action->execute().
- if (getExecutionContext())
- getExecutionContext()->timers()->setTimerNestingLevel(0);
+ ExecutionContext* executionContext = getExecutionContext();
+ if (!executionContext)
+ return;
+
+ executionContext->timers()->setTimerNestingLevel(0);
+ // Eagerly unregister as ExecutionContext observer.
+ clearContext();
}
void DOMTimer::stop()
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/DOMTimerCoordinator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698