Chromium Code Reviews| Index: base/time/time_win.cc |
| diff --git a/base/time/time_win.cc b/base/time/time_win.cc |
| index dc968ad63980edbbe0280519a654447c121a74ae..e0307c560212edfe39983b57f8b543813799b4c4 100644 |
| --- a/base/time/time_win.cc |
| +++ b/base/time/time_win.cc |
| @@ -86,6 +86,9 @@ void InitializeClock() { |
| initial_time = CurrentWallclockMicroseconds(); |
| } |
| +const char* kTimeGetTimeClockId = "WIN_ROLLOVER_PROTECTED_TIME_GET_TIME_MICROS"; |
| +const char* kQPCClockId = "WIN_QPC_MICROS"; |
| + |
| // The two values that ActivateHighResolutionTimer uses to set the systemwide |
| // timer interrupt frequency on Windows. It controls how precise timers are |
| // but also has a big impact on battery life. |
| @@ -403,6 +406,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; |
| +const char* g_now_clock_id = ""; |
| + |
| int64_t g_qpc_ticks_per_second = 0; |
| // As of January 2015, use of <atomic> is forbidden in Chromium code. This is |
| @@ -459,12 +464,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_id; |
| base::CPU cpu; |
| if (ticks_per_sec.QuadPart <= 0 || |
| !cpu.has_non_stop_time_stamp_counter() || IsBuggyAthlon(cpu)) { |
| now_function = &RolloverProtectedNow; |
| + now_clock_id = kTimeGetTimeClockId; |
| } else { |
| now_function = &QPCNow; |
| + now_clock_id = kQPCClockId; |
| } |
| // Threading note 1: In an unlikely race condition, it's possible for two or |
| @@ -479,6 +487,7 @@ void InitializeNowFunctionPointer() { |
| g_qpc_ticks_per_second = ticks_per_sec.QuadPart; |
| ATOMIC_THREAD_FENCE(memory_order_release); |
| g_now_function = now_function; |
| + g_now_clock_id = now_clock_id; |
|
danakj
2016/03/26 00:40:33
Why is this after the fence?
charliea (OOO until 10-5)
2016/03/28 15:40:51
I'm not sure, but if the above comment is any indi
danakj
2016/03/28 17:53:50
Yeah, I stared at this for a while, and AFAICT the
charliea (OOO until 10-5)
2016/03/28 21:07:36
Done.
|
| } |
| TimeDelta InitialNowFunction() { |
| @@ -512,6 +521,13 @@ bool TimeTicks::IsHighResolution() { |
| } |
| // static |
| +std::string TimeTicks::ClockId() { |
| + if (g_now_function == &InitialNowFunction) |
| + InitializeNowFunctionPointer(); |
| + return g_now_clock_id; |
| +} |
| + |
| +// static |
| ThreadTicks ThreadTicks::Now() { |
| DCHECK(IsSupported()); |