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

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

Issue 1321733004: Use the site engagement eviction policy for temporary storage eviction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_eviction_policy
Patch Set: Created 5 years, 3 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 "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/time/default_clock.h" 11 #include "base/time/default_clock.h"
11 #include "base/time/time.h" 12 #include "base/time/time.h"
12 #include "components/keyed_service/core/keyed_service.h" 13 #include "components/keyed_service/core/keyed_service.h"
13 14
14 namespace base { 15 namespace base {
15 class DictionaryValue; 16 class DictionaryValue;
16 } 17 }
17 18
18 class GURL; 19 class GURL;
19 class Profile; 20 class Profile;
21 class SiteEngagementEvictionPolicy;
20 22
21 class SiteEngagementScore { 23 class SiteEngagementScore {
22 public: 24 public:
23 // Keys used in the content settings dictionary. 25 // Keys used in the content settings dictionary.
24 static const char* kRawScoreKey; 26 static const char* kRawScoreKey;
25 static const char* kPointsAddedTodayKey; 27 static const char* kPointsAddedTodayKey;
26 static const char* kLastEngagementTimeKey; 28 static const char* kLastEngagementTimeKey;
27 29
28 // The maximum number of points that are allowed. 30 // The maximum number of points that are allowed.
29 static const double kMaxPoints; 31 static const double kMaxPoints;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // 103 //
102 // Positive user activity, such as visiting the origin often and adding it to 104 // Positive user activity, such as visiting the origin often and adding it to
103 // the homescreen, will increase the site engagement score. Negative activity, 105 // the homescreen, will increase the site engagement score. Negative activity,
104 // such as rejecting permission prompts or not responding to notifications, will 106 // such as rejecting permission prompts or not responding to notifications, will
105 // decrease the site engagement score. 107 // decrease the site engagement score.
106 class SiteEngagementService : public KeyedService, 108 class SiteEngagementService : public KeyedService,
107 public SiteEngagementScoreProvider { 109 public SiteEngagementScoreProvider {
108 public: 110 public:
109 static SiteEngagementService* Get(Profile* profile); 111 static SiteEngagementService* Get(Profile* profile);
110 112
111 // Returns whether or not the SiteEngagementService is enabled. 113 // Returns whether or not the SiteEngagementService is enabled. Enabling
114 // dependent features will cause this to return true.
112 static bool IsEnabled(); 115 static bool IsEnabled();
113 116
114 explicit SiteEngagementService(Profile* profile); 117 explicit SiteEngagementService(Profile* profile);
115 ~SiteEngagementService() override; 118 ~SiteEngagementService() override;
116 119
117 // Update the karma score of the origin matching |url| for user navigation. 120 // Update the karma score of the origin matching |url| for user navigation.
118 void HandleNavigation(const GURL& url); 121 void HandleNavigation(const GURL& url);
119 122
123 SiteEngagementEvictionPolicy* site_engagement_eviction_policy() {
124 return site_engagement_eviction_policy_.get();
125 }
126
120 // Overridden from SiteEngagementScoreProvider: 127 // Overridden from SiteEngagementScoreProvider:
121 int GetScore(const GURL& url) override; 128 int GetScore(const GURL& url) override;
122 int GetTotalEngagementPoints() override; 129 int GetTotalEngagementPoints() override;
123 130
124 private: 131 private:
125 Profile* profile_; 132 Profile* profile_;
126 133
134 scoped_ptr<SiteEngagementEvictionPolicy> site_engagement_eviction_policy_;
135
127 // The clock used to vend times. 136 // The clock used to vend times.
128 base::DefaultClock clock_; 137 base::DefaultClock clock_;
129 138
130 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService); 139 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService);
131 }; 140 };
132 141
133 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ 142 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/engagement/site_engagement_eviction_policy.cc ('k') | chrome/browser/engagement/site_engagement_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698