| Index: base/time/time_win.cc
|
| diff --git a/base/time/time_win.cc b/base/time/time_win.cc
|
| index dc968ad63980edbbe0280519a654447c121a74ae..7c82b5127d7d7405afbee99e1dffaee08f738df8 100644
|
| --- a/base/time/time_win.cc
|
| +++ b/base/time/time_win.cc
|
| @@ -403,6 +403,8 @@ TimeDelta InitialNowFunction();
|
| // See "threading notes" in InitializeNowFunctionPointer() for details on how
|
| // concurrent reads/writes to these globals has been made safe.
|
| NowFunction g_now_function = &InitialNowFunction;
|
| +TimeTicks::Clock g_now_clock = TimeTicks::Clock::UNKNOWN;
|
| +
|
| int64_t g_qpc_ticks_per_second = 0;
|
|
|
| // As of January 2015, use of <atomic> is forbidden in Chromium code. This is
|
| @@ -459,12 +461,15 @@ void InitializeNowFunctionPointer() {
|
| // Otherwise, Now uses the high-resolution QPC clock. As of 21 August 2015,
|
| // ~72% of users fall within this category.
|
| NowFunction now_function;
|
| + const char* now_clock;
|
| base::CPU cpu;
|
| if (ticks_per_sec.QuadPart <= 0 ||
|
| !cpu.has_non_stop_time_stamp_counter() || IsBuggyAthlon(cpu)) {
|
| now_function = &RolloverProtectedNow;
|
| + now_clock = Clock::WIN_ROLLOVER_PROTECTED_TIME_GET_TIME;
|
| } else {
|
| now_function = &QPCNow;
|
| + now_clock = Clock::WIN_QPC;
|
| }
|
|
|
| // Threading note 1: In an unlikely race condition, it's possible for two or
|
| @@ -476,6 +481,7 @@ void InitializeNowFunctionPointer() {
|
| // perspective of other threads using the function pointers, that the
|
| // assignment to |g_qpc_ticks_per_second| happens before the function pointers
|
| // are changed.
|
| + g_now_clock = now_clock;
|
| g_qpc_ticks_per_second = ticks_per_sec.QuadPart;
|
| ATOMIC_THREAD_FENCE(memory_order_release);
|
| g_now_function = now_function;
|
| @@ -512,6 +518,13 @@ bool TimeTicks::IsHighResolution() {
|
| }
|
|
|
| // static
|
| +TimeTicks::Clock TimeTicks::GetClock() {
|
| + if (g_now_function == &InitialNowFunction)
|
| + InitializeNowFunctionPointer();
|
| + return g_now_clock;
|
| +}
|
| +
|
| +// static
|
| ThreadTicks ThreadTicks::Now() {
|
| DCHECK(IsSupported());
|
|
|
|
|