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 16 matching lines...) Expand all Loading... |
27 // article about this here: | 27 // article about this here: |
28 // http://softwarecommunity.intel.com/articles/eng/1086.htm | 28 // http://softwarecommunity.intel.com/articles/eng/1086.htm |
29 // | 29 // |
30 // To work around all this, we're going to generally use timeGetTime(). We | 30 // To work around all this, we're going to generally use timeGetTime(). We |
31 // will only increase the system-wide timer if we're not running on battery | 31 // will only increase the system-wide timer if we're not running on battery |
32 // power. Using timeBeginPeriod(1) is a requirement in order to make our | 32 // power. Using timeBeginPeriod(1) is a requirement in order to make our |
33 // message loop waits have the same resolution that our time measurements | 33 // message loop waits have the same resolution that our time measurements |
34 // do. Otherwise, WaitForSingleObject(..., 1) will no less than 15ms when | 34 // do. Otherwise, WaitForSingleObject(..., 1) will no less than 15ms when |
35 // there is nothing else to waken the Wait. | 35 // there is nothing else to waken the Wait. |
36 | 36 |
37 #include "base/time.h" | 37 #include "base/time/time.h" |
38 | 38 |
39 #pragma comment(lib, "winmm.lib") | 39 #pragma comment(lib, "winmm.lib") |
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/cpu.h" |
44 #include "base/logging.h" | 45 #include "base/logging.h" |
45 #include "base/cpu.h" | |
46 #include "base/memory/singleton.h" | 46 #include "base/memory/singleton.h" |
47 #include "base/synchronization/lock.h" | 47 #include "base/synchronization/lock.h" |
48 | 48 |
49 using base::Time; | 49 using base::Time; |
50 using base::TimeDelta; | 50 using base::TimeDelta; |
51 using base::TimeTicks; | 51 using base::TimeTicks; |
52 | 52 |
53 namespace { | 53 namespace { |
54 | 54 |
55 // From MSDN, FILETIME "Contains a 64-bit value representing the number of | 55 // From MSDN, FILETIME "Contains a 64-bit value representing the number of |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 return HighResNowSingleton::GetInstance()->IsUsingHighResClock(); | 477 return HighResNowSingleton::GetInstance()->IsUsingHighResClock(); |
478 } | 478 } |
479 | 479 |
480 // TimeDelta ------------------------------------------------------------------ | 480 // TimeDelta ------------------------------------------------------------------ |
481 | 481 |
482 // static | 482 // static |
483 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { | 483 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { |
484 return TimeDelta( | 484 return TimeDelta( |
485 HighResNowSingleton::GetInstance()->QPCValueToMicroseconds(qpc_value)); | 485 HighResNowSingleton::GetInstance()->QPCValueToMicroseconds(qpc_value)); |
486 } | 486 } |
OLD | NEW |