summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/test/test_suite.cc1
-rw-r--r--base/time/time.h8
-rw-r--r--base/time/time_win.cc50
-rw-r--r--chrome/browser/chrome_browser_main_win.cc1
-rw-r--r--content/app/content_main_runner.cc2
5 files changed, 20 insertions, 42 deletions
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc
index 0084d1e..c7a921a 100644
--- a/base/test/test_suite.cc
+++ b/base/test/test_suite.cc
@@ -135,7 +135,6 @@ void TestSuite::InitializeFromCommandLine(int argc, wchar_t** argv) {
void TestSuite::PreInitialize(bool create_at_exit_manager) {
#if defined(OS_WIN)
testing::GTEST_FLAG(catch_exceptions) = false;
- base::TimeTicks::SetNowIsHighResNowIfSupported();
#endif
base::EnableTerminationOnHeapCorruption();
#if defined(OS_LINUX) && defined(USE_AURA)
diff --git a/base/time/time.h b/base/time/time.h
index 79346f1..4d72a19 100644
--- a/base/time/time.h
+++ b/base/time/time.h
@@ -639,14 +639,6 @@ class BASE_EXPORT TimeTicks {
// This is only for testing.
static bool IsHighResClockWorking();
- // Enable high resolution time for TimeTicks::Now(). This function will
- // test for the availability of a working implementation of
- // QueryPerformanceCounter(). If one is not available, this function does
- // nothing and the resolution of Now() remains 1ms. Otherwise, all future
- // calls to TimeTicks::Now() will have the higher resolution provided by QPC.
- // Returns true if high resolution time was successfully enabled.
- static bool SetNowIsHighResNowIfSupported();
-
// Returns a time value that is NOT rollover protected.
static TimeTicks UnprotectedNow();
#endif
diff --git a/base/time/time_win.cc b/base/time/time_win.cc
index 5fa899d..27bcd18 100644
--- a/base/time/time_win.cc
+++ b/base/time/time_win.cc
@@ -359,21 +359,24 @@ bool IsBuggyAthlon(const base::CPU& cpu) {
class HighResNowSingleton {
public:
HighResNowSingleton()
- : ticks_per_second_(0),
- skew_(0) {
- InitializeClock();
+ : ticks_per_second_(0),
+ skew_(0) {
base::CPU cpu;
if (IsBuggyAthlon(cpu))
- DisableHighResClock();
- }
+ return;
- bool IsUsingHighResClock() {
- return ticks_per_second_ != 0.0;
+ // Synchronize the QPC clock with GetSystemTimeAsFileTime.
+ LARGE_INTEGER ticks_per_sec = {0};
+ if (!QueryPerformanceFrequency(&ticks_per_sec))
+ return; // QPC is not available.
+ ticks_per_second_ = ticks_per_sec.QuadPart;
+
+ skew_ = UnreliableNow() - ReliableNow();
}
- void DisableHighResClock() {
- ticks_per_second_ = 0.0;
+ bool IsUsingHighResClock() {
+ return ticks_per_second_ != 0;
}
TimeDelta Now() {
@@ -408,16 +411,6 @@ class HighResNowSingleton {
}
private:
- // Synchronize the QPC clock with GetSystemTimeAsFileTime.
- void InitializeClock() {
- LARGE_INTEGER ticks_per_sec = {0};
- if (!QueryPerformanceFrequency(&ticks_per_sec))
- return; // Broken, we don't guarantee this function works.
- ticks_per_second_ = ticks_per_sec.QuadPart;
-
- skew_ = UnreliableNow() - ReliableNow();
- }
-
// Get the number of microseconds since boot in an unreliable fashion.
int64 UnreliableNow() {
LARGE_INTEGER now;
@@ -446,7 +439,6 @@ TimeDelta HighResNowWrapper() {
}
typedef TimeDelta (*NowFunction)(void);
-NowFunction now_function = RolloverProtectedNow;
bool CPUReliablySupportsHighResTime() {
base::CPU cpu;
@@ -460,6 +452,14 @@ bool CPUReliablySupportsHighResTime() {
return true;
}
+NowFunction GetNowFunction() {
+ if (!CPUReliablySupportsHighResTime())
+ return RolloverProtectedNow;
+ return HighResNowWrapper;
+}
+
+NowFunction now_function = GetNowFunction();
+
} // namespace
// static
@@ -474,16 +474,6 @@ TimeTicks::TickFunctionType TimeTicks::SetMockTickFunction(
}
// static
-bool TimeTicks::SetNowIsHighResNowIfSupported() {
- if (!CPUReliablySupportsHighResTime()) {
- return false;
- }
-
- now_function = HighResNowWrapper;
- return true;
-}
-
-// static
TimeTicks TimeTicks::Now() {
return TimeTicks() + now_function();
}
diff --git a/chrome/browser/chrome_browser_main_win.cc b/chrome/browser/chrome_browser_main_win.cc
index fb517ee..18bfb73 100644
--- a/chrome/browser/chrome_browser_main_win.cc
+++ b/chrome/browser/chrome_browser_main_win.cc
@@ -158,7 +158,6 @@ int DoUninstallTasks(bool chrome_still_running) {
ChromeBrowserMainPartsWin::ChromeBrowserMainPartsWin(
const content::MainFunctionParams& parameters)
: ChromeBrowserMainParts(parameters) {
- base::TimeTicks::SetNowIsHighResNowIfSupported();
if (base::win::IsMetroProcess()) {
typedef const wchar_t* (*GetMetroSwitches)(void);
GetMetroSwitches metro_switches_proc = reinterpret_cast<GetMetroSwitches>(
diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc
index e9aebce..5827ae2 100644
--- a/content/app/content_main_runner.cc
+++ b/content/app/content_main_runner.cc
@@ -661,8 +661,6 @@ class ContentMainRunnerImpl : public ContentMainRunner {
MachBroker::ChildSendTaskPortToParent();
}
#elif defined(OS_WIN)
- base::TimeTicks::SetNowIsHighResNowIfSupported();
-
bool init_device_scale_factor = true;
if (command_line.HasSwitch(switches::kDeviceScaleFactor)) {
std::string scale_factor_string = command_line.GetSwitchValueASCII(