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 1615523002: Transitively keep track of an isolated world's children scripts and worlds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use a static world stack instead of a per-world private field Created 4 years, 10 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 unified diff | Download patch
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 TRACE_EVENT_INSTANT1("devtools.timeline", "TimerRemove", TRACE_EVENT_SCOPE_T HREAD, "data", InspectorTimerRemoveEvent::data(context, timeoutID)); 65 TRACE_EVENT_INSTANT1("devtools.timeline", "TimerRemove", TRACE_EVENT_SCOPE_T HREAD, "data", InspectorTimerRemoveEvent::data(context, timeoutID));
66 InspectorInstrumentation::didRemoveTimer(context, timeoutID); 66 InspectorInstrumentation::didRemoveTimer(context, timeoutID);
67 } 67 }
68 68
69 DOMTimer::DOMTimer(ExecutionContext* context, PassOwnPtrWillBeRawPtr<ScheduledAc tion> action, int interval, bool singleShot, int timeoutID) 69 DOMTimer::DOMTimer(ExecutionContext* context, PassOwnPtrWillBeRawPtr<ScheduledAc tion> action, int interval, bool singleShot, int timeoutID)
70 : SuspendableTimer(context) 70 : SuspendableTimer(context)
71 , m_timeoutID(timeoutID) 71 , m_timeoutID(timeoutID)
72 , m_nestingLevel(context->timers()->timerNestingLevel() + 1) 72 , m_nestingLevel(context->timers()->timerNestingLevel() + 1)
73 , m_action(action) 73 , m_action(action)
74 { 74 {
75 // Store the creating worldId, as the timer is fired in the main world.
76 ASSERT(v8::Isolate::GetCurrent()->InContext());
77 m_originWorld = PassRefPtr<DOMWrapperWorld>(DOMWrapperWorld::current(v8::Iso late::GetCurrent()).originWorld());
78
75 ASSERT(timeoutID > 0); 79 ASSERT(timeoutID > 0);
76 if (shouldForwardUserGesture(interval, m_nestingLevel)) 80 if (shouldForwardUserGesture(interval, m_nestingLevel))
77 m_userGestureToken = UserGestureIndicator::currentToken(); 81 m_userGestureToken = UserGestureIndicator::currentToken();
78 82
79 double intervalMilliseconds = std::max(oneMillisecond, interval * oneMillise cond); 83 double intervalMilliseconds = std::max(oneMillisecond, interval * oneMillise cond);
80 if (intervalMilliseconds < minimumInterval && m_nestingLevel >= maxTimerNest ingLevel) 84 if (intervalMilliseconds < minimumInterval && m_nestingLevel >= maxTimerNest ingLevel)
81 intervalMilliseconds = minimumInterval; 85 intervalMilliseconds = minimumInterval;
82 if (singleShot) 86 if (singleShot)
83 startOneShot(intervalMilliseconds, BLINK_FROM_HERE); 87 startOneShot(intervalMilliseconds, BLINK_FROM_HERE);
84 else 88 else
(...skipping 12 matching lines...) Expand all
97 } 101 }
98 102
99 void DOMTimer::fired() 103 void DOMTimer::fired()
100 { 104 {
101 ExecutionContext* context = executionContext(); 105 ExecutionContext* context = executionContext();
102 ASSERT(context); 106 ASSERT(context);
103 context->timers()->setTimerNestingLevel(m_nestingLevel); 107 context->timers()->setTimerNestingLevel(m_nestingLevel);
104 ASSERT(!context->activeDOMObjectsAreSuspended()); 108 ASSERT(!context->activeDOMObjectsAreSuspended());
105 // Only the first execution of a multi-shot timer should get an affirmative user gesture indicator. 109 // Only the first execution of a multi-shot timer should get an affirmative user gesture indicator.
106 UserGestureIndicator gestureIndicator(m_userGestureToken.release()); 110 UserGestureIndicator gestureIndicator(m_userGestureToken.release());
111 // Ensure the origin world is propagated to the action and is reset afterwar ds.
112 DOMWrapperWorld::OriginWorldScope worldScope(m_originWorld);
107 113
108 TRACE_EVENT1("devtools.timeline", "TimerFire", "data", InspectorTimerFireEve nt::data(context, m_timeoutID)); 114 TRACE_EVENT1("devtools.timeline", "TimerFire", "data", InspectorTimerFireEve nt::data(context, m_timeoutID));
109 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireTi mer(context, m_timeoutID); 115 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireTi mer(context, m_timeoutID);
110 116
111 // Simple case for non-one-shot timers. 117 // Simple case for non-one-shot timers.
112 if (isActive()) { 118 if (isActive()) {
113 if (repeatInterval() && repeatInterval() < minimumInterval) { 119 if (repeatInterval() && repeatInterval() < minimumInterval) {
114 m_nestingLevel++; 120 m_nestingLevel++;
115 if (m_nestingLevel >= maxTimerNestingLevel) 121 if (m_nestingLevel >= maxTimerNestingLevel)
116 augmentRepeatInterval(minimumInterval - repeatInterval()); 122 augmentRepeatInterval(minimumInterval - repeatInterval());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 return executionContext()->timers()->timerTaskRunner(); 161 return executionContext()->timers()->timerTaskRunner();
156 } 162 }
157 163
158 DEFINE_TRACE(DOMTimer) 164 DEFINE_TRACE(DOMTimer)
159 { 165 {
160 visitor->trace(m_action); 166 visitor->trace(m_action);
161 SuspendableTimer::trace(visitor); 167 SuspendableTimer::trace(visitor);
162 } 168 }
163 169
164 } // namespace blink 170 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/DOMTimer.h ('k') | third_party/WebKit/Source/core/loader/NavigationScheduler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698