| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // second at most. | 59 // second at most. |
| 60 return 1.0; | 60 return 1.0; |
| 61 } | 61 } |
| 62 | 62 |
| 63 double DOMTimer::visiblePageAlignmentInterval() | 63 double DOMTimer::visiblePageAlignmentInterval() |
| 64 { | 64 { |
| 65 // Alignment does not apply to timers on visible pages. | 65 // Alignment does not apply to timers on visible pages. |
| 66 return 0; | 66 return 0; |
| 67 } | 67 } |
| 68 | 68 |
| 69 int DOMTimer::install(ExecutionContext* context, PassOwnPtr<ScheduledAction> act
ion, int timeout, bool singleShot) | 69 int DOMTimer::install(ExecutionContext* context, PassOwnPtrWillBeRawPtr<Schedule
dAction> action, int timeout, bool singleShot) |
| 70 { | 70 { |
| 71 int timeoutID = context->timers()->installNewTimeout(context, action, timeou
t, singleShot); | 71 int timeoutID = context->timers()->installNewTimeout(context, action, timeou
t, singleShot); |
| 72 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "TimerI
nstall", "data", InspectorTimerInstallEvent::data(context, timeoutID, timeout, s
ingleShot)); | 72 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "TimerI
nstall", "data", InspectorTimerInstallEvent::data(context, timeoutID, timeout, s
ingleShot)); |
| 73 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli
ne migrates to tracing. | 73 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli
ne migrates to tracing. |
| 74 InspectorInstrumentation::didInstallTimer(context, timeoutID, timeout, singl
eShot); | 74 InspectorInstrumentation::didInstallTimer(context, timeoutID, timeout, singl
eShot); |
| 75 WTF_LOG(Timers, "DOMTimer::install: timeoutID = %d, timeout = %d, singleShot
= %d", timeoutID, timeout, singleShot ? 1 : 0); | 75 WTF_LOG(Timers, "DOMTimer::install: timeoutID = %d, timeout = %d, singleShot
= %d", timeoutID, timeout, singleShot ? 1 : 0); |
| 76 return timeoutID; | 76 return timeoutID; |
| 77 } | 77 } |
| 78 | 78 |
| 79 void DOMTimer::removeByID(ExecutionContext* context, int timeoutID) | 79 void DOMTimer::removeByID(ExecutionContext* context, int timeoutID) |
| 80 { | 80 { |
| 81 WTF_LOG(Timers, "DOMTimer::removeByID: timeoutID = %d", timeoutID); | 81 WTF_LOG(Timers, "DOMTimer::removeByID: timeoutID = %d", timeoutID); |
| 82 context->timers()->removeTimeoutByID(timeoutID); | 82 context->timers()->removeTimeoutByID(timeoutID); |
| 83 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "TimerR
emove", "data", InspectorTimerRemoveEvent::data(context, timeoutID)); | 83 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "TimerR
emove", "data", InspectorTimerRemoveEvent::data(context, timeoutID)); |
| 84 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli
ne migrates to tracing. | 84 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli
ne migrates to tracing. |
| 85 InspectorInstrumentation::didRemoveTimer(context, timeoutID); | 85 InspectorInstrumentation::didRemoveTimer(context, timeoutID); |
| 86 } | 86 } |
| 87 | 87 |
| 88 DOMTimer::DOMTimer(ExecutionContext* context, PassOwnPtr<ScheduledAction> action
, int interval, bool singleShot, int timeoutID) | 88 DOMTimer::DOMTimer(ExecutionContext* context, PassOwnPtrWillBeRawPtr<ScheduledAc
tion> action, int interval, bool singleShot, int timeoutID) |
| 89 : SuspendableTimer(context) | 89 : SuspendableTimer(context) |
| 90 , m_timeoutID(timeoutID) | 90 , m_timeoutID(timeoutID) |
| 91 , m_nestingLevel(context->timers()->timerNestingLevel() + 1) | 91 , m_nestingLevel(context->timers()->timerNestingLevel() + 1) |
| 92 , m_action(action) | 92 , m_action(action) |
| 93 { | 93 { |
| 94 ASSERT(timeoutID > 0); | 94 ASSERT(timeoutID > 0); |
| 95 if (shouldForwardUserGesture(interval, m_nestingLevel)) | 95 if (shouldForwardUserGesture(interval, m_nestingLevel)) |
| 96 m_userGestureToken = UserGestureIndicator::currentToken(); | 96 m_userGestureToken = UserGestureIndicator::currentToken(); |
| 97 | 97 |
| 98 double intervalMilliseconds = std::max(oneMillisecond, interval * oneMillise
cond); | 98 double intervalMilliseconds = std::max(oneMillisecond, interval * oneMillise
cond); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 150 |
| 151 return; | 151 return; |
| 152 } | 152 } |
| 153 | 153 |
| 154 WTF_LOG(Timers, "DOMTimer::fired: m_timeoutID = %d, one-shot, m_action = %p"
, m_timeoutID, m_action.get()); | 154 WTF_LOG(Timers, "DOMTimer::fired: m_timeoutID = %d, one-shot, m_action = %p"
, m_timeoutID, m_action.get()); |
| 155 | 155 |
| 156 RefPtrWillBeRawPtr<DOMTimer> protect(this); | 156 RefPtrWillBeRawPtr<DOMTimer> protect(this); |
| 157 | 157 |
| 158 // Unregister the timer from ExecutionContext before executing the action | 158 // Unregister the timer from ExecutionContext before executing the action |
| 159 // for one-shot timers. | 159 // for one-shot timers. |
| 160 OwnPtr<ScheduledAction> action = m_action.release(); | 160 OwnPtrWillBeRawPtr<ScheduledAction> action = m_action.release(); |
| 161 context->timers()->removeTimeoutByID(m_timeoutID); | 161 context->timers()->removeTimeoutByID(m_timeoutID); |
| 162 | 162 |
| 163 action->execute(context); | 163 action->execute(context); |
| 164 | 164 |
| 165 InspectorInstrumentation::didFireTimer(cookie); | 165 InspectorInstrumentation::didFireTimer(cookie); |
| 166 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update
Counters", "data", InspectorUpdateCountersEvent::data()); | 166 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update
Counters", "data", InspectorUpdateCountersEvent::data()); |
| 167 | 167 |
| 168 // ExecutionContext might be already gone when we executed action->execute()
. | 168 // ExecutionContext might be already gone when we executed action->execute()
. |
| 169 if (executionContext()) | 169 if (executionContext()) |
| 170 executionContext()->timers()->setTimerNestingLevel(0); | 170 executionContext()->timers()->setTimerNestingLevel(0); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 return alignedTimeRoundedDown; | 210 return alignedTimeRoundedDown; |
| 211 | 211 |
| 212 return alignedTimeRoundedUp; | 212 return alignedTimeRoundedUp; |
| 213 } | 213 } |
| 214 | 214 |
| 215 return fireTime; | 215 return fireTime; |
| 216 } | 216 } |
| 217 | 217 |
| 218 void DOMTimer::trace(Visitor* visitor) | 218 void DOMTimer::trace(Visitor* visitor) |
| 219 { | 219 { |
| 220 visitor->trace(m_action); |
| 220 SuspendableTimer::trace(visitor); | 221 SuspendableTimer::trace(visitor); |
| 221 } | 222 } |
| 222 | 223 |
| 223 } // namespace blink | 224 } // namespace blink |
| OLD | NEW |