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. | |
93 double interval_milliseconds = | 91 double interval_milliseconds = |
94 std::max(single_shot ? 0.0 : kOneMillisecond, interval * kOneMillisecond); | 92 std::max(kOneMillisecond, interval * kOneMillisecond); |
95 if (interval_milliseconds < kMinimumInterval && | 93 if (interval_milliseconds < kMinimumInterval && |
96 nesting_level_ >= kMaxTimerNestingLevel) | 94 nesting_level_ >= kMaxTimerNestingLevel) |
97 interval_milliseconds = kMinimumInterval; | 95 interval_milliseconds = kMinimumInterval; |
98 if (single_shot) | 96 if (single_shot) |
99 StartOneShot(interval_milliseconds, BLINK_FROM_HERE); | 97 StartOneShot(interval_milliseconds, BLINK_FROM_HERE); |
100 else | 98 else |
101 StartRepeating(interval_milliseconds, BLINK_FROM_HERE); | 99 StartRepeating(interval_milliseconds, BLINK_FROM_HERE); |
102 | 100 |
103 SuspendIfNeeded(); | 101 SuspendIfNeeded(); |
104 TRACE_EVENT_INSTANT1("devtools.timeline", "TimerInstall", | 102 TRACE_EVENT_INSTANT1("devtools.timeline", "TimerInstall", |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 RefPtr<WebTaskRunner> DOMTimer::TimerTaskRunner() const { | 186 RefPtr<WebTaskRunner> DOMTimer::TimerTaskRunner() const { |
189 return GetExecutionContext()->Timers()->TimerTaskRunner(); | 187 return GetExecutionContext()->Timers()->TimerTaskRunner(); |
190 } | 188 } |
191 | 189 |
192 DEFINE_TRACE(DOMTimer) { | 190 DEFINE_TRACE(DOMTimer) { |
193 visitor->Trace(action_); | 191 visitor->Trace(action_); |
194 SuspendableTimer::Trace(visitor); | 192 SuspendableTimer::Trace(visitor); |
195 } | 193 } |
196 | 194 |
197 } // namespace blink | 195 } // namespace blink |
OLD | NEW |