Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(686)

Side by Side Diff: base/time/time_win.cc

Issue 1824673002: time: Add a static TimeTicks method that returns the underlying clock (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use IsHighResolution Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/time/time_posix.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 } 505 }
506 506
507 // static 507 // static
508 bool TimeTicks::IsHighResolution() { 508 bool TimeTicks::IsHighResolution() {
509 if (g_now_function == &InitialNowFunction) 509 if (g_now_function == &InitialNowFunction)
510 InitializeNowFunctionPointer(); 510 InitializeNowFunctionPointer();
511 return g_now_function == &QPCNow; 511 return g_now_function == &QPCNow;
512 } 512 }
513 513
514 // static 514 // static
515 TimeTicks::Clock TimeTicks::GetClock() {
516 return IsHighResolution() ?
517 Clock::WIN_QPC : Clock::WIN_ROLLOVER_PROTECTED_TIME_GET_TIME;
518 }
519
520 // static
515 ThreadTicks ThreadTicks::Now() { 521 ThreadTicks ThreadTicks::Now() {
516 DCHECK(IsSupported()); 522 DCHECK(IsSupported());
517 523
518 // Get the number of TSC ticks used by the current thread. 524 // Get the number of TSC ticks used by the current thread.
519 ULONG64 thread_cycle_time = 0; 525 ULONG64 thread_cycle_time = 0;
520 GetQueryThreadCycleTimeFunction()(::GetCurrentThread(), &thread_cycle_time); 526 GetQueryThreadCycleTimeFunction()(::GetCurrentThread(), &thread_cycle_time);
521 527
522 // Get the frequency of the TSC. 528 // Get the frequency of the TSC.
523 double tsc_ticks_per_second = TSCTicksPerSecond(); 529 double tsc_ticks_per_second = TSCTicksPerSecond();
524 if (tsc_ticks_per_second == 0) 530 if (tsc_ticks_per_second == 0)
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 TimeTicks TimeTicks::FromQPCValue(LONGLONG qpc_value) { 613 TimeTicks TimeTicks::FromQPCValue(LONGLONG qpc_value) {
608 return TimeTicks() + QPCValueToTimeDelta(qpc_value); 614 return TimeTicks() + QPCValueToTimeDelta(qpc_value);
609 } 615 }
610 616
611 // TimeDelta ------------------------------------------------------------------ 617 // TimeDelta ------------------------------------------------------------------
612 618
613 // static 619 // static
614 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { 620 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) {
615 return QPCValueToTimeDelta(qpc_value); 621 return QPCValueToTimeDelta(qpc_value);
616 } 622 }
OLDNEW
« no previous file with comments | « base/time/time_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698