OLD | NEW |
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" |
5 #include "chrome/browser/browser_process.h" | 8 #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" | 9 #include "chrome/browser/engagement/site_engagement_service.h" |
8 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
| 12 #include "chrome/common/chrome_switches.h" |
10 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
11 | 14 |
12 namespace { | 15 namespace { |
13 | 16 |
14 const int kExpectedEngagementSites = 200; | 17 const int kExpectedEngagementSites = 200; |
15 | 18 |
16 // Gets the quota that an origin deserves based on its site engagement. | 19 // Gets the quota that an origin deserves based on its site engagement. |
17 int64 GetSoftQuotaForOrigin(const GURL& origin, | 20 int64 GetSoftQuotaForOrigin(const GURL& origin, |
18 int score, | 21 int score, |
19 int total_engagement_points, | 22 int total_engagement_points, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 87 |
85 if (!score_provider) | 88 if (!score_provider) |
86 return GURL(); | 89 return GURL(); |
87 | 90 |
88 return DoCalculateEvictionOrigin(special_storage_policy, score_provider, | 91 return DoCalculateEvictionOrigin(special_storage_policy, score_provider, |
89 exceptions, usage_map, global_quota); | 92 exceptions, usage_map, global_quota); |
90 } | 93 } |
91 | 94 |
92 } // namespace | 95 } // namespace |
93 | 96 |
| 97 // static |
| 98 bool SiteEngagementEvictionPolicy::IsEnabled() { |
| 99 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 100 switches::kEnableSiteEngagementEvictionPolicy); |
| 101 } |
| 102 |
94 SiteEngagementEvictionPolicy::SiteEngagementEvictionPolicy( | 103 SiteEngagementEvictionPolicy::SiteEngagementEvictionPolicy( |
95 content::BrowserContext* browser_context) | 104 content::BrowserContext* browser_context) |
96 : browser_context_(browser_context) {} | 105 : browser_context_(browser_context) {} |
97 | 106 |
98 SiteEngagementEvictionPolicy::~SiteEngagementEvictionPolicy() {} | 107 SiteEngagementEvictionPolicy::~SiteEngagementEvictionPolicy() {} |
99 | 108 |
100 void SiteEngagementEvictionPolicy::GetEvictionOrigin( | 109 void SiteEngagementEvictionPolicy::GetEvictionOrigin( |
101 const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy, | 110 const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy, |
102 const std::set<GURL>& exceptions, | 111 const std::set<GURL>& exceptions, |
103 const std::map<GURL, int64>& usage_map, | 112 const std::map<GURL, int64>& usage_map, |
(...skipping 12 matching lines...) Expand all Loading... |
116 // static | 125 // static |
117 GURL SiteEngagementEvictionPolicy::CalculateEvictionOriginForTests( | 126 GURL SiteEngagementEvictionPolicy::CalculateEvictionOriginForTests( |
118 const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy, | 127 const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy, |
119 SiteEngagementScoreProvider* score_provider, | 128 SiteEngagementScoreProvider* score_provider, |
120 const std::set<GURL>& exceptions, | 129 const std::set<GURL>& exceptions, |
121 const std::map<GURL, int64>& usage_map, | 130 const std::map<GURL, int64>& usage_map, |
122 int64 global_quota) { | 131 int64 global_quota) { |
123 return DoCalculateEvictionOrigin(special_storage_policy, score_provider, | 132 return DoCalculateEvictionOrigin(special_storage_policy, score_provider, |
124 exceptions, usage_map, global_quota); | 133 exceptions, usage_map, global_quota); |
125 } | 134 } |
OLD | NEW |