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

Issue 2427343002: Make the site engagement service more robust to clock changes and time inconsistencies. (Closed)

Created:
4 years, 2 months ago by dominickn
Modified:
4 years, 2 months ago
Reviewers:
benwells
CC:
chromium-reviews, dominickn+watch_chromium.org, kcarattini, chrome-apps-syd-reviews_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Make the site engagement service more robust to clock changes and time inconsistencies. This CL adjusts the site engagement service's logic for rebasing last engagement times when no engagement has been earned for some time. This code was prone to errors when users changed their clocks, where last engagement times could be moved into the future or into the past based on a clock change. This has only recently become an issue because the rebasing codepath now triggers if no engagement is earned for ~9 hours, as opposed to three weeks. The code was also brittle if the overall last engagement time (a lossy pref) became out of sync with any single engagement score's last engagement time (a lossy content setting). It is theoretically possible that the content setting would be written to prefs, but the overall last engagement time would not due to the prefs system buffering the lossy write and then failing to complete it before browser shutdown. This CL changes the rebase logic to also sanely handle unexpected times caused by changing clocks or pref writing race conditions. Time rebasing now occurs when the last engagement time is detected to be in the future as well as in the past. Regression tests are added to ensure the correct behaviour. BUG=654560 Committed: https://crrev.com/ed64b2a6aaeb060283ca5583abc1583a879b1ce1 Cr-Commit-Position: refs/heads/master@{#426696}

Patch Set 1 #

Total comments: 1

Patch Set 2 : Handle last engagement in the future as well #

Patch Set 3 : Cap last_engagement_time at now #

Total comments: 2

Patch Set 4 : Address nit #

Unified diffs Side-by-side diffs Delta from patch set Stats (+161 lines, -20 lines) Patch
M chrome/browser/engagement/site_engagement_service.h View 1 chunk +4 lines, -0 lines 0 comments Download
M chrome/browser/engagement/site_engagement_service.cc View 1 2 3 3 chunks +44 lines, -20 lines 0 comments Download
M chrome/browser/engagement/site_engagement_service_unittest.cc View 1 2 1 chunk +113 lines, -0 lines 0 comments Download

Messages

Total messages: 30 (22 generated)
dominickn
PTAL, thanks!
4 years, 2 months ago (2016-10-19 04:05:12 UTC) #5
benwells
https://codereview.chromium.org/2427343002/diff/1/chrome/browser/engagement/site_engagement_service_unittest.cc File chrome/browser/engagement/site_engagement_service_unittest.cc (right): https://codereview.chromium.org/2427343002/diff/1/chrome/browser/engagement/site_engagement_service_unittest.cc#newcode1524 chrome/browser/engagement/site_engagement_service_unittest.cc:1524: clock->SetNow(before_stale_period); What would happen if CleanupEngagementScores(true) was called now? ...
4 years, 2 months ago (2016-10-19 23:54:06 UTC) #8
dominickn
PTAL, thanks! The code now allows CleanupEngagementScores to run if last_engagement_time is in the future, ...
4 years, 2 months ago (2016-10-20 06:11:00 UTC) #14
benwells
lgtm https://codereview.chromium.org/2427343002/diff/40001/chrome/browser/engagement/site_engagement_service.cc File chrome/browser/engagement/site_engagement_service.cc (right): https://codereview.chromium.org/2427343002/diff/40001/chrome/browser/engagement/site_engagement_service.cc#newcode307 chrome/browser/engagement/site_engagement_service.cc:307: DCHECK(!update_last_engagement_time || ((last_engagement_time >= now) || Nit: So ...
4 years, 2 months ago (2016-10-20 07:14:43 UTC) #19
dominickn
Thanks! https://codereview.chromium.org/2427343002/diff/40001/chrome/browser/engagement/site_engagement_service.cc File chrome/browser/engagement/site_engagement_service.cc (right): https://codereview.chromium.org/2427343002/diff/40001/chrome/browser/engagement/site_engagement_service.cc#newcode307 chrome/browser/engagement/site_engagement_service.cc:307: DCHECK(!update_last_engagement_time || ((last_engagement_time >= now) || On 2016/10/20 ...
4 years, 2 months ago (2016-10-21 00:03:25 UTC) #21
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2427343002/60001
4 years, 2 months ago (2016-10-21 02:13:48 UTC) #27
commit-bot: I haz the power
Committed patchset #4 (id:60001)
4 years, 2 months ago (2016-10-21 02:26:21 UTC) #28
commit-bot: I haz the power
4 years, 2 months ago (2016-10-21 13:26:20 UTC) #30
Message was sent while issue was closed.
Patchset 4 (id:??) landed as
https://crrev.com/ed64b2a6aaeb060283ca5583abc1583a879b1ce1
Cr-Commit-Position: refs/heads/master@{#426696}

Powered by Google App Engine
This is Rietveld 408576698