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" | 5 #include "chrome/browser/engagement/site_engagement_eviction_policy.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 (special_storage_policy->IsStorageUnlimited(origin) || | 58 (special_storage_policy->IsStorageUnlimited(origin) || |
59 special_storage_policy->IsStorageDurable(origin))) { | 59 special_storage_policy->IsStorageDurable(origin))) { |
60 continue; | 60 continue; |
61 } | 61 } |
62 | 62 |
63 // |overuse| can be negative if the soft quota exceeds the usage. | 63 // |overuse| can be negative if the soft quota exceeds the usage. |
64 int64_t overuse = | 64 int64_t overuse = |
65 usage.second - | 65 usage.second - |
66 GetSoftQuotaForOrigin(origin, score_provider->GetScore(origin), | 66 GetSoftQuotaForOrigin(origin, score_provider->GetScore(origin), |
67 total_engagement_points, global_quota); | 67 total_engagement_points, global_quota); |
68 if (overuse > max_overuse && !ContainsKey(exceptions, origin)) { | 68 if (overuse > max_overuse && !base::ContainsKey(exceptions, origin)) { |
69 max_overuse = overuse; | 69 max_overuse = overuse; |
70 origin_to_evict = origin; | 70 origin_to_evict = origin; |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 return origin_to_evict; | 74 return origin_to_evict; |
75 } | 75 } |
76 | 76 |
77 GURL GetSiteEngagementEvictionOriginOnUIThread( | 77 GURL GetSiteEngagementEvictionOriginOnUIThread( |
78 const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy, | 78 const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // static | 135 // static |
136 GURL SiteEngagementEvictionPolicy::CalculateEvictionOriginForTests( | 136 GURL SiteEngagementEvictionPolicy::CalculateEvictionOriginForTests( |
137 const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy, | 137 const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy, |
138 SiteEngagementScoreProvider* score_provider, | 138 SiteEngagementScoreProvider* score_provider, |
139 const std::set<GURL>& exceptions, | 139 const std::set<GURL>& exceptions, |
140 const std::map<GURL, int64_t>& usage_map, | 140 const std::map<GURL, int64_t>& usage_map, |
141 int64_t global_quota) { | 141 int64_t global_quota) { |
142 return DoCalculateEvictionOrigin(special_storage_policy, score_provider, | 142 return DoCalculateEvictionOrigin(special_storage_policy, score_provider, |
143 exceptions, usage_map, global_quota); | 143 exceptions, usage_map, global_quota); |
144 } | 144 } |
OLD | NEW |