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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 timeout_id_(timeout_id), | 81 timeout_id_(timeout_id), |
82 nesting_level_(context->Timers()->TimerNestingLevel() + 1), | 82 nesting_level_(context->Timers()->TimerNestingLevel() + 1), |
83 action_(action) { | 83 action_(action) { |
84 ASSERT(timeout_id > 0); | 84 ASSERT(timeout_id > 0); |
85 if (ShouldForwardUserGesture(interval, nesting_level_)) { | 85 if (ShouldForwardUserGesture(interval, nesting_level_)) { |
86 // Thread safe because shouldForwardUserGesture will only return true if | 86 // Thread safe because shouldForwardUserGesture will only return true if |
87 // execution is on the the main thread. | 87 // execution is on the the main thread. |
88 user_gesture_token_ = UserGestureIndicator::CurrentToken(); | 88 user_gesture_token_ = UserGestureIndicator::CurrentToken(); |
89 } | 89 } |
90 | 90 |
| 91 // TODO(delphick): Remove the single shot guard here so that this affects |
| 92 // setInterval as well. |
91 double interval_milliseconds = | 93 double interval_milliseconds = |
92 std::max(kOneMillisecond, interval * kOneMillisecond); | 94 std::max(single_shot ? 0.0 : kOneMillisecond, interval * kOneMillisecond); |
93 if (interval_milliseconds < kMinimumInterval && | 95 if (interval_milliseconds < kMinimumInterval && |
94 nesting_level_ >= kMaxTimerNestingLevel) | 96 nesting_level_ >= kMaxTimerNestingLevel) |
95 interval_milliseconds = kMinimumInterval; | 97 interval_milliseconds = kMinimumInterval; |
96 if (single_shot) | 98 if (single_shot) |
97 StartOneShot(interval_milliseconds, BLINK_FROM_HERE); | 99 StartOneShot(interval_milliseconds, BLINK_FROM_HERE); |
98 else | 100 else |
99 StartRepeating(interval_milliseconds, BLINK_FROM_HERE); | 101 StartRepeating(interval_milliseconds, BLINK_FROM_HERE); |
100 | 102 |
101 SuspendIfNeeded(); | 103 SuspendIfNeeded(); |
102 TRACE_EVENT_INSTANT1("devtools.timeline", "TimerInstall", | 104 TRACE_EVENT_INSTANT1("devtools.timeline", "TimerInstall", |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 RefPtr<WebTaskRunner> DOMTimer::TimerTaskRunner() const { | 188 RefPtr<WebTaskRunner> DOMTimer::TimerTaskRunner() const { |
187 return GetExecutionContext()->Timers()->TimerTaskRunner(); | 189 return GetExecutionContext()->Timers()->TimerTaskRunner(); |
188 } | 190 } |
189 | 191 |
190 DEFINE_TRACE(DOMTimer) { | 192 DEFINE_TRACE(DOMTimer) { |
191 visitor->Trace(action_); | 193 visitor->Trace(action_); |
192 SuspendableTimer::Trace(visitor); | 194 SuspendableTimer::Trace(visitor); |
193 } | 195 } |
194 | 196 |
195 } // namespace blink | 197 } // namespace blink |
OLD | NEW |