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

Side by Side Diff: storage/browser/quota/client_usage_tracker.cc

Issue 1343273003: Integrate SiteEngagementEvictionPolicy with QuotaManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_eviction_policy
Patch Set: address comments 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
« no previous file with comments | « storage/browser/quota/client_usage_tracker.h ('k') | storage/browser/quota/quota_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "storage/browser/quota/client_usage_tracker.h" 5 #include "storage/browser/quota/client_usage_tracker.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "net/base/net_util.h" 9 #include "net/base/net_util.h"
10 #include "storage/browser/quota/storage_monitor.h" 10 #include "storage/browser/quota/storage_monitor.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // We don't know about this host yet, so populate our cache for it. 162 // We don't know about this host yet, so populate our cache for it.
163 GetHostUsage(host, base::Bind(&ClientUsageTracker::DidGetHostUsageAfterUpdate, 163 GetHostUsage(host, base::Bind(&ClientUsageTracker::DidGetHostUsageAfterUpdate,
164 AsWeakPtr(), origin)); 164 AsWeakPtr(), origin));
165 } 165 }
166 166
167 void ClientUsageTracker::GetCachedHostsUsage( 167 void ClientUsageTracker::GetCachedHostsUsage(
168 std::map<std::string, int64>* host_usage) const { 168 std::map<std::string, int64>* host_usage) const {
169 DCHECK(host_usage); 169 DCHECK(host_usage);
170 for (const auto& host_and_usage_map : cached_usage_by_host_) { 170 for (const auto& host_and_usage_map : cached_usage_by_host_) {
171 const std::string& host = host_and_usage_map.first; 171 const std::string& host = host_and_usage_map.first;
172 LOG(ERROR) << host;
raymes 2015/09/23 01:56:14 nit: remove this
calamity 2015/09/23 02:15:56 Done.
172 (*host_usage)[host] += GetCachedHostUsage(host); 173 (*host_usage)[host] += GetCachedHostUsage(host);
173 } 174 }
174 } 175 }
175 176
177 void ClientUsageTracker::GetUsageForCachedOrigins(
178 std::map<GURL, int64>* origin_usage) const {
179 DCHECK(origin_usage);
180 for (const auto& host_and_usage_map : cached_usage_by_host_) {
181 for (const auto& origin_and_usage : host_and_usage_map.second)
182 (*origin_usage)[origin_and_usage.first] += origin_and_usage.second;
183 }
184 }
185
176 void ClientUsageTracker::GetCachedOrigins(std::set<GURL>* origins) const { 186 void ClientUsageTracker::GetCachedOrigins(std::set<GURL>* origins) const {
177 DCHECK(origins); 187 DCHECK(origins);
178 for (const auto& host_and_usage_map : cached_usage_by_host_) { 188 for (const auto& host_and_usage_map : cached_usage_by_host_) {
179 for (const auto& origin_and_usage : host_and_usage_map.second) 189 for (const auto& origin_and_usage : host_and_usage_map.second)
180 origins->insert(origin_and_usage.first); 190 origins->insert(origin_and_usage.first);
181 } 191 }
182 } 192 }
183 193
184 void ClientUsageTracker::SetUsageCacheEnabled(const GURL& origin, 194 void ClientUsageTracker::SetUsageCacheEnabled(const GURL& origin,
185 bool enabled) { 195 bool enabled) {
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 } 461 }
452 462
453 bool ClientUsageTracker::IsStorageUnlimited(const GURL& origin) const { 463 bool ClientUsageTracker::IsStorageUnlimited(const GURL& origin) const {
454 if (type_ == kStorageTypeSyncable) 464 if (type_ == kStorageTypeSyncable)
455 return false; 465 return false;
456 return special_storage_policy_.get() && 466 return special_storage_policy_.get() &&
457 special_storage_policy_->IsStorageUnlimited(origin); 467 special_storage_policy_->IsStorageUnlimited(origin);
458 } 468 }
459 469
460 } // namespace storage 470 } // namespace storage
OLDNEW
« no previous file with comments | « storage/browser/quota/client_usage_tracker.h ('k') | storage/browser/quota/quota_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698