Chromium Code Reviews| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 | 124 |
| 125 // Time ----------------------------------------------------------------------- | 125 // Time ----------------------------------------------------------------------- |
| 126 | 126 |
| 127 // The internal representation of Time uses FILETIME, whose epoch is 1601-01-01 | 127 // The internal representation of Time uses FILETIME, whose epoch is 1601-01-01 |
| 128 // 00:00:00 UTC. ((1970-1601)*365+89)*24*60*60*1000*1000, where 89 is the | 128 // 00:00:00 UTC. ((1970-1601)*365+89)*24*60*60*1000*1000, where 89 is the |
| 129 // number of leap year days between 1601 and 1970: (1970-1601)/4 excluding | 129 // number of leap year days between 1601 and 1970: (1970-1601)/4 excluding |
| 130 // 1700, 1800, and 1900. | 130 // 1700, 1800, and 1900. |
| 131 // static | 131 // static |
| 132 const int64 Time::kTimeTToMicrosecondsOffset = INT64_C(11644473600000000); | 132 const int64 Time::kTimeTToMicrosecondsOffset = INT64_C(11644473600000000); |
| 133 | 133 |
| 134 // VS 2015 and above allow these definitions and in this case require them | |
|
danakj
2015/10/30 20:23:30
nit: period
brucedawson
2015/10/30 20:36:59
Done.
| |
| 135 #if _MSC_VER >= 1900 | |
| 136 const int64 base::Time::kQPCOverflowThreshold; | |
|
danakj
2015/10/30 20:23:30
Other statics that have storage seem to be initial
| |
| 137 #endif | |
| 138 | |
| 134 // static | 139 // static |
| 135 Time Time::Now() { | 140 Time Time::Now() { |
| 136 if (initial_time == 0) | 141 if (initial_time == 0) |
| 137 InitializeClock(); | 142 InitializeClock(); |
| 138 | 143 |
| 139 // We implement time using the high-resolution timers so that we can get | 144 // We implement time using the high-resolution timers so that we can get |
| 140 // timeouts which are smaller than 10-15ms. If we just used | 145 // timeouts which are smaller than 10-15ms. If we just used |
| 141 // CurrentWallclockMicroseconds(), we'd have the less-granular timer. | 146 // CurrentWallclockMicroseconds(), we'd have the less-granular timer. |
| 142 // | 147 // |
| 143 // To make this work, we initialize the clock (initial_time) and the | 148 // To make this work, we initialize the clock (initial_time) and the |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 621 TimeTicks TimeTicks::FromQPCValue(LONGLONG qpc_value) { | 626 TimeTicks TimeTicks::FromQPCValue(LONGLONG qpc_value) { |
| 622 return TimeTicks() + QPCValueToTimeDelta(qpc_value); | 627 return TimeTicks() + QPCValueToTimeDelta(qpc_value); |
| 623 } | 628 } |
| 624 | 629 |
| 625 // TimeDelta ------------------------------------------------------------------ | 630 // TimeDelta ------------------------------------------------------------------ |
| 626 | 631 |
| 627 // static | 632 // static |
| 628 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { | 633 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { |
| 629 return QPCValueToTimeDelta(qpc_value); | 634 return QPCValueToTimeDelta(qpc_value); |
| 630 } | 635 } |
| OLD | NEW |