Index: base/time_win.cc |
diff --git a/base/time_win.cc b/base/time_win.cc |
index 71c914da29dabe75003d9e83172269d3ac72a717..0e1c67ed65143366361d464f1713fa20a2b67415 100644 |
--- a/base/time_win.cc |
+++ b/base/time_win.cc |
@@ -371,6 +371,11 @@ class HighResNowSingleton { |
return abs(static_cast<long>((UnreliableNow() - ReliableNow()) - skew_)); |
} |
+ TimeDelta FromQPCValue(LONGLONG qpcValue) { |
+ return TimeDelta::FromMicroseconds( |
+ static_cast<int64>(qpcValue / ticks_per_microsecond_)); |
apatrick_chromium
2012/07/30 19:43:31
nit: indent 4 spaces.
|
+ } |
+ |
private: |
HighResNowSingleton() |
: ticks_per_microsecond_(0.0), |
@@ -389,8 +394,8 @@ class HighResNowSingleton { |
LARGE_INTEGER ticks_per_sec = {0}; |
if (!QueryPerformanceFrequency(&ticks_per_sec)) |
return; // Broken, we don't guarantee this function works. |
- ticks_per_microsecond_ = static_cast<float>(ticks_per_sec.QuadPart) / |
- static_cast<float>(Time::kMicrosecondsPerSecond); |
+ ticks_per_microsecond_ = static_cast<double>(ticks_per_sec.QuadPart) / |
+ static_cast<double>(Time::kMicrosecondsPerSecond); |
skew_ = UnreliableNow() - ReliableNow(); |
} |
@@ -409,7 +414,7 @@ class HighResNowSingleton { |
// Cached clock frequency -> microseconds. This assumes that the clock |
// frequency is faster than one microsecond (which is 1MHz, should be OK). |
- float ticks_per_microsecond_; // 0 indicates QPF failed and we're broken. |
+ double ticks_per_microsecond_; // 0 indicates QPF failed and we're broken. |
brianderson
2012/07/30 19:38:13
jar, is changing this to a double ok?
jar (doing other things)
2012/07/30 21:41:33
<Doh>.... I hadn't noticed this. <woops!>
Can you
brianderson
2012/07/30 22:37:31
Dividing a 64-bit integer by the 32-bit float coul
|
int64 skew_; // Skew between lo-res and hi-res clocks (for debugging). |
friend struct DefaultSingletonTraits<HighResNowSingleton>; |
@@ -446,6 +451,19 @@ int64 TimeTicks::GetQPCDriftMicroseconds() { |
} |
// static |
+TimeTicks TimeTicks::FromQPCValue(LONGLONG qpcValue) { |
+ return TimeTicks() + |
apatrick_chromium
2012/07/30 19:43:31
why not TimeTicks::FromInternalValue()?
brianderson
2012/07/30 20:16:39
Copied this trick from TimeTicks::HighResNow() a f
|
+ HighResNowSingleton::GetInstance()->FromQPCValue(qpcValue); |
apatrick_chromium
2012/07/30 19:43:31
nit: indent 4 spaces
|
+} |
+ |
+// static |
bool TimeTicks::IsHighResClockWorking() { |
return HighResNowSingleton::GetInstance()->IsUsingHighResClock(); |
} |
+ |
+// TimeDelta ------------------------------------------------------------------ |
+ |
+// static |
+TimeDelta TimeDelta::FromQPCValue(LONGLONG qpcValue) { |
+ return HighResNowSingleton::GetInstance()->FromQPCValue(qpcValue); |
+} |