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

Side by Side Diff: chrome/browser/engagement/site_engagement_service.h

Issue 1221523003: Add a SiteEngagementEvictionPolicy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@get_total_engagement_points
Patch Set: remove unnecessary destructor Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ 5 #ifndef CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_
6 #define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ 6 #define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_
7 7
8 #include "base/gtest_prod_util.h" 8 #include "base/gtest_prod_util.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/time/default_clock.h" 10 #include "base/time/default_clock.h"
12 #include "base/time/time.h" 11 #include "base/time/time.h"
13 #include "components/keyed_service/core/keyed_service.h" 12 #include "components/keyed_service/core/keyed_service.h"
14 13
15 namespace base { 14 namespace base {
16 class DictionaryValue; 15 class DictionaryValue;
17 } 16 }
18 17
19 class GURL; 18 class GURL;
20 class Profile; 19 class Profile;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 double points_added_today_; 76 double points_added_today_;
78 77
79 // The last time the score was updated for engagement. Used in conjunction 78 // The last time the score was updated for engagement. Used in conjunction
80 // with |points_added_today_| to avoid adding more than kMaxPointsPerDay on 79 // with |points_added_today_| to avoid adding more than kMaxPointsPerDay on
81 // any one day. 80 // any one day.
82 base::Time last_engagement_time_; 81 base::Time last_engagement_time_;
83 82
84 DISALLOW_COPY_AND_ASSIGN(SiteEngagementScore); 83 DISALLOW_COPY_AND_ASSIGN(SiteEngagementScore);
85 }; 84 };
86 85
86 class SiteEngagementScoreProvider {
87 public:
88 // Returns a non-negative integer representing the engagement score of the
89 // origin for this URL.
90 virtual int GetScore(const GURL& url) = 0;
91
92 // Returns the sum of engagement points awarded to all sites.
93 virtual int GetTotalEngagementPoints() = 0;
94 };
95
87 // Stores and retrieves the engagement score of an origin. 96 // Stores and retrieves the engagement score of an origin.
88 // 97 //
89 // An engagement score is a positive integer that represents how much a user has 98 // An engagement score is a positive integer that represents how much a user has
90 // engaged with an origin - the higher it is, the more engagement the user has 99 // engaged with an origin - the higher it is, the more engagement the user has
91 // had with this site recently. 100 // had with this site recently.
92 // 101 //
93 // Positive user activity, such as visiting the origin often and adding it to 102 // Positive user activity, such as visiting the origin often and adding it to
94 // the homescreen, will increase the site engagement score. Negative activity, 103 // the homescreen, will increase the site engagement score. Negative activity,
95 // such as rejecting permission prompts or not responding to notifications, will 104 // such as rejecting permission prompts or not responding to notifications, will
96 // decrease the site engagement score. 105 // decrease the site engagement score.
97 class SiteEngagementService : public KeyedService { 106 class SiteEngagementService : public KeyedService,
107 public SiteEngagementScoreProvider {
98 public: 108 public:
99 static SiteEngagementService* Get(Profile* profile); 109 static SiteEngagementService* Get(Profile* profile);
100 110
101 // Returns whether or not the SiteEngagementService is enabled. 111 // Returns whether or not the SiteEngagementService is enabled.
102 static bool IsEnabled(); 112 static bool IsEnabled();
103 113
104 explicit SiteEngagementService(Profile* profile); 114 explicit SiteEngagementService(Profile* profile);
105 ~SiteEngagementService() override; 115 ~SiteEngagementService() override;
106 116
107 // Update the karma score of the origin matching |url| for user navigation. 117 // Update the karma score of the origin matching |url| for user navigation.
108 void HandleNavigation(const GURL& url); 118 void HandleNavigation(const GURL& url);
109 119
110 // Returns a non-negative integer representing the engagement score of the 120 // Overridden from SiteEngagementScoreProvider:
111 // origin for this URL. 121 int GetScore(const GURL& url) override;
112 int GetScore(const GURL& url); 122 int GetTotalEngagementPoints() override;
113
114 // Returns the sum of engagement points awarded to all sites.
115 int GetTotalEngagementPoints();
116 123
117 private: 124 private:
118 Profile* profile_; 125 Profile* profile_;
119 126
120 // The clock used to vend times. 127 // The clock used to vend times.
121 base::DefaultClock clock_; 128 base::DefaultClock clock_;
122 129
123 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService); 130 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService);
124 }; 131 };
125 132
126 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ 133 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/engagement/site_engagement_eviction_policy_unittest.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698