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

Issue 6904117: Reland old fix that was reverted without my knowledge. (Closed)

Created:
9 years, 7 months ago by Mike Belshe
Modified:
9 years, 5 months ago
CC:
chromium-reviews, pam+watch_chromium.org, jam, brettw-cc_chromium.org
Visibility:
Public.

Description

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 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=85413

Patch Set 1 #

Patch Set 2 : '' #

Patch Set 3 : '' #

Total comments: 7
Unified diffs Side-by-side diffs Delta from patch set Stats (+104 lines, -12 lines) Patch
M base/message_loop.cc View 3 chunks +15 lines, -3 lines 0 comments Download
M base/time.h View 2 chunks +10 lines, -1 line 0 comments Download
M base/time_win.cc View 2 chunks +19 lines, -4 lines 4 comments Download
M chrome/chrome_tests.gypi View 1 1 chunk +1 line, -0 lines 0 comments Download
M content/common/hi_res_timer_manager.h View 1 chunk +4 lines, -1 line 0 comments Download
M content/common/hi_res_timer_manager_posix.cc View 1 chunk +1 line, -1 line 0 comments Download
A content/common/hi_res_timer_manager_unittest.cc View 1 2 1 chunk +51 lines, -0 lines 3 comments Download
M content/common/hi_res_timer_manager_win.cc View 2 chunks +3 lines, -2 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
Mike Belshe
Jim - You code reviewed this long ago: http://codereview.chromium.org/3848002/show But it got reverted multiple times ...
9 years, 7 months ago (2011-04-29 15:26:37 UTC) #1
jar (doing other things)
Question and a nit below. http://codereview.chromium.org/6904117/diff/3011/base/time_win.cc File base/time_win.cc (right): http://codereview.chromium.org/6904117/diff/3011/base/time_win.cc#newcode176 base/time_win.cc:176: high_resolution_timer_activated_++; Should you be ...
9 years, 7 months ago (2011-05-01 17:42:34 UTC) #2
Mike Belshe
http://codereview.chromium.org/6904117/diff/3011/base/time_win.cc File base/time_win.cc (right): http://codereview.chromium.org/6904117/diff/3011/base/time_win.cc#newcode176 base/time_win.cc:176: high_resolution_timer_activated_++; On 2011/05/01 17:42:34, jar wrote: > Should you ...
9 years, 7 months ago (2011-05-01 21:58:00 UTC) #3
Mike Belshe
http://codereview.chromium.org/6904117/diff/3011/base/time_win.cc File base/time_win.cc (right): http://codereview.chromium.org/6904117/diff/3011/base/time_win.cc#newcode176 base/time_win.cc:176: high_resolution_timer_activated_++; On 2011/05/01 21:58:00, Mike Belshe wrote: > On ...
9 years, 7 months ago (2011-05-04 07:23:13 UTC) #4
jar (doing other things)
9 years, 7 months ago (2011-05-04 16:08:26 UTC) #5
LGTM with with the two items at your discretion.

http://codereview.chromium.org/6904117/diff/3011/base/time_win.cc
File base/time_win.cc (right):

http://codereview.chromium.org/6904117/diff/3011/base/time_win.cc#newcode176
base/time_win.cc:176: high_resolution_timer_activated_++;
Ah... I see... sorry for my confusion.

Maybe it would be good to add comments for lines 176 and 189:

  // For tests ONLY.  Not used in production.

I would expect that you'll have to have a suppression in valgrind for this,
since the value will be changed in a race, even though never relied upon. (maybe
you already have a suppression).  Having a local comment would make it clear
that a suppression should be added.

On 2011/05/04 07:23:13, Mike Belshe wrote:
> On 2011/05/01 21:58:00, Mike Belshe wrote:
> > On 2011/05/01 17:42:34, jar wrote:
> > > Should you be concerned with atomic increment and decrement?  Is this
> > guarnateed
> > > to only appear on one thread?
> > 
> > Good point, I'll add atomics.
> 
> 
> Actually, Jim - I looked again.  The comments in lines 186-190 explain this,
and
> the comments in the header file do as well.  This is only used for testing (so
> we can verify the high res timer is activated or not), and the comments
clearly
> say that this can only be used in single-threaded tests.
>

http://codereview.chromium.org/6904117/diff/3011/content/common/hi_res_timer_...
File content/common/hi_res_timer_manager_unittest.cc (right):

http://codereview.chromium.org/6904117/diff/3011/content/common/hi_res_timer_...
content/common/hi_res_timer_manager_unittest.cc:24:
manager.OnPowerStateChange(/* on_battery */ false);
Yeah... a name change like that would be an equally good (or better)
improvement.  The prefix word "On" has come to mean "When an event ... has
happened" so I'd probably rather see:

BatteryOn(bool state)

or

BatteryIsOn(bool state)

or

BatteryPowered(bool is_battery_powered)

or something of that sort.

On 2011/05/01 21:58:00, Mike Belshe wrote:
> On 2011/05/01 17:42:34, jar wrote:
> > Rather than using a boolean, it would be much more readable to use a pair of
> > distinct enumerators.  (a new pet peeve I've added to my code reviews when
the
> > function or method name does not make the meaning of the argument clear).
> 
> Well, if I'm going to change the API and all callers of it, would it be better
> to change it to "OnBattery(bool)"?
>

Powered by Google App Engine
This is Rietveld 408576698