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

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

Issue 1363523003: Enable SiteEngagementEvictionPolicy behind --enable-site-eviction-policy flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lru_policy_gooood
Patch Set: Created 5 years, 1 month 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_eviction_policy.h"
6
7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h"
9 #include "base/strings/string_util.h"
5 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
6 #include "chrome/browser/engagement/site_engagement_eviction_policy.h"
7 #include "chrome/browser/engagement/site_engagement_service.h" 11 #include "chrome/browser/engagement/site_engagement_service.h"
8 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/common/chrome_switches.h"
10 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
11 16
12 namespace { 17 namespace {
13 18
14 const int kExpectedEngagementSites = 200; 19 const int kExpectedEngagementSites = 200;
15 20
16 // Gets the quota that an origin deserves based on its site engagement. 21 // Gets the quota that an origin deserves based on its site engagement.
17 int64 GetSoftQuotaForOrigin(const GURL& origin, 22 int64 GetSoftQuotaForOrigin(const GURL& origin,
18 int score, 23 int score,
19 int total_engagement_points, 24 int total_engagement_points,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 89
85 if (!score_provider) 90 if (!score_provider)
86 return GURL(); 91 return GURL();
87 92
88 return DoCalculateEvictionOrigin(special_storage_policy, score_provider, 93 return DoCalculateEvictionOrigin(special_storage_policy, score_provider,
89 exceptions, usage_map, global_quota); 94 exceptions, usage_map, global_quota);
90 } 95 }
91 96
92 } // namespace 97 } // namespace
93 98
99 // static
100 bool SiteEngagementEvictionPolicy::IsEnabled() {
101 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
102 switches::kEnableSiteEngagementEvictionPolicy)) {
103 return true;
104 }
105
106 const std::string group_name = base::FieldTrialList::FindFullName(
107 SiteEngagementService::kEngagementParams);
108 return base::StartsWith(group_name, "StorageEvictionEnabled",
109 base::CompareCase::SENSITIVE);
110 }
111
94 SiteEngagementEvictionPolicy::SiteEngagementEvictionPolicy( 112 SiteEngagementEvictionPolicy::SiteEngagementEvictionPolicy(
95 content::BrowserContext* browser_context) 113 content::BrowserContext* browser_context)
96 : browser_context_(browser_context) {} 114 : browser_context_(browser_context) {}
97 115
98 SiteEngagementEvictionPolicy::~SiteEngagementEvictionPolicy() {} 116 SiteEngagementEvictionPolicy::~SiteEngagementEvictionPolicy() {}
99 117
100 void SiteEngagementEvictionPolicy::GetEvictionOrigin( 118 void SiteEngagementEvictionPolicy::GetEvictionOrigin(
101 const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy, 119 const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy,
102 const std::set<GURL>& exceptions, 120 const std::set<GURL>& exceptions,
103 const std::map<GURL, int64>& usage_map, 121 const std::map<GURL, int64>& usage_map,
(...skipping 12 matching lines...) Expand all
116 // static 134 // static
117 GURL SiteEngagementEvictionPolicy::CalculateEvictionOriginForTests( 135 GURL SiteEngagementEvictionPolicy::CalculateEvictionOriginForTests(
118 const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy, 136 const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy,
119 SiteEngagementScoreProvider* score_provider, 137 SiteEngagementScoreProvider* score_provider,
120 const std::set<GURL>& exceptions, 138 const std::set<GURL>& exceptions,
121 const std::map<GURL, int64>& usage_map, 139 const std::map<GURL, int64>& usage_map,
122 int64 global_quota) { 140 int64 global_quota) {
123 return DoCalculateEvictionOrigin(special_storage_policy, score_provider, 141 return DoCalculateEvictionOrigin(special_storage_policy, score_provider,
124 exceptions, usage_map, global_quota); 142 exceptions, usage_map, global_quota);
125 } 143 }
OLDNEW
« no previous file with comments | « chrome/browser/engagement/site_engagement_eviction_policy.h ('k') | chrome/browser/engagement/site_engagement_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698