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 |
5 #include "base/barrier_closure.h" | 7 #include "base/barrier_closure.h" |
| 8 #include "base/command_line.h" |
6 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
7 #include "chrome/browser/engagement/site_engagement_eviction_policy.h" | |
8 #include "chrome/browser/engagement/site_engagement_service.h" | 10 #include "chrome/browser/engagement/site_engagement_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
| 13 #include "chrome/common/chrome_switches.h" |
11 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
12 #include "storage/browser/quota/usage_tracker.h" | 15 #include "storage/browser/quota/usage_tracker.h" |
13 | 16 |
14 namespace { | 17 namespace { |
15 | 18 |
16 base::Callback<SiteEngagementScoreProvider*(content::BrowserContext*)>* | 19 base::Callback<SiteEngagementScoreProvider*(content::BrowserContext*)>* |
17 g_test_score_provider_callback = nullptr; | 20 g_test_score_provider_callback = nullptr; |
18 | 21 |
19 const int kExpectedEngagementSites = 200; | 22 const int kExpectedEngagementSites = 200; |
20 | 23 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 98 |
96 if (!score_provider) | 99 if (!score_provider) |
97 return GURL(); | 100 return GURL(); |
98 | 101 |
99 return DoCalculateEvictionOrigin(special_storage_policy, score_provider, | 102 return DoCalculateEvictionOrigin(special_storage_policy, score_provider, |
100 exceptions, usage_map, global_quota); | 103 exceptions, usage_map, global_quota); |
101 } | 104 } |
102 | 105 |
103 } // namespace | 106 } // namespace |
104 | 107 |
| 108 // static |
| 109 bool SiteEngagementEvictionPolicy::IsEnabled() { |
| 110 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 111 switches::kEnableSiteEngagementEvictionPolicy); |
| 112 } |
| 113 |
105 SiteEngagementEvictionPolicy::SiteEngagementEvictionPolicy( | 114 SiteEngagementEvictionPolicy::SiteEngagementEvictionPolicy( |
106 storage::StorageType type, | 115 storage::StorageType type, |
107 storage::QuotaManager* manager, | 116 storage::QuotaManager* manager, |
108 content::BrowserContext* browser_context) | 117 content::BrowserContext* browser_context) |
109 : type_(type), | 118 : type_(type), |
110 manager_(manager), | 119 manager_(manager), |
111 browser_context_(browser_context), | 120 browser_context_(browser_context), |
112 global_quota_(0), | 121 global_quota_(0), |
113 remaining_tasks_(0), | 122 remaining_tasks_(0), |
114 weak_factory_(this) {} | 123 weak_factory_(this) {} |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 // static | 188 // static |
180 GURL SiteEngagementEvictionPolicy::CalculateEvictionOriginForTests( | 189 GURL SiteEngagementEvictionPolicy::CalculateEvictionOriginForTests( |
181 const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy, | 190 const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy, |
182 SiteEngagementScoreProvider* score_provider, | 191 SiteEngagementScoreProvider* score_provider, |
183 const std::set<GURL>& exceptions, | 192 const std::set<GURL>& exceptions, |
184 const std::map<GURL, int64>& usage_map, | 193 const std::map<GURL, int64>& usage_map, |
185 int64 global_quota) { | 194 int64 global_quota) { |
186 return DoCalculateEvictionOrigin(special_storage_policy, score_provider, | 195 return DoCalculateEvictionOrigin(special_storage_policy, score_provider, |
187 exceptions, usage_map, global_quota); | 196 exceptions, usage_map, global_quota); |
188 } | 197 } |
OLD | NEW |