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

Unified Diff: base/time/time_win.cc

Issue 1910063003: More accurate implementation of watched thread time for Gpu Watchdog. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/time/time.h ('k') | content/gpu/gpu_watchdog_thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/time/time_win.cc
diff --git a/base/time/time_win.cc b/base/time/time_win.cc
index ad3c9914dbdc81cceff83b4698f43252a480ba8b..ac3197a0c709140addd9145252789525a96e72e2 100644
--- a/base/time/time_win.cc
+++ b/base/time/time_win.cc
@@ -42,6 +42,7 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/synchronization/lock.h"
+#include "base/threading/platform_thread.h"
using base::ThreadTicks;
using base::Time;
@@ -98,16 +99,6 @@ uint32_t g_high_res_timer_count = 0;
base::LazyInstance<base::Lock>::Leaky g_high_res_lock =
LAZY_INSTANCE_INITIALIZER;
-// Returns a pointer to the QueryThreadCycleTime() function from Windows.
-// Can't statically link to it because it is not available on XP.
-using QueryThreadCycleTimePtr = decltype(::QueryThreadCycleTime)*;
-QueryThreadCycleTimePtr GetQueryThreadCycleTimeFunction() {
- static const QueryThreadCycleTimePtr query_thread_cycle_time_fn =
- reinterpret_cast<QueryThreadCycleTimePtr>(::GetProcAddress(
- ::GetModuleHandle(L"kernel32.dll"), "QueryThreadCycleTime"));
- return query_thread_cycle_time_fn;
-}
-
// Returns the current value of the performance counter.
uint64_t QPCNowRaw() {
LARGE_INTEGER perf_counter_now = {};
@@ -518,11 +509,17 @@ TimeTicks::Clock TimeTicks::GetClock() {
// static
ThreadTicks ThreadTicks::Now() {
+ return ThreadTicks::GetForThread(PlatformThread::CurrentHandle());
+}
+
+// static
+ThreadTicks ThreadTicks::GetForThread(
+ const base::PlatformThreadHandle& thread_handle) {
DCHECK(IsSupported());
// Get the number of TSC ticks used by the current thread.
ULONG64 thread_cycle_time = 0;
- GetQueryThreadCycleTimeFunction()(::GetCurrentThread(), &thread_cycle_time);
+ ::QueryThreadCycleTime(thread_handle.platform_handle(), &thread_cycle_time);
// Get the frequency of the TSC.
double tsc_ticks_per_second = TSCTicksPerSecond();
@@ -537,8 +534,7 @@ ThreadTicks ThreadTicks::Now() {
// static
bool ThreadTicks::IsSupportedWin() {
- static bool is_supported = GetQueryThreadCycleTimeFunction() &&
- base::CPU().has_non_stop_time_stamp_counter() &&
+ static bool is_supported = base::CPU().has_non_stop_time_stamp_counter() &&
!IsBuggyAthlon(base::CPU());
return is_supported;
}
« no previous file with comments | « base/time/time.h ('k') | content/gpu/gpu_watchdog_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698