diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-20 10:50:38 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-20 10:50:38 +0000 |
commit | 21766d7536424c43a8d677bedeb8c81e6cce41c7 (patch) | |
tree | e9da0d1983b21f2459ba8fdc56699a252b4bda38 /base/time_win.cc | |
parent | e97c2822866796a872cb59c12a5e831e98b085d3 (diff) | |
download | chromium_src-21766d7536424c43a8d677bedeb8c81e6cce41c7.zip chromium_src-21766d7536424c43a8d677bedeb8c81e6cce41c7.tar.gz chromium_src-21766d7536424c43a8d677bedeb8c81e6cce41c7.tar.bz2 |
Revert 63191 - 2nd try:
Fix regression where high resolution timers could be activated even under
battery power. Add unit test to protect chromium from developers like me
in the future.
The fix is a one-liner in hi_res_timer_manager_win.cc. The rest of the code
change is the mechanics to enable the unit test.
BUG=59528
TEST=HiResTimerManagerTest.ToggleOnOff
Broke unit_tests on Vista and XP:
[ RUN ] GeolocationNetworkProviderTest.GatewayAndWifiScans
[2916:2376:1020/030222:2975321329:FATAL:network_location_provider.cc(51)] Check failed: cache_.size() == cache_times_.size().
Review URL: http://codereview.chromium.org/3889004
TBR=mbelshe@chromium.org
Review URL: http://codereview.chromium.org/3946003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63200 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/time_win.cc')
-rw-r--r-- | base/time_win.cc | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/base/time_win.cc b/base/time_win.cc index 502dd83..5d3ecd6 100644 --- a/base/time_win.cc +++ b/base/time_win.cc @@ -99,7 +99,6 @@ void InitializeClock() { const int64 Time::kTimeTToMicrosecondsOffset = GG_INT64_C(11644473600000000); bool Time::high_resolution_timer_enabled_ = false; -int Time::high_resolution_timer_activated_ = 0; // static Time Time::Now() { @@ -163,36 +162,22 @@ void Time::EnableHighResolutionTimer(bool enable) { } // static -bool Time::ActivateHighResolutionTimer(bool activating) { - if (!high_resolution_timer_enabled_ && activating) +bool Time::ActivateHighResolutionTimer(bool activate) { + if (!high_resolution_timer_enabled_) return false; // Using anything other than 1ms makes timers granular // to that interval. const int kMinTimerIntervalMs = 1; MMRESULT result; - if (activating) { + if (activate) result = timeBeginPeriod(kMinTimerIntervalMs); - high_resolution_timer_activated_++; - } else { + else result = timeEndPeriod(kMinTimerIntervalMs); - high_resolution_timer_activated_--; - } return result == TIMERR_NOERROR; } // static -bool Time::IsHighResolutionTimerInUse() { - // Note: we should track the high_resolution_timer_activated_ value - // under a lock if we want it to be accurate in a system with multiple - // message loops. We don't do that - because we don't want to take the - // expense of a lock for this. We *only* track this value so that unit - // tests can see if the high resolution timer is on or off. - return high_resolution_timer_enabled_ && - high_resolution_timer_activated_ > 0; -} - -// static Time Time::FromExploded(bool is_local, const Exploded& exploded) { // Create the system struct representing our exploded time. It will either be // in local time or UTC. |