| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 // Windows Timer Primer | 6 // Windows Timer Primer |
| 7 // | 7 // |
| 8 // A good article: http://www.ddj.com/windows/184416651 | 8 // A good article: http://www.ddj.com/windows/184416651 |
| 9 // A good mozilla bug: http://bugzilla.mozilla.org/show_bug.cgi?id=363258 | 9 // A good mozilla bug: http://bugzilla.mozilla.org/show_bug.cgi?id=363258 |
| 10 // | 10 // |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 182 |
| 183 // Calculate the time elapsed since we started our timer | 183 // Calculate the time elapsed since we started our timer |
| 184 TimeDelta elapsed = ticks - initial_ticks; | 184 TimeDelta elapsed = ticks - initial_ticks; |
| 185 | 185 |
| 186 // Check if enough time has elapsed that we need to resync the clock. | 186 // Check if enough time has elapsed that we need to resync the clock. |
| 187 if (elapsed.InMilliseconds() > kMaxMillisecondsToAvoidDrift) { | 187 if (elapsed.InMilliseconds() > kMaxMillisecondsToAvoidDrift) { |
| 188 InitializeClock(); | 188 InitializeClock(); |
| 189 continue; | 189 continue; |
| 190 } | 190 } |
| 191 | 191 |
| 192 return Time(elapsed + initial_time); | 192 return Time(elapsed + Time(initial_time)); |
| 193 } | 193 } |
| 194 } | 194 } |
| 195 | 195 |
| 196 // static | 196 // static |
| 197 Time Time::NowFromSystemTime() { | 197 Time Time::NowFromSystemTime() { |
| 198 // Force resync. | 198 // Force resync. |
| 199 InitializeClock(); | 199 InitializeClock(); |
| 200 return Time(initial_time); | 200 return Time(initial_time); |
| 201 } | 201 } |
| 202 | 202 |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 | 440 |
| 441 // static | 441 // static |
| 442 TimeTicks TimeTicks::Now() { | 442 TimeTicks TimeTicks::Now() { |
| 443 return TimeTicks() + Singleton<NowSingleton>::get()->Now(); | 443 return TimeTicks() + Singleton<NowSingleton>::get()->Now(); |
| 444 } | 444 } |
| 445 | 445 |
| 446 // static | 446 // static |
| 447 TimeTicks TimeTicks::HighResNow() { | 447 TimeTicks TimeTicks::HighResNow() { |
| 448 return TimeTicks() + Singleton<HighResNowSingleton>::get()->Now(); | 448 return TimeTicks() + Singleton<HighResNowSingleton>::get()->Now(); |
| 449 } | 449 } |
| OLD | NEW |