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

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

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 #include "chrome/browser/engagement/site_engagement_service.h" 5 #include "chrome/browser/engagement/site_engagement_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/time/clock.h" 11 #include "base/time/clock.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/engagement/site_engagement_eviction_policy.h"
13 #include "chrome/browser/engagement/site_engagement_helper.h" 14 #include "chrome/browser/engagement/site_engagement_helper.h"
14 #include "chrome/browser/engagement/site_engagement_service_factory.h" 15 #include "chrome/browser/engagement/site_engagement_service_factory.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
17 #include "components/content_settings/core/browser/host_content_settings_map.h" 18 #include "components/content_settings/core/browser/host_content_settings_map.h"
18 #include "components/content_settings/core/common/content_settings_pattern.h" 19 #include "components/content_settings/core/common/content_settings_pattern.h"
19 #include "url/gurl.h" 20 #include "url/gurl.h"
20 21
21 namespace { 22 namespace {
22 23
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 151 }
151 152
152 // static 153 // static
153 SiteEngagementService* SiteEngagementService::Get(Profile* profile) { 154 SiteEngagementService* SiteEngagementService::Get(Profile* profile) {
154 return SiteEngagementServiceFactory::GetForProfile(profile); 155 return SiteEngagementServiceFactory::GetForProfile(profile);
155 } 156 }
156 157
157 // static 158 // static
158 bool SiteEngagementService::IsEnabled() { 159 bool SiteEngagementService::IsEnabled() {
159 return base::CommandLine::ForCurrentProcess()->HasSwitch( 160 return base::CommandLine::ForCurrentProcess()->HasSwitch(
160 switches::kEnableSiteEngagementService); 161 switches::kEnableSiteEngagementService) ||
162 SiteEngagementEvictionPolicy::IsEnabled();
161 } 163 }
162 164
163 SiteEngagementService::SiteEngagementService(Profile* profile) 165 SiteEngagementService::SiteEngagementService(Profile* profile)
164 : profile_(profile) { 166 : profile_(profile),
165 } 167 site_engagement_eviction_policy_(
168 new SiteEngagementEvictionPolicy(profile)) {}
raymes 2015/09/01 06:52:52 Should SiteEngagementService depend on SiteEngagem
calamity 2015/09/04 05:44:21 Forgot to put in the enable condition. What do yo
166 169
167 SiteEngagementService::~SiteEngagementService() { 170 SiteEngagementService::~SiteEngagementService() {
168 } 171 }
169 172
170 void SiteEngagementService::HandleNavigation(const GURL& url) { 173 void SiteEngagementService::HandleNavigation(const GURL& url) {
171 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); 174 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap();
172 scoped_ptr<base::DictionaryValue> score_dict = 175 scoped_ptr<base::DictionaryValue> score_dict =
173 GetScoreDictForOrigin(settings_map, url); 176 GetScoreDictForOrigin(settings_map, url);
174 SiteEngagementScore score(&clock_, *score_dict); 177 SiteEngagementScore score(&clock_, *score_dict);
175 178
(...skipping 30 matching lines...) Expand all
206 if (!origin.is_valid()) 209 if (!origin.is_valid())
207 continue; 210 continue;
208 211
209 scoped_ptr<base::DictionaryValue> score_dict = 212 scoped_ptr<base::DictionaryValue> score_dict =
210 GetScoreDictForOrigin(settings_map, origin); 213 GetScoreDictForOrigin(settings_map, origin);
211 SiteEngagementScore score(&clock_, *score_dict); 214 SiteEngagementScore score(&clock_, *score_dict);
212 total_score += score.Score(); 215 total_score += score.Score();
213 } 216 }
214 return total_score; 217 return total_score;
215 } 218 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698