| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // timer interrupt frequency on Windows. It controls how precise timers are | 90 // timer interrupt frequency on Windows. It controls how precise timers are |
| 91 // but also has a big impact on battery life. | 91 // but also has a big impact on battery life. |
| 92 const int kMinTimerIntervalHighResMs = 1; | 92 const int kMinTimerIntervalHighResMs = 1; |
| 93 const int kMinTimerIntervalLowResMs = 4; | 93 const int kMinTimerIntervalLowResMs = 4; |
| 94 // Track if kMinTimerIntervalHighResMs or kMinTimerIntervalLowResMs is active. | 94 // Track if kMinTimerIntervalHighResMs or kMinTimerIntervalLowResMs is active. |
| 95 bool g_high_res_timer_enabled = false; | 95 bool g_high_res_timer_enabled = false; |
| 96 // How many times the high resolution timer has been called. | 96 // How many times the high resolution timer has been called. |
| 97 uint32_t g_high_res_timer_count = 0; | 97 uint32_t g_high_res_timer_count = 0; |
| 98 // The lock to control access to the above two variables. | 98 // The lock to control access to the above two variables. |
| 99 base::Lock* GetHighResLock() { | 99 base::Lock* GetHighResLock() { |
| 100 static auto lock = new base::Lock(); | 100 static auto* lock = new base::Lock(); |
| 101 return lock; | 101 return lock; |
| 102 } | 102 } |
| 103 | 103 |
| 104 // Returns the current value of the performance counter. | 104 // Returns the current value of the performance counter. |
| 105 uint64_t QPCNowRaw() { | 105 uint64_t QPCNowRaw() { |
| 106 LARGE_INTEGER perf_counter_now = {}; | 106 LARGE_INTEGER perf_counter_now = {}; |
| 107 // According to the MSDN documentation for QueryPerformanceCounter(), this | 107 // According to the MSDN documentation for QueryPerformanceCounter(), this |
| 108 // will never fail on systems that run XP or later. | 108 // will never fail on systems that run XP or later. |
| 109 // https://msdn.microsoft.com/library/windows/desktop/ms644904.aspx | 109 // https://msdn.microsoft.com/library/windows/desktop/ms644904.aspx |
| 110 ::QueryPerformanceCounter(&perf_counter_now); | 110 ::QueryPerformanceCounter(&perf_counter_now); |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 TimeTicks TimeTicks::FromQPCValue(LONGLONG qpc_value) { | 675 TimeTicks TimeTicks::FromQPCValue(LONGLONG qpc_value) { |
| 676 return TimeTicks() + QPCValueToTimeDelta(qpc_value); | 676 return TimeTicks() + QPCValueToTimeDelta(qpc_value); |
| 677 } | 677 } |
| 678 | 678 |
| 679 // TimeDelta ------------------------------------------------------------------ | 679 // TimeDelta ------------------------------------------------------------------ |
| 680 | 680 |
| 681 // static | 681 // static |
| 682 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { | 682 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { |
| 683 return QPCValueToTimeDelta(qpc_value); | 683 return QPCValueToTimeDelta(qpc_value); |
| 684 } | 684 } |
| OLD | NEW |