Chromium Code Reviews| Index: chrome/browser/push_messaging/background_budget_service.cc |
| diff --git a/chrome/browser/push_messaging/background_budget_service.cc b/chrome/browser/push_messaging/background_budget_service.cc |
| index cbcb169f211be16066eabddf007ed853b0cfcae3..8589cd510c1f9a9bd0ff4be1689425c23922c1c1 100644 |
| --- a/chrome/browser/push_messaging/background_budget_service.cc |
| +++ b/chrome/browser/push_messaging/background_budget_service.cc |
| @@ -129,6 +129,12 @@ double BackgroundBudgetService::GetBudget(const GURL& origin) { |
| base::Time now = clock_->Now(); |
| base::TimeDelta elapsed = now - base::Time::FromDoubleT(last_updated_msec); |
| + // The user can set their clock backwards, so if the last updated time is in |
| + // the future, don't update the budget based on elapsed time. Eventually the |
| + // clock will reach the future, and the budget calculations will catch up. |
| + if (elapsed.InMicroseconds() < 0) |
|
johnme
2016/06/01 18:24:38
Conversely, the clock may jump forwards a lot, e.g
harkness
2016/06/02 10:06:34
Done.
|
| + return old_budget; |
| + |
| // For each time period that elapses, calculate the carryover ratio as the |
| // ratio of time remaining in our max period to the total period. |
| // The carryover component is then the old budget multiplied by the ratio. |