OLD | NEW |
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 <map> | 8 #include <map> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // The SiteEngagementService does not take ownership of |clock|. It is the | 50 // The SiteEngagementService does not take ownership of |clock|. It is the |
51 // responsibility of the caller to make sure |clock| outlives this | 51 // responsibility of the caller to make sure |clock| outlives this |
52 // SiteEngagementScore. | 52 // SiteEngagementScore. |
53 SiteEngagementScore(base::Clock* clock, | 53 SiteEngagementScore(base::Clock* clock, |
54 const base::DictionaryValue& score_dict); | 54 const base::DictionaryValue& score_dict); |
55 ~SiteEngagementScore(); | 55 ~SiteEngagementScore(); |
56 | 56 |
57 double Score() const; | 57 double Score() const; |
58 void AddPoints(double points); | 58 void AddPoints(double points); |
59 | 59 |
| 60 // Returns true if the maximum number of points today has been added. Resets |
| 61 // the number of points added today if the day has changed. |
| 62 bool MaxPointsPerDayAdded(); |
| 63 |
60 // Updates the content settings dictionary |score_dict| with the current score | 64 // Updates the content settings dictionary |score_dict| with the current score |
61 // fields. Returns true if |score_dict| changed, otherwise return false. | 65 // fields. Returns true if |score_dict| changed, otherwise return false. |
62 bool UpdateScoreDict(base::DictionaryValue* score_dict); | 66 bool UpdateScoreDict(base::DictionaryValue* score_dict); |
63 | 67 |
64 private: | 68 private: |
65 friend class SiteEngagementScoreTest; | 69 friend class SiteEngagementScoreTest; |
66 | 70 |
67 // This version of the constructor is used in unit tests. | 71 // This version of the constructor is used in unit tests. |
68 explicit SiteEngagementScore(base::Clock* clock); | 72 explicit SiteEngagementScore(base::Clock* clock); |
69 | 73 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 136 |
133 // Overridden from SiteEngagementScoreProvider: | 137 // Overridden from SiteEngagementScoreProvider: |
134 double GetScore(const GURL& url) override; | 138 double GetScore(const GURL& url) override; |
135 double GetTotalEngagementPoints() override; | 139 double GetTotalEngagementPoints() override; |
136 | 140 |
137 private: | 141 private: |
138 // Adds the specified number of points to the given origin, respecting the | 142 // Adds the specified number of points to the given origin, respecting the |
139 // maximum limits for the day and overall. | 143 // maximum limits for the day and overall. |
140 void AddPoints(const GURL& url, double points); | 144 void AddPoints(const GURL& url, double points); |
141 | 145 |
| 146 // Returns the number of origins with maximum daily and total engagement |
| 147 // respectively. |
| 148 int OriginsWithMaxDailyEngagement(); |
| 149 int OriginsWithMaxEngagement(); |
| 150 |
| 151 // Logs the total number of origins stored by the site engagement service, and |
| 152 // the total accumulated engagement score. |
| 153 void RecordStartupUmaStats(); |
| 154 |
142 Profile* profile_; | 155 Profile* profile_; |
143 | 156 |
144 // The clock used to vend times. | 157 // The clock used to vend times. |
145 base::DefaultClock clock_; | 158 base::DefaultClock clock_; |
146 | 159 |
147 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService); | 160 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService); |
148 }; | 161 }; |
149 | 162 |
150 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ | 163 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ |
OLD | NEW |