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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 DOMTimer::DOMTimer(ExecutionContext* context, | 75 DOMTimer::DOMTimer(ExecutionContext* context, |
76 ScheduledAction* action, | 76 ScheduledAction* action, |
77 int interval, | 77 int interval, |
78 bool single_shot, | 78 bool single_shot, |
79 int timeout_id) | 79 int timeout_id) |
80 : SuspendableTimer(context, TaskType::kTimer), | 80 : SuspendableTimer(context, TaskType::kTimer), |
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 DCHECK_GT(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 double interval_milliseconds = | 91 double interval_milliseconds = |
92 std::max(kOneMillisecond, interval * kOneMillisecond); | 92 std::max(kOneMillisecond, interval * kOneMillisecond); |
93 if (interval_milliseconds < kMinimumInterval && | 93 if (interval_milliseconds < kMinimumInterval && |
94 nesting_level_ >= kMaxTimerNestingLevel) | 94 nesting_level_ >= kMaxTimerNestingLevel) |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 RefPtr<WebTaskRunner> DOMTimer::TimerTaskRunner() const { | 186 RefPtr<WebTaskRunner> DOMTimer::TimerTaskRunner() const { |
187 return GetExecutionContext()->Timers()->TimerTaskRunner(); | 187 return GetExecutionContext()->Timers()->TimerTaskRunner(); |
188 } | 188 } |
189 | 189 |
190 DEFINE_TRACE(DOMTimer) { | 190 DEFINE_TRACE(DOMTimer) { |
191 visitor->Trace(action_); | 191 visitor->Trace(action_); |
192 SuspendableTimer::Trace(visitor); | 192 SuspendableTimer::Trace(visitor); |
193 } | 193 } |
194 | 194 |
195 } // namespace blink | 195 } // namespace blink |
OLD | NEW |