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

Unified Diff: chrome/browser/engagement/site_engagement_score.h

Issue 2082953002: Prevent site engagement scores from decaying when Chrome isn't in use. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/engagement/site_engagement_score.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/engagement/site_engagement_score.h
diff --git a/chrome/browser/engagement/site_engagement_score.h b/chrome/browser/engagement/site_engagement_score.h
index 8a1b0a7eb53aa8fb88502a949afc567b89cc6ebc..8fd9a3a274d0aa947cec64846df4c953b49c4bc4 100644
--- a/chrome/browser/engagement/site_engagement_score.h
+++ b/chrome/browser/engagement/site_engagement_score.h
@@ -62,6 +62,18 @@ class SiteEngagementScore {
MEDIUM_ENGAGEMENT_BOUNDARY,
HIGH_ENGAGEMENT_BOUNDARY,
+ // The maximum number of decays that a SiteEngagementScore can incur before
+ // entering a grace period. MAX_DECAYS_PER_SCORE * DECAY_PERIOD_IN_DAYS is
+ // the max decay period, i.e. the maximum duration permitted for
+ // (clock_->Now() - score.last_engagement_time()).
+ MAX_DECAYS_PER_SCORE,
+
+ // If a SiteEngagamentScore has not been accessed or updated for a period
+ // longer than the max decay period + LAST_ENGAGEMENT_GRACE_PERIOD_IN_HOURS
+ // (see above), its last engagement time will be reset to be max decay
+ // period prior to clock_->Now().
+ LAST_ENGAGEMENT_GRACE_PERIOD_IN_HOURS,
+
MAX_VARIATION
};
@@ -80,6 +92,8 @@ class SiteEngagementScore {
static double GetBootstrapPoints();
static double GetMediumEngagementBoundary();
static double GetHighEngagementBoundary();
+ static double GetMaxDecaysPerScore();
+ static double GetLastEngagementGracePeriodInHours();
// Update the default engagement settings via variations.
static void UpdateFromVariations(const char* param_name);
@@ -108,10 +122,7 @@ class SiteEngagementScore {
bool MaxPointsPerDayAdded() const;
// Resets the score to |points| and resets the daily point limit. If
- // |updated_time| is non-null, sets the last engagement time and last
- // shortcut launch time (if it is non-null) to |updated_time|. Otherwise, last
- // engagement time is set to the current time and last shortcut launch time is
- // left unchanged.
+ // |updated_time| is non-null, sets the last engagement time to that value.
void Reset(double points, const base::Time updated_time);
// Get/set the last time this origin was launched from an installed shortcut.
@@ -122,6 +133,14 @@ class SiteEngagementScore {
last_shortcut_launch_time_ = time;
}
+ // Get/set the last time this origin recorded an engagement change.
+ base::Time last_engagement_time() const {
+ return last_engagement_time_;
+ }
+ void set_last_engagement_time(const base::Time& time) {
+ last_engagement_time_ = time;
+ }
+
private:
FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, PartiallyEmptyDictionary);
FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, PopulatedDictionary);
« no previous file with comments | « no previous file | chrome/browser/engagement/site_engagement_score.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698