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

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

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

Powered by Google App Engine
This is Rietveld 408576698