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

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

Issue 1427913002: Implement media playing engagement detection for the site engagement service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@user-input-event
Patch Set: Addressing nits Created 5 years, 1 month 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 <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
(...skipping 20 matching lines...) Expand all
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 std::map<GURL, double> GetScoreMap(); 150 std::map<GURL, double> GetScoreMap();
143 151
144 // Update the karma score of the origin matching |url| for navigation. 152 // Update the karma score of the origin matching |url| for navigation.
145 void HandleNavigation(const GURL& url, ui::PageTransition transition); 153 void HandleNavigation(const GURL& url, ui::PageTransition transition);
146 154
147 // Update the karma score of the origin matching |url| for time-on-site, based 155 // Update the karma score of the origin matching |url| for time-on-site, based
148 // on user input. 156 // on user input.
149 void HandleUserInput(const GURL& url, 157 void HandleUserInput(const GURL& url,
150 SiteEngagementMetrics::EngagementType type); 158 SiteEngagementMetrics::EngagementType type);
151 159
160 // Update the karma score of the origin matching |url| for media playing. The
161 // points awarded are discounted if the media is being played in a non-visible
162 // tab.
163 void HandleMediaPlaying(const GURL& url, bool is_hidden);
164
152 // Overridden from SiteEngagementScoreProvider: 165 // Overridden from SiteEngagementScoreProvider:
153 double GetScore(const GURL& url) override; 166 double GetScore(const GURL& url) override;
154 double GetTotalEngagementPoints() override; 167 double GetTotalEngagementPoints() override;
155 168
156 private: 169 private:
157 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CheckHistograms); 170 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CheckHistograms);
158 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CleanupEngagementScores); 171 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CleanupEngagementScores);
159 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, ClearHistoryForURLs); 172 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, ClearHistoryForURLs);
160 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, GetMedianEngagement); 173 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, GetMedianEngagement);
161 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, GetTotalNavigationPoints); 174 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, GetTotalNavigationPoints);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // origin's engagement score after an hour has elapsed triggers the next 206 // origin's engagement score after an hour has elapsed triggers the next
194 // upload. 207 // upload.
195 base::Time last_metrics_time_; 208 base::Time last_metrics_time_;
196 209
197 base::WeakPtrFactory<SiteEngagementService> weak_factory_; 210 base::WeakPtrFactory<SiteEngagementService> weak_factory_;
198 211
199 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService); 212 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService);
200 }; 213 };
201 214
202 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ 215 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/engagement/site_engagement_metrics.h ('k') | chrome/browser/engagement/site_engagement_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698