| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_originWorldId = DOMWrapperWorld::current(v8::Isolate::GetCurrent()).origin
WorldId(); |
| 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 Loading... |
| 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 parent world id gets propagated to the action and is reset aft
erwards. |
| 112 DOMWrapperWorld::ParentWorldIdPusher worldIdPusher(ScriptState::forMainWorld
(toDocument(context)->frame())->world(), m_originWorldId); |
| 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 Loading... |
| 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 |
| OLD | NEW |