| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // the smallest possible interval timer. | 44 // the smallest possible interval timer. |
| 45 static const double minimumInterval = 0.004; | 45 static const double minimumInterval = 0.004; |
| 46 | 46 |
| 47 static inline bool shouldForwardUserGesture(int interval, int nestingLevel) | 47 static inline bool shouldForwardUserGesture(int interval, int nestingLevel) |
| 48 { | 48 { |
| 49 return UserGestureIndicator::processingUserGesture() | 49 return UserGestureIndicator::processingUserGesture() |
| 50 && interval <= maxIntervalForUserGestureForwarding | 50 && interval <= maxIntervalForUserGestureForwarding |
| 51 && nestingLevel == 1; // Gestures should not be forwarded to nested time
rs. | 51 && nestingLevel == 1; // Gestures should not be forwarded to nested time
rs. |
| 52 } | 52 } |
| 53 | 53 |
| 54 int DOMTimer::install(ExecutionContext* context, PassOwnPtrWillBeRawPtr<Schedule
dAction> action, int timeout, bool singleShot) | 54 int DOMTimer::install(ExecutionContext* context, RawPtr<ScheduledAction> action,
int timeout, bool singleShot) |
| 55 { | 55 { |
| 56 int timeoutID = context->timers()->installNewTimeout(context, action, timeou
t, singleShot); | 56 int timeoutID = context->timers()->installNewTimeout(context, action, timeou
t, singleShot); |
| 57 TRACE_EVENT_INSTANT1("devtools.timeline", "TimerInstall", TRACE_EVENT_SCOPE_
THREAD, "data", InspectorTimerInstallEvent::data(context, timeoutID, timeout, si
ngleShot)); | 57 TRACE_EVENT_INSTANT1("devtools.timeline", "TimerInstall", TRACE_EVENT_SCOPE_
THREAD, "data", InspectorTimerInstallEvent::data(context, timeoutID, timeout, si
ngleShot)); |
| 58 InspectorInstrumentation::didInstallTimer(context, timeoutID, timeout, singl
eShot); | 58 InspectorInstrumentation::didInstallTimer(context, timeoutID, timeout, singl
eShot); |
| 59 return timeoutID; | 59 return timeoutID; |
| 60 } | 60 } |
| 61 | 61 |
| 62 void DOMTimer::removeByID(ExecutionContext* context, int timeoutID) | 62 void DOMTimer::removeByID(ExecutionContext* context, int timeoutID) |
| 63 { | 63 { |
| 64 context->timers()->removeTimeoutByID(timeoutID); | 64 context->timers()->removeTimeoutByID(timeoutID); |
| 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, RawPtr<ScheduledAction> action, in
t 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 ASSERT(timeoutID > 0); | 75 ASSERT(timeoutID > 0); |
| 76 if (shouldForwardUserGesture(interval, m_nestingLevel)) | 76 if (shouldForwardUserGesture(interval, m_nestingLevel)) |
| 77 m_userGestureToken = UserGestureIndicator::currentToken(); | 77 m_userGestureToken = UserGestureIndicator::currentToken(); |
| 78 | 78 |
| 79 double intervalMilliseconds = std::max(oneMillisecond, interval * oneMillise
cond); | 79 double intervalMilliseconds = std::max(oneMillisecond, interval * oneMillise
cond); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 } | 117 } |
| 118 | 118 |
| 119 // No access to member variables after this point, it can delete the tim
er. | 119 // No access to member variables after this point, it can delete the tim
er. |
| 120 m_action->execute(context); | 120 m_action->execute(context); |
| 121 | 121 |
| 122 InspectorInstrumentation::didFireTimer(cookie); | 122 InspectorInstrumentation::didFireTimer(cookie); |
| 123 | 123 |
| 124 return; | 124 return; |
| 125 } | 125 } |
| 126 | 126 |
| 127 RefPtrWillBeRawPtr<DOMTimer> protect(this); | 127 RawPtr<DOMTimer> protect(this); |
| 128 | 128 |
| 129 // Unregister the timer from ExecutionContext before executing the action | 129 // Unregister the timer from ExecutionContext before executing the action |
| 130 // for one-shot timers. | 130 // for one-shot timers. |
| 131 OwnPtrWillBeRawPtr<ScheduledAction> action = m_action.release(); | 131 RawPtr<ScheduledAction> action = m_action.release(); |
| 132 context->timers()->removeTimeoutByID(m_timeoutID); | 132 context->timers()->removeTimeoutByID(m_timeoutID); |
| 133 | 133 |
| 134 action->execute(context); | 134 action->execute(context); |
| 135 | 135 |
| 136 InspectorInstrumentation::didFireTimer(cookie); | 136 InspectorInstrumentation::didFireTimer(cookie); |
| 137 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update
Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data(
)); | 137 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update
Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data(
)); |
| 138 | 138 |
| 139 // ExecutionContext might be already gone when we executed action->execute()
. | 139 // ExecutionContext might be already gone when we executed action->execute()
. |
| 140 if (getExecutionContext()) | 140 if (getExecutionContext()) |
| 141 getExecutionContext()->timers()->setTimerNestingLevel(0); | 141 getExecutionContext()->timers()->setTimerNestingLevel(0); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 155 return getExecutionContext()->timers()->timerTaskRunner(); | 155 return getExecutionContext()->timers()->timerTaskRunner(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 DEFINE_TRACE(DOMTimer) | 158 DEFINE_TRACE(DOMTimer) |
| 159 { | 159 { |
| 160 visitor->trace(m_action); | 160 visitor->trace(m_action); |
| 161 SuspendableTimer::trace(visitor); | 161 SuspendableTimer::trace(visitor); |
| 162 } | 162 } |
| 163 | 163 |
| 164 } // namespace blink | 164 } // namespace blink |
| OLD | NEW |