Chromium Code Reviews| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 | 132 |
| 129 // Update the karma score of the origin matching |url| for time-on-site, based | 133 // Update the karma score of the origin matching |url| for time-on-site, based |
| 130 // on user input. | 134 // on user input. |
| 131 void HandleUserInput(const GURL& url); | 135 void HandleUserInput(const GURL& url); |
| 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: |
| 142 // Adds the specified number of points to the given origin, respecting the | |
| 143 // maximum limits for the day and overall. | |
|
calamity
2015/09/25 07:08:33
nit: This should be moved into the previous CL but
dominickn
2015/09/28 03:34:50
Done.
| |
| 138 void AddPoints(const GURL& url, double points); | 144 void AddPoints(const GURL& url, double points); |
| 139 | 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 | |
| 140 Profile* profile_; | 155 Profile* profile_; |
| 141 | 156 |
| 142 // The clock used to vend times. | 157 // The clock used to vend times. |
| 143 base::DefaultClock clock_; | 158 base::DefaultClock clock_; |
| 144 | 159 |
| 145 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService); | 160 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService); |
| 146 }; | 161 }; |
| 147 | 162 |
| 148 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ | 163 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ |
| OLD | NEW |