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

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

Issue 1207383006: Add GetTotalEngagementPoints to SiteEngagementService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 5 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/engagement/site_engagement_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/gtest_prod_util.h" 8 #include "base/gtest_prod_util.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 28 matching lines...) Expand all
39 // constant determines how often that happens. 39 // constant determines how often that happens.
40 static const int kDecayPeriodInDays; 40 static const int kDecayPeriodInDays;
41 41
42 // How much the score decays after every kDecayPeriodInDays. 42 // How much the score decays after every kDecayPeriodInDays.
43 static const double kDecayPoints; 43 static const double kDecayPoints;
44 44
45 // The SiteEngagementService does not take ownership of |clock|. It is the 45 // The SiteEngagementService does not take ownership of |clock|. It is the
46 // responsibility of the caller to make sure |clock| outlives this 46 // responsibility of the caller to make sure |clock| outlives this
47 // SiteEngagementScore. 47 // SiteEngagementScore.
48 SiteEngagementScore(base::Clock* clock, 48 SiteEngagementScore(base::Clock* clock,
49 const base::DictionaryValue& settings); 49 const base::DictionaryValue& score_dict);
50 ~SiteEngagementScore(); 50 ~SiteEngagementScore();
51 51
52 double Score() const; 52 double Score() const;
53 void AddPoints(double points); 53 void AddPoints(double points);
54 54
55 // Updates the content settings dictionary |settings| with the current score 55 // Updates the content settings dictionary |score_dict| with the current score
56 // fields. Returns true if |settings| changed, otherwise return false. 56 // fields. Returns true if |score_dict| changed, otherwise return false.
57 bool UpdateSettings(base::DictionaryValue* settings); 57 bool UpdateScoreDict(base::DictionaryValue* score_dict);
58 58
59 private: 59 private:
60 friend class SiteEngagementScoreTest; 60 friend class SiteEngagementScoreTest;
61 61
62 // This version of the constructor is used in unit tests. 62 // This version of the constructor is used in unit tests.
63 explicit SiteEngagementScore(base::Clock* clock); 63 explicit SiteEngagementScore(base::Clock* clock);
64 64
65 // Determine the score, accounting for any decay. 65 // Determine the score, accounting for any decay.
66 double DecayedScore() const; 66 double DecayedScore() const;
67 67
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 explicit SiteEngagementService(Profile* profile); 104 explicit SiteEngagementService(Profile* profile);
105 ~SiteEngagementService() override; 105 ~SiteEngagementService() override;
106 106
107 // Update the karma score of the origin matching |url| for user navigation. 107 // Update the karma score of the origin matching |url| for user navigation.
108 void HandleNavigation(const GURL& url); 108 void HandleNavigation(const GURL& url);
109 109
110 // Returns a non-negative integer representing the engagement score of the 110 // Returns a non-negative integer representing the engagement score of the
111 // origin for this URL. 111 // origin for this URL.
112 int GetScore(const GURL& url); 112 int GetScore(const GURL& url);
113 113
114 // Returns the sum of engagement points awarded to all sites.
115 int GetTotalEngagementPoints();
116
114 private: 117 private:
115 Profile* profile_; 118 Profile* profile_;
116 119
117 // The clock used to vend times. 120 // The clock used to vend times.
118 base::DefaultClock clock_; 121 base::DefaultClock clock_;
119 122
120 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService); 123 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService);
121 }; 124 };
122 125
123 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ 126 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/engagement/site_engagement_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698