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 29 matching lines...) Expand all Loading... |
40 #include <windows.h> | 40 #include <windows.h> |
41 #include <mmsystem.h> | 41 #include <mmsystem.h> |
42 | 42 |
43 #include "base/basictypes.h" | 43 #include "base/basictypes.h" |
44 #include "base/lock.h" | 44 #include "base/lock.h" |
45 #include "base/logging.h" | 45 #include "base/logging.h" |
46 #include "base/cpu.h" | 46 #include "base/cpu.h" |
47 #include "base/singleton.h" | 47 #include "base/singleton.h" |
48 #include "base/system_monitor.h" | 48 #include "base/system_monitor.h" |
49 | 49 |
| 50 using base::Time; |
| 51 using base::TimeDelta; |
| 52 using base::TimeTicks; |
| 53 |
50 namespace { | 54 namespace { |
51 | 55 |
52 // From MSDN, FILETIME "Contains a 64-bit value representing the number of | 56 // From MSDN, FILETIME "Contains a 64-bit value representing the number of |
53 // 100-nanosecond intervals since January 1, 1601 (UTC)." | 57 // 100-nanosecond intervals since January 1, 1601 (UTC)." |
54 int64 FileTimeToMicroseconds(const FILETIME& ft) { | 58 int64 FileTimeToMicroseconds(const FILETIME& ft) { |
55 // Need to bit_cast to fix alignment, then divide by 10 to convert | 59 // Need to bit_cast to fix alignment, then divide by 10 to convert |
56 // 100-nanoseconds to milliseconds. This only works on little-endian | 60 // 100-nanoseconds to milliseconds. This only works on little-endian |
57 // machines. | 61 // machines. |
58 return bit_cast<int64, FILETIME>(ft) / 10; | 62 return bit_cast<int64, FILETIME>(ft) / 10; |
59 } | 63 } |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 | 386 |
383 // static | 387 // static |
384 TimeTicks TimeTicks::Now() { | 388 TimeTicks TimeTicks::Now() { |
385 return TimeTicks() + Singleton<NowSingleton>::get()->Now(); | 389 return TimeTicks() + Singleton<NowSingleton>::get()->Now(); |
386 } | 390 } |
387 | 391 |
388 // static | 392 // static |
389 TimeTicks TimeTicks::HighResNow() { | 393 TimeTicks TimeTicks::HighResNow() { |
390 return TimeTicks() + Singleton<HighResNowSingleton>::get()->Now(); | 394 return TimeTicks() + Singleton<HighResNowSingleton>::get()->Now(); |
391 } | 395 } |
OLD | NEW |