| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 bool Time::ActivateHighResolutionTimer(bool activating) { | 196 bool Time::ActivateHighResolutionTimer(bool activating) { |
| 197 // We only do work on the transition from zero to one or one to zero so we | 197 // We only do work on the transition from zero to one or one to zero so we |
| 198 // can easily undo the effect (if necessary) when EnableHighResolutionTimer is | 198 // can easily undo the effect (if necessary) when EnableHighResolutionTimer is |
| 199 // called. | 199 // called. |
| 200 const uint32_t max = std::numeric_limits<uint32_t>::max(); | 200 const uint32_t max = std::numeric_limits<uint32_t>::max(); |
| 201 | 201 |
| 202 base::AutoLock lock(g_high_res_lock.Get()); | 202 base::AutoLock lock(g_high_res_lock.Get()); |
| 203 UINT period = g_high_res_timer_enabled ? kMinTimerIntervalHighResMs | 203 UINT period = g_high_res_timer_enabled ? kMinTimerIntervalHighResMs |
| 204 : kMinTimerIntervalLowResMs; | 204 : kMinTimerIntervalLowResMs; |
| 205 if (activating) { | 205 if (activating) { |
| 206 DCHECK(g_high_res_timer_count != max); | 206 DCHECK_NE(g_high_res_timer_count, max); |
| 207 ++g_high_res_timer_count; | 207 ++g_high_res_timer_count; |
| 208 if (g_high_res_timer_count == 1) | 208 if (g_high_res_timer_count == 1) |
| 209 timeBeginPeriod(period); | 209 timeBeginPeriod(period); |
| 210 } else { | 210 } else { |
| 211 DCHECK(g_high_res_timer_count != 0); | 211 DCHECK_NE(g_high_res_timer_count, 0u); |
| 212 --g_high_res_timer_count; | 212 --g_high_res_timer_count; |
| 213 if (g_high_res_timer_count == 0) | 213 if (g_high_res_timer_count == 0) |
| 214 timeEndPeriod(period); | 214 timeEndPeriod(period); |
| 215 } | 215 } |
| 216 return (period == kMinTimerIntervalHighResMs); | 216 return (period == kMinTimerIntervalHighResMs); |
| 217 } | 217 } |
| 218 | 218 |
| 219 // static | 219 // static |
| 220 bool Time::IsHighResolutionTimerInUse() { | 220 bool Time::IsHighResolutionTimerInUse() { |
| 221 base::AutoLock lock(g_high_res_lock.Get()); | 221 base::AutoLock lock(g_high_res_lock.Get()); |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 TimeTicks TimeTicks::FromQPCValue(LONGLONG qpc_value) { | 518 TimeTicks TimeTicks::FromQPCValue(LONGLONG qpc_value) { |
| 519 return TimeTicks() + QPCValueToTimeDelta(qpc_value); | 519 return TimeTicks() + QPCValueToTimeDelta(qpc_value); |
| 520 } | 520 } |
| 521 | 521 |
| 522 // TimeDelta ------------------------------------------------------------------ | 522 // TimeDelta ------------------------------------------------------------------ |
| 523 | 523 |
| 524 // static | 524 // static |
| 525 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { | 525 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { |
| 526 return QPCValueToTimeDelta(qpc_value); | 526 return QPCValueToTimeDelta(qpc_value); |
| 527 } | 527 } |
| OLD | NEW |