Chromium Code Reviews| Index: chrome/browser/engagement/site_engagement_service.h |
| diff --git a/chrome/browser/engagement/site_engagement_service.h b/chrome/browser/engagement/site_engagement_service.h |
| index e7b3b6f3483c2ec68109cca1af364dde8e7d8def..3c57983619b66eb88529d483661bc405171dc5e2 100644 |
| --- a/chrome/browser/engagement/site_engagement_service.h |
| +++ b/chrome/browser/engagement/site_engagement_service.h |
| @@ -11,6 +11,7 @@ |
| #include "base/macros.h" |
| #include "base/memory/weak_ptr.h" |
| #include "base/time/time.h" |
| +#include "chrome/browser/engagement/site_engagement_metrics.h" |
| #include "components/keyed_service/core/keyed_service.h" |
| #include "ui/base/page_transition_types.h" |
| @@ -58,6 +59,10 @@ class SiteEngagementScore { |
| double Score() const; |
| void AddPoints(double points); |
| + // Returns true if the maximum number of points today has been added. Resets |
| + // the number of points added today if the day has changed. |
|
benwells
2015/10/02 01:33:25
Nit: you can delete the last sentence now.
dominickn
2015/10/02 04:54:50
Done.
|
| + bool MaxPointsPerDayAdded(); |
| + |
| // Updates the content settings dictionary |score_dict| with the current score |
| // fields. Returns true if |score_dict| changed, otherwise return false. |
| bool UpdateScoreDict(base::DictionaryValue* score_dict); |
| @@ -129,7 +134,8 @@ class SiteEngagementService : public KeyedService, |
| // Update the karma score of the origin matching |url| for time-on-site, based |
| // on user input. |
| - void HandleUserInput(const GURL& url); |
| + void HandleUserInput(const GURL& url, |
| + SiteEngagementMetrics::EngagementType type); |
| // Overridden from SiteEngagementScoreProvider: |
| double GetScore(const GURL& url) override; |
| @@ -137,6 +143,8 @@ class SiteEngagementService : public KeyedService, |
| private: |
| FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CleanupEngagementScores); |
| + FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, GetTotalNavigationPoints); |
| + FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, GetTotalUserInputPoints); |
| // Only used in tests. |
| SiteEngagementService(Profile* profile, scoped_ptr<base::Clock> clock); |
| @@ -145,13 +153,30 @@ class SiteEngagementService : public KeyedService, |
| // maximum limits for the day and overall. |
| void AddPoints(const GURL& url, double points); |
| + // Post startup tasks: cleaning up origins which have decayed to 0, and |
| + // logging UMA statistics. |
| + void AfterStartupTask(); |
| void CleanupEngagementScores(); |
| + void RecordMetrics(); |
| + |
| + // Returns the number of origins with maximum daily and total engagement |
| + // respectively. |
| + int OriginsWithMaxDailyEngagement(); |
| + int OriginsWithMaxEngagement(std::map<GURL, double>& score_map); |
| + |
|
benwells
2015/10/02 01:33:25
Nit: only one blank line.
dominickn
2015/10/02 04:54:50
Done.
|
| Profile* profile_; |
| // The clock used to vend times. |
| scoped_ptr<base::Clock> clock_; |
| + // Metrics are recorded at non-incognito browser startup, and then |
| + // approximately once per hour thereafter. Store the local time at which |
| + // metrics were previously uploaded: the first event which affects any |
| + // origin's engagement score after an hour has elapsed triggers the next |
| + // upload. |
| + base::Time last_metrics_time_; |
| + |
| base::WeakPtrFactory<SiteEngagementService> weak_factory_; |
| DISALLOW_COPY_AND_ASSIGN(SiteEngagementService); |