| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // second at most. | 58 // second at most. |
| 59 return 1.0; | 59 return 1.0; |
| 60 } | 60 } |
| 61 | 61 |
| 62 double DOMTimer::visiblePageAlignmentInterval() | 62 double DOMTimer::visiblePageAlignmentInterval() |
| 63 { | 63 { |
| 64 // Alignment does not apply to timers on visible pages. | 64 // Alignment does not apply to timers on visible pages. |
| 65 return 0; | 65 return 0; |
| 66 } | 66 } |
| 67 | 67 |
| 68 int DOMTimer::install(ExecutionContext* context, PassOwnPtr<ScheduledAction> act
ion, int timeout, bool singleShot) | 68 int DOMTimer::install(ExecutionContext* context, PassOwnPtrWillBeRawPtr<Schedule
dAction> action, int timeout, bool singleShot) |
| 69 { | 69 { |
| 70 int timeoutID = context->timers()->installNewTimeout(context, action, timeou
t, singleShot); | 70 int timeoutID = context->timers()->installNewTimeout(context, action, timeou
t, singleShot); |
| 71 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "TimerI
nstall", "data", InspectorTimerInstallEvent::data(context, timeoutID, timeout, s
ingleShot)); | 71 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "TimerI
nstall", "data", InspectorTimerInstallEvent::data(context, timeoutID, timeout, s
ingleShot)); |
| 72 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli
ne migrates to tracing. | 72 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli
ne migrates to tracing. |
| 73 InspectorInstrumentation::didInstallTimer(context, timeoutID, timeout, singl
eShot); | 73 InspectorInstrumentation::didInstallTimer(context, timeoutID, timeout, singl
eShot); |
| 74 return timeoutID; | 74 return timeoutID; |
| 75 } | 75 } |
| 76 | 76 |
| 77 void DOMTimer::removeByID(ExecutionContext* context, int timeoutID) | 77 void DOMTimer::removeByID(ExecutionContext* context, int timeoutID) |
| 78 { | 78 { |
| 79 context->timers()->removeTimeoutByID(timeoutID); | 79 context->timers()->removeTimeoutByID(timeoutID); |
| 80 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "TimerR
emove", "data", InspectorTimerRemoveEvent::data(context, timeoutID)); | 80 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "TimerR
emove", "data", InspectorTimerRemoveEvent::data(context, timeoutID)); |
| 81 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli
ne migrates to tracing. | 81 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli
ne migrates to tracing. |
| 82 InspectorInstrumentation::didRemoveTimer(context, timeoutID); | 82 InspectorInstrumentation::didRemoveTimer(context, timeoutID); |
| 83 } | 83 } |
| 84 | 84 |
| 85 DOMTimer::DOMTimer(ExecutionContext* context, PassOwnPtr<ScheduledAction> action
, int interval, bool singleShot, int timeoutID) | 85 DOMTimer::DOMTimer(ExecutionContext* context, PassOwnPtrWillBeRawPtr<ScheduledAc
tion> action, int interval, bool singleShot, int timeoutID) |
| 86 : SuspendableTimer(context) | 86 : SuspendableTimer(context) |
| 87 , m_timeoutID(timeoutID) | 87 , m_timeoutID(timeoutID) |
| 88 , m_nestingLevel(context->timers()->timerNestingLevel() + 1) | 88 , m_nestingLevel(context->timers()->timerNestingLevel() + 1) |
| 89 , m_action(action) | 89 , m_action(action) |
| 90 { | 90 { |
| 91 ASSERT(timeoutID > 0); | 91 ASSERT(timeoutID > 0); |
| 92 if (shouldForwardUserGesture(interval, m_nestingLevel)) | 92 if (shouldForwardUserGesture(interval, m_nestingLevel)) |
| 93 m_userGestureToken = UserGestureIndicator::currentToken(); | 93 m_userGestureToken = UserGestureIndicator::currentToken(); |
| 94 | 94 |
| 95 double intervalMilliseconds = std::max(oneMillisecond, interval * oneMillise
cond); | 95 double intervalMilliseconds = std::max(oneMillisecond, interval * oneMillise
cond); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 138 |
| 139 InspectorInstrumentation::didFireTimer(cookie); | 139 InspectorInstrumentation::didFireTimer(cookie); |
| 140 | 140 |
| 141 return; | 141 return; |
| 142 } | 142 } |
| 143 | 143 |
| 144 RefPtrWillBeRawPtr<DOMTimer> protect(this); | 144 RefPtrWillBeRawPtr<DOMTimer> protect(this); |
| 145 | 145 |
| 146 // Unregister the timer from ExecutionContext before executing the action | 146 // Unregister the timer from ExecutionContext before executing the action |
| 147 // for one-shot timers. | 147 // for one-shot timers. |
| 148 OwnPtr<ScheduledAction> action = m_action.release(); | 148 OwnPtrWillBeRawPtr<ScheduledAction> action = m_action.release(); |
| 149 context->timers()->removeTimeoutByID(m_timeoutID); | 149 context->timers()->removeTimeoutByID(m_timeoutID); |
| 150 | 150 |
| 151 action->execute(context); | 151 action->execute(context); |
| 152 | 152 |
| 153 InspectorInstrumentation::didFireTimer(cookie); | 153 InspectorInstrumentation::didFireTimer(cookie); |
| 154 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update
Counters", "data", InspectorUpdateCountersEvent::data()); | 154 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update
Counters", "data", InspectorUpdateCountersEvent::data()); |
| 155 | 155 |
| 156 // ExecutionContext might be already gone when we executed action->execute()
. | 156 // ExecutionContext might be already gone when we executed action->execute()
. |
| 157 if (executionContext()) | 157 if (executionContext()) |
| 158 executionContext()->timers()->setTimerNestingLevel(0); | 158 executionContext()->timers()->setTimerNestingLevel(0); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 return alignedTimeRoundedDown; | 198 return alignedTimeRoundedDown; |
| 199 | 199 |
| 200 return alignedTimeRoundedUp; | 200 return alignedTimeRoundedUp; |
| 201 } | 201 } |
| 202 | 202 |
| 203 return fireTime; | 203 return fireTime; |
| 204 } | 204 } |
| 205 | 205 |
| 206 void DOMTimer::trace(Visitor* visitor) | 206 void DOMTimer::trace(Visitor* visitor) |
| 207 { | 207 { |
| 208 visitor->trace(m_action); |
| 208 SuspendableTimer::trace(visitor); | 209 SuspendableTimer::trace(visitor); |
| 209 } | 210 } |
| 210 | 211 |
| 211 } // namespace blink | 212 } // namespace blink |
| OLD | NEW |