OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009 Google Inc. All rights reserved. | 3 * Copyright (C) 2009 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 TRACE_EVENT0("blink", "TimerBase::run"); | 126 TRACE_EVENT0("blink", "TimerBase::run"); |
127 #if DCHECK_IS_ON() | 127 #if DCHECK_IS_ON() |
128 DCHECK_EQ(m_thread, currentThread()) | 128 DCHECK_EQ(m_thread, currentThread()) |
129 << "Timer posted by " << m_location.function_name() << " " | 129 << "Timer posted by " << m_location.function_name() << " " |
130 << m_location.file_name() << " was run on a different thread"; | 130 << m_location.file_name() << " was run on a different thread"; |
131 #endif | 131 #endif |
132 TRACE_EVENT_SET_SAMPLING_STATE("blink", "BlinkInternal"); | 132 TRACE_EVENT_SET_SAMPLING_STATE("blink", "BlinkInternal"); |
133 | 133 |
134 if (m_repeatInterval) { | 134 if (m_repeatInterval) { |
135 double now = timerMonotonicallyIncreasingTime(); | 135 double now = timerMonotonicallyIncreasingTime(); |
136 // This computation should be drift free, and it will cope if we miss a beat
, | 136 // This computation should be drift free, and it will cope if we miss a |
137 // which can easily happen if the thread is busy. It will also cope if we g
et | 137 // beat, which can easily happen if the thread is busy. It will also cope |
138 // called slightly before m_unalignedNextFireTime, which can happen due to l
ack | 138 // if we get called slightly before m_unalignedNextFireTime, which can |
139 // of timer precision. | 139 // happen due to lack of timer precision. |
140 double intervalToNextFireTime = | 140 double intervalToNextFireTime = |
141 m_repeatInterval - fmod(now - m_nextFireTime, m_repeatInterval); | 141 m_repeatInterval - fmod(now - m_nextFireTime, m_repeatInterval); |
142 setNextFireTime(timerMonotonicallyIncreasingTime(), intervalToNextFireTime); | 142 setNextFireTime(timerMonotonicallyIncreasingTime(), intervalToNextFireTime); |
143 } else { | 143 } else { |
144 m_nextFireTime = 0; | 144 m_nextFireTime = 0; |
145 } | 145 } |
146 fired(); | 146 fired(); |
147 TRACE_EVENT_SET_SAMPLING_STATE("blink", "Sleeping"); | 147 TRACE_EVENT_SET_SAMPLING_STATE("blink", "Sleeping"); |
148 } | 148 } |
149 | 149 |
150 bool TimerBase::Comparator::operator()(const TimerBase* a, | 150 bool TimerBase::Comparator::operator()(const TimerBase* a, |
151 const TimerBase* b) const { | 151 const TimerBase* b) const { |
152 return a->m_nextFireTime < b->m_nextFireTime; | 152 return a->m_nextFireTime < b->m_nextFireTime; |
153 } | 153 } |
154 | 154 |
155 // static | 155 // static |
156 double TimerBase::timerMonotonicallyIncreasingTime() const { | 156 double TimerBase::timerMonotonicallyIncreasingTime() const { |
157 return timerTaskRunner()->monotonicallyIncreasingVirtualTimeSeconds(); | 157 return timerTaskRunner()->monotonicallyIncreasingVirtualTimeSeconds(); |
158 } | 158 } |
159 | 159 |
160 } // namespace blink | 160 } // namespace blink |
OLD | NEW |