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

Issue 23205008: Fix a bug where the minimum granular time for Alarms was not calculated properly. (Closed)

Created:
7 years, 4 months ago by dhnishi (use Chromium)
Modified:
6 years, 11 months ago
Reviewers:
dhnishi, Yoyo Zhou, Matt Perry, iclelland
CC:
chromium-reviews, chromium-apps-reviews_chromium.org, extensions-reviews_chromium.org
Base URL:
http://git.chromium.org/chromium/src.git@master
Visibility:
Public.

Description

Fix a bug where the minimum granular time for Alarms was not calculated properly. BUG=268300 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=218398

Patch Set 1 #

Total comments: 2

Patch Set 2 : Unit tests. #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+33 lines, -4 lines) Patch
M chrome/browser/extensions/api/alarms/alarm_manager.h View 1 2 chunks +4 lines, -0 lines 0 comments Download
M chrome/browser/extensions/api/alarms/alarm_manager.cc View 3 chunks +7 lines, -1 line 4 comments Download
M chrome/browser/extensions/api/alarms/alarms_api_unittest.cc View 1 2 chunks +22 lines, -3 lines 0 comments Download

Messages

Total messages: 16 (0 generated)
dhnishi (use Chromium)
@mpcomplete: PTAL when you get a moment.
7 years, 4 months ago (2013-08-16 22:21:39 UTC) #1
dhnishi (use Chromium)
https://codereview.chromium.org/23205008/diff/1/chrome/browser/extensions/api/alarms/alarm_manager.cc File chrome/browser/extensions/api/alarms/alarm_manager.cc (right): https://codereview.chromium.org/23205008/diff/1/chrome/browser/extensions/api/alarms/alarm_manager.cc#newcode327 chrome/browser/extensions/api/alarms/alarm_manager.cc:327: base::TimeDelta cur_alarm_delta = cur_alarm_time - clock_->Now(); I am worried ...
7 years, 4 months ago (2013-08-16 22:28:29 UTC) #2
Matt Perry
Could you add a unittest that covers the case outlined in the bug (and make ...
7 years, 4 months ago (2013-08-16 22:28:30 UTC) #3
Matt Perry
https://codereview.chromium.org/23205008/diff/1/chrome/browser/extensions/api/alarms/alarm_manager.cc File chrome/browser/extensions/api/alarms/alarm_manager.cc (right): https://codereview.chromium.org/23205008/diff/1/chrome/browser/extensions/api/alarms/alarm_manager.cc#newcode327 chrome/browser/extensions/api/alarms/alarm_manager.cc:327: base::TimeDelta cur_alarm_delta = cur_alarm_time - clock_->Now(); On 2013/08/16 22:28:29, ...
7 years, 4 months ago (2013-08-16 22:30:59 UTC) #4
dhnishi (use Chromium)
On 2013/08/16 22:30:59, Matt Perry wrote: > https://codereview.chromium.org/23205008/diff/1/chrome/browser/extensions/api/alarms/alarm_manager.cc > File chrome/browser/extensions/api/alarms/alarm_manager.cc (right): > > https://codereview.chromium.org/23205008/diff/1/chrome/browser/extensions/api/alarms/alarm_manager.cc#newcode327 ...
7 years, 4 months ago (2013-08-16 22:35:48 UTC) #5
Matt Perry
On 2013/08/16 22:35:48, Daniel Nishi wrote: > On 2013/08/16 22:30:59, Matt Perry wrote: > > ...
7 years, 4 months ago (2013-08-16 22:42:42 UTC) #6
dhnishi (use Chromium)
I added a unit test. It fails without my patch at 240000 (one extra minute) ...
7 years, 4 months ago (2013-08-16 23:41:25 UTC) #7
Matt Perry
Great, LGTM
7 years, 4 months ago (2013-08-16 23:47:14 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/DHNishi@gmail.com/23205008/9001
7 years, 4 months ago (2013-08-16 23:54:29 UTC) #9
commit-bot: I haz the power
Retried try job too often on ios_dbg_simulator for step(s) media_unittests http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=ios_dbg_simulator&number=78407
7 years, 4 months ago (2013-08-17 01:03:36 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/DHNishi@gmail.com/23205008/9001
7 years, 4 months ago (2013-08-19 19:51:14 UTC) #11
commit-bot: I haz the power
Change committed as 218398
7 years, 4 months ago (2013-08-20 01:31:46 UTC) #12
Matt Perry
https://chromiumcodereview.appspot.com/23205008/diff/9001/chrome/browser/extensions/api/alarms/alarm_manager.cc File chrome/browser/extensions/api/alarms/alarm_manager.cc (right): https://chromiumcodereview.appspot.com/23205008/diff/9001/chrome/browser/extensions/api/alarms/alarm_manager.cc#newcode330 chrome/browser/extensions/api/alarms/alarm_manager.cc:330: if (min_granularity < l_it->minimum_granularity) I think these 2 ifs ...
6 years, 11 months ago (2014-01-16 22:58:34 UTC) #13
Yoyo Zhou
https://chromiumcodereview.appspot.com/23205008/diff/9001/chrome/browser/extensions/api/alarms/alarm_manager.cc File chrome/browser/extensions/api/alarms/alarm_manager.cc (right): https://chromiumcodereview.appspot.com/23205008/diff/9001/chrome/browser/extensions/api/alarms/alarm_manager.cc#newcode330 chrome/browser/extensions/api/alarms/alarm_manager.cc:330: if (min_granularity < l_it->minimum_granularity) On 2014/01/16 22:58:34, Matt Perry ...
6 years, 11 months ago (2014-01-16 23:34:31 UTC) #14
iclelland
I've added some examples showing how the computed min_granularity now depends on the *order* of ...
6 years, 11 months ago (2014-01-17 14:54:31 UTC) #15
Matt Perry
6 years, 11 months ago (2014-01-17 18:43:51 UTC) #16
Message was sent while issue was closed.
https://chromiumcodereview.appspot.com/23205008/diff/9001/chrome/browser/exte...
File chrome/browser/extensions/api/alarms/alarm_manager.cc (right):

https://chromiumcodereview.appspot.com/23205008/diff/9001/chrome/browser/exte...
chrome/browser/extensions/api/alarms/alarm_manager.cc:330: if (min_granularity <
l_it->minimum_granularity)
On 2014/01/17 14:54:32, iclelland wrote:
> On 2014/01/16 22:58:34, Matt Perry wrote:
> > I think these 2 ifs are reversed. The idea here is that
> > l_it->minimum_granularity is the extension's granularity (0 for an unpacked
> > extension, 1 min otherwise). So if a release-mode alarm will go off 30 sec
> from
> > now, it should be capped to 1min instead. But that shouldn't override the
> > min_granularity if it's already set to go off in, say, 10 sec.
> 
> I don't think it's reversed -- it should _increase_ min_granularity if it's
> below an alarm's minimum_granularity.
> 
> However, it makes the result sensitive to the order of the alarms iterated
over.
> If an early alarm has a large minimum_granularity, then min_granularity would
be
> set to that, but a later alarm with a small granularity (not
> minimum_granularity) would lower it again.
> 
> Example:
> alarm1: granularity=1min, minumum_granularity=1min
> alarm2: granularity=10min, minimum_granularity=1min
> alarm3: granularity=1000min, minimum_granularity=100min
> 
> Given (alarm1, alarm2, alarm3), min_granularity ends up at 100min.
> Given (alarm2, alarm3, alarm1), min_granularity ends up at 1min.
> Given (alarm1, alarm3, alarm2), min_granularity ends up at 10min.
> 
> 
> I think what was intended here was:
>    min_granularity = max ( min(all granularity members), max(all
> minimum_granularity members) )

That's not the intended calculation. Each alarm's minimum_granularity should
only affect that alarm. So for your example, our desired min_granularity is
1min, due to alarm 1.

What we want is:
min_granularity = min( for each alarm, max(alarm granularity, alarm
minimum_granularity) )

Powered by Google App Engine
This is Rietveld 408576698