| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/usage_tracker.h" | 5 #include "storage/browser/quota/usage_tracker.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 } | 129 } |
| 130 | 130 |
| 131 void UsageTracker::UpdateUsageCache(QuotaClient::ID client_id, | 131 void UsageTracker::UpdateUsageCache(QuotaClient::ID client_id, |
| 132 const GURL& origin, | 132 const GURL& origin, |
| 133 int64_t delta) { | 133 int64_t delta) { |
| 134 ClientUsageTracker* client_tracker = GetClientTracker(client_id); | 134 ClientUsageTracker* client_tracker = GetClientTracker(client_id); |
| 135 DCHECK(client_tracker); | 135 DCHECK(client_tracker); |
| 136 client_tracker->UpdateUsageCache(origin, delta); | 136 client_tracker->UpdateUsageCache(origin, delta); |
| 137 } | 137 } |
| 138 | 138 |
| 139 int64_t UsageTracker::GetCachedUsage() const { | |
| 140 int64_t usage = 0; | |
| 141 for (const auto& client_id_and_tracker : client_tracker_map_) | |
| 142 usage += client_id_and_tracker.second->GetCachedUsage(); | |
| 143 return usage; | |
| 144 } | |
| 145 | |
| 146 void UsageTracker::GetCachedHostsUsage( | 139 void UsageTracker::GetCachedHostsUsage( |
| 147 std::map<std::string, int64_t>* host_usage) const { | 140 std::map<std::string, int64_t>* host_usage) const { |
| 148 DCHECK(host_usage); | 141 DCHECK(host_usage); |
| 149 host_usage->clear(); | 142 host_usage->clear(); |
| 150 for (const auto& client_id_and_tracker : client_tracker_map_) | 143 for (const auto& client_id_and_tracker : client_tracker_map_) |
| 151 client_id_and_tracker.second->GetCachedHostsUsage(host_usage); | 144 client_id_and_tracker.second->GetCachedHostsUsage(host_usage); |
| 152 } | 145 } |
| 153 | 146 |
| 154 void UsageTracker::GetCachedOriginsUsage( | 147 void UsageTracker::GetCachedOriginsUsage( |
| 155 std::map<GURL, int64_t>* origin_usage) const { | 148 std::map<GURL, int64_t>* origin_usage) const { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 // Defend against confusing inputs from clients. | 213 // Defend against confusing inputs from clients. |
| 221 if (info->usage < 0) | 214 if (info->usage < 0) |
| 222 info->usage = 0; | 215 info->usage = 0; |
| 223 | 216 |
| 224 // All the clients have returned their usage data. Dispatch the | 217 // All the clients have returned their usage data. Dispatch the |
| 225 // pending callbacks. | 218 // pending callbacks. |
| 226 host_usage_callbacks_.Run(host, info->usage); | 219 host_usage_callbacks_.Run(host, info->usage); |
| 227 } | 220 } |
| 228 | 221 |
| 229 } // namespace storage | 222 } // namespace storage |
| OLD | NEW |