summaryrefslogtreecommitdiffstats
path: root/base/time_win.cc
diff options
context:
space:
mode:
Diffstat (limited to 'base/time_win.cc')
-rw-r--r--base/time_win.cc32
1 files changed, 18 insertions, 14 deletions
diff --git a/base/time_win.cc b/base/time_win.cc
index 5d3ecd6..ca3aef1 100644
--- a/base/time_win.cc
+++ b/base/time_win.cc
@@ -310,16 +310,8 @@ TimeDelta RolloverProtectedNow() {
// retrieve and more reliable.
class HighResNowSingleton {
public:
- HighResNowSingleton()
- : ticks_per_microsecond_(0.0),
- skew_(0) {
- InitializeClock();
-
- // On Athlon X2 CPUs (e.g. model 15) QueryPerformanceCounter is
- // unreliable. Fallback to low-res clock.
- base::CPU cpu;
- if (cpu.vendor_name() == "AuthenticAMD" && cpu.family() == 15)
- DisableHighResClock();
+ static HighResNowSingleton* GetInstance() {
+ return Singleton<HighResNowSingleton>::get();
}
bool IsUsingHighResClock() {
@@ -346,6 +338,18 @@ class HighResNowSingleton {
}
private:
+ HighResNowSingleton()
+ : ticks_per_microsecond_(0.0),
+ skew_(0) {
+ InitializeClock();
+
+ // On Athlon X2 CPUs (e.g. model 15) QueryPerformanceCounter is
+ // unreliable. Fallback to low-res clock.
+ base::CPU cpu;
+ if (cpu.vendor_name() == "AuthenticAMD" && cpu.family() == 15)
+ DisableHighResClock();
+ }
+
// Synchronize the QPC clock with GetSystemTimeAsFileTime.
void InitializeClock() {
LARGE_INTEGER ticks_per_sec = {0};
@@ -374,7 +378,7 @@ class HighResNowSingleton {
float ticks_per_microsecond_; // 0 indicates QPF failed and we're broken.
int64 skew_; // Skew between lo-res and hi-res clocks (for debugging).
- DISALLOW_COPY_AND_ASSIGN(HighResNowSingleton);
+ friend struct DefaultSingletonTraits<HighResNowSingleton>;
};
} // namespace
@@ -394,15 +398,15 @@ TimeTicks TimeTicks::Now() {
// static
TimeTicks TimeTicks::HighResNow() {
- return TimeTicks() + Singleton<HighResNowSingleton>::get()->Now();
+ return TimeTicks() + HighResNowSingleton::GetInstance()->Now();
}
// static
int64 TimeTicks::GetQPCDriftMicroseconds() {
- return Singleton<HighResNowSingleton>::get()->GetQPCDriftMicroseconds();
+ return HighResNowSingleton::GetInstance()->GetQPCDriftMicroseconds();
}
// static
bool TimeTicks::IsHighResClockWorking() {
- return Singleton<HighResNowSingleton>::get()->IsUsingHighResClock();
+ return HighResNowSingleton::GetInstance()->IsUsingHighResClock();
} \ No newline at end of file