diff options
author | mbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-15 19:20:49 +0000 |
---|---|---|
committer | mbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-15 19:20:49 +0000 |
commit | 14255a99d1709414d9b5419329e19bf9bd8406b7 (patch) | |
tree | 18616ca60c09839db53690e8c127f5972ca76899 /base/time.h | |
parent | 3f20a2191bdac8e08bc1572913d5aa4a17df930c (diff) | |
download | chromium_src-14255a99d1709414d9b5419329e19bf9bd8406b7.zip chromium_src-14255a99d1709414d9b5419329e19bf9bd8406b7.tar.gz chromium_src-14255a99d1709414d9b5419329e19bf9bd8406b7.tar.bz2 |
Reland old fix that was reverted incorrectly.
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
Review URL: http://codereview.chromium.org/6904117
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85413 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/time.h')
-rw-r--r-- | base/time.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/base/time.h b/base/time.h index 58b0eb2..1b05e24 100644 --- a/base/time.h +++ b/base/time.h @@ -25,6 +25,7 @@ #include <time.h> +#include "base/atomicops.h" #include "base/base_api.h" #include "base/basictypes.h" @@ -281,10 +282,16 @@ class BASE_API Time { // 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. + // returns true. Each successful activate call must be paired with a + // subsequent deactivate call. // 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 @@ -403,6 +410,9 @@ class BASE_API Time { // 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. |