| OLD | NEW |
| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 storage_monitor_->NotifyUsageChange(filter, delta); | 158 storage_monitor_->NotifyUsageChange(filter, delta); |
| 159 } | 159 } |
| 160 return; | 160 return; |
| 161 } | 161 } |
| 162 | 162 |
| 163 // We don't know about this host yet, so populate our cache for it. | 163 // We don't know about this host yet, so populate our cache for it. |
| 164 GetHostUsage(host, base::Bind(&ClientUsageTracker::DidGetHostUsageAfterUpdate, | 164 GetHostUsage(host, base::Bind(&ClientUsageTracker::DidGetHostUsageAfterUpdate, |
| 165 AsWeakPtr(), origin)); | 165 AsWeakPtr(), origin)); |
| 166 } | 166 } |
| 167 | 167 |
| 168 int64_t ClientUsageTracker::GetCachedUsage() const { |
| 169 int64_t usage = 0; |
| 170 for (const auto& host_and_usage_map : cached_usage_by_host_) { |
| 171 for (const auto& origin_and_usage : host_and_usage_map.second) |
| 172 usage += origin_and_usage.second; |
| 173 } |
| 174 return usage; |
| 175 } |
| 176 |
| 168 void ClientUsageTracker::GetCachedHostsUsage( | 177 void ClientUsageTracker::GetCachedHostsUsage( |
| 169 std::map<std::string, int64_t>* host_usage) const { | 178 std::map<std::string, int64_t>* host_usage) const { |
| 170 DCHECK(host_usage); | 179 DCHECK(host_usage); |
| 171 for (const auto& host_and_usage_map : cached_usage_by_host_) { | 180 for (const auto& host_and_usage_map : cached_usage_by_host_) { |
| 172 const std::string& host = host_and_usage_map.first; | 181 const std::string& host = host_and_usage_map.first; |
| 173 (*host_usage)[host] += GetCachedHostUsage(host); | 182 (*host_usage)[host] += GetCachedHostUsage(host); |
| 174 } | 183 } |
| 175 } | 184 } |
| 176 | 185 |
| 177 void ClientUsageTracker::GetCachedOriginsUsage( | 186 void ClientUsageTracker::GetCachedOriginsUsage( |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 } | 469 } |
| 461 | 470 |
| 462 bool ClientUsageTracker::IsStorageUnlimited(const GURL& origin) const { | 471 bool ClientUsageTracker::IsStorageUnlimited(const GURL& origin) const { |
| 463 if (type_ == kStorageTypeSyncable) | 472 if (type_ == kStorageTypeSyncable) |
| 464 return false; | 473 return false; |
| 465 return special_storage_policy_.get() && | 474 return special_storage_policy_.get() && |
| 466 special_storage_policy_->IsStorageUnlimited(origin); | 475 special_storage_policy_->IsStorageUnlimited(origin); |
| 467 } | 476 } |
| 468 | 477 |
| 469 } // namespace storage | 478 } // namespace storage |
| OLD | NEW |