| 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 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 // The maximum number of points that can be accrued in one day. | 32 // The maximum number of points that can be accrued in one day. |
| 33 static double g_max_points_per_day; | 33 static double g_max_points_per_day; |
| 34 | 34 |
| 35 // The number of points given for navigations. | 35 // The number of points given for navigations. |
| 36 static double g_navigation_points; | 36 static double g_navigation_points; |
| 37 | 37 |
| 38 // The number of points given for user input (indicating time-on-site). | 38 // The number of points given for user input (indicating time-on-site). |
| 39 static double g_user_input_points; | 39 static double g_user_input_points; |
| 40 | 40 |
| 41 // The number of points given for media playing. Initially calibrated such |
| 42 // that at least 30 minutes of video watching or audio listening would be |
| 43 // required to allow a site to reach the daily engagement maximum. |
| 44 static double g_visible_media_playing_points; |
| 45 |
| 46 // The number of points given for media playing in a non-visible tab. |
| 47 static double g_hidden_media_playing_points; |
| 48 |
| 41 // Decaying works by removing a portion of the score periodically. This | 49 // Decaying works by removing a portion of the score periodically. This |
| 42 // constant determines how often that happens. | 50 // constant determines how often that happens. |
| 43 static int g_decay_period_in_days; | 51 static int g_decay_period_in_days; |
| 44 | 52 |
| 45 // How much the score decays after every kDecayPeriodInDays. | 53 // How much the score decays after every kDecayPeriodInDays. |
| 46 static double g_decay_points; | 54 static double g_decay_points; |
| 47 | 55 |
| 48 // Update the default engagement settings via variations. | 56 // Update the default engagement settings via variations. |
| 49 static void UpdateFromVariations(); | 57 static void UpdateFromVariations(); |
| 50 | 58 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 std::map<GURL, double> GetScoreMap(); | 147 std::map<GURL, double> GetScoreMap(); |
| 140 | 148 |
| 141 // Update the karma score of the origin matching |url| for navigation. | 149 // Update the karma score of the origin matching |url| for navigation. |
| 142 void HandleNavigation(const GURL& url, ui::PageTransition transition); | 150 void HandleNavigation(const GURL& url, ui::PageTransition transition); |
| 143 | 151 |
| 144 // Update the karma score of the origin matching |url| for time-on-site, based | 152 // Update the karma score of the origin matching |url| for time-on-site, based |
| 145 // on user input. | 153 // on user input. |
| 146 void HandleUserInput(const GURL& url, | 154 void HandleUserInput(const GURL& url, |
| 147 SiteEngagementMetrics::EngagementType type); | 155 SiteEngagementMetrics::EngagementType type); |
| 148 | 156 |
| 157 // Update the karma score of the origin matching |url| for media playing. The |
| 158 // points awarded are discounted if the media is being played in a non-visible |
| 159 // tab. |
| 160 void HandleMediaPlaying(const GURL& url, bool is_hidden); |
| 161 |
| 149 // Overridden from SiteEngagementScoreProvider: | 162 // Overridden from SiteEngagementScoreProvider: |
| 150 double GetScore(const GURL& url) override; | 163 double GetScore(const GURL& url) override; |
| 151 double GetTotalEngagementPoints() override; | 164 double GetTotalEngagementPoints() override; |
| 152 | 165 |
| 153 private: | 166 private: |
| 154 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CheckHistograms); | 167 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CheckHistograms); |
| 155 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CleanupEngagementScores); | 168 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CleanupEngagementScores); |
| 156 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, ClearHistoryForURLs); | 169 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, ClearHistoryForURLs); |
| 157 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, GetMedianEngagement); | 170 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, GetMedianEngagement); |
| 158 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, GetTotalNavigationPoints); | 171 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, GetTotalNavigationPoints); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 // origin's engagement score after an hour has elapsed triggers the next | 203 // origin's engagement score after an hour has elapsed triggers the next |
| 191 // upload. | 204 // upload. |
| 192 base::Time last_metrics_time_; | 205 base::Time last_metrics_time_; |
| 193 | 206 |
| 194 base::WeakPtrFactory<SiteEngagementService> weak_factory_; | 207 base::WeakPtrFactory<SiteEngagementService> weak_factory_; |
| 195 | 208 |
| 196 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService); | 209 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService); |
| 197 }; | 210 }; |
| 198 | 211 |
| 199 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ | 212 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ |
| OLD | NEW |