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


CrOS-Libchrome-Original-Commit: 21766d7536424c43a8d677bedeb8c81e6cce41c7
diff --git a/base/message_loop.cc b/base/message_loop.cc
index 0b03d3c..8f6c997 100644
--- a/base/message_loop.cc
+++ b/base/message_loop.cc
@@ -179,16 +179,6 @@
 
   // OK, now make it so that no one can find us.
   lazy_tls_ptr.Pointer()->Set(NULL);
-
-#if defined(OS_WIN)
-  // If we left the high-resolution timer activated, deactivate it now.
-  // Doing this is not-critical, it is mainly to make sure we track
-  // the high resolution timer activations properly in our unit tests.
-  if (!high_resolution_timer_expiration_.is_null()) {
-    Time::ActivateHighResolutionTimer(false);
-    high_resolution_timer_expiration_ = base::TimeTicks();
-  }
-#endif
 }
 
 void MessageLoop::AddDestructionObserver(
@@ -347,10 +337,9 @@
       bool needs_high_res_timers =
           delay_ms < (2 * Time::kMinLowResolutionThresholdMs);
       if (needs_high_res_timers) {
-        if (Time::ActivateHighResolutionTimer(true)) {
-          high_resolution_timer_expiration_ = base::TimeTicks::Now() +
-              TimeDelta::FromMilliseconds(kHighResolutionTimerModeLeaseTimeMs);
-        }
+        Time::ActivateHighResolutionTimer(true);
+        high_resolution_timer_expiration_ = base::TimeTicks::Now() +
+            TimeDelta::FromMilliseconds(kHighResolutionTimerModeLeaseTimeMs);
       }
     }
 #endif
diff --git a/base/time.h b/base/time.h
index 305ca6b..79e30b4 100644
--- a/base/time.h
+++ b/base/time.h
@@ -283,16 +283,10 @@
   // Activates or deactivates the high resolution timer based on the |activate|
   // flag.  If the HighResolutionTimer is not Enabled (see
   // EnableHighResolutionTimer), this function will return false.  Otherwise
-  // returns true.  Each successful activate call must be paired with a
-  // subsequent deactivate call.
+  // returns true.
   // All callers to activate the high resolution timer must eventually call
   // this function to deactivate the high resolution timer.
   static bool ActivateHighResolutionTimer(bool activate);
-
-  // Returns true if the high resolution timer is both enabled and activated.
-  // This is provided for testing only, and is not tracked in a thread-safe
-  // way.
-  static bool IsHighResolutionTimerInUse();
 #endif
 
   // Converts an exploded structure representing either the local time or UTC
@@ -411,9 +405,6 @@
   // when using battery power, we might elect to prevent high speed timers
   // which would draw more power.
   static bool high_resolution_timer_enabled_;
-  // Count of activations on the high resolution timer.  Only use in tests
-  // which are single threaded.
-  static int high_resolution_timer_activated_;
 #endif
 
   // Time in microseconds in UTC.