| 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 <algorithm> | 7 #include <algorithm> |
| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 } | 137 } |
| 138 | 138 |
| 139 void UsageTracker::GetCachedHostsUsage( | 139 void UsageTracker::GetCachedHostsUsage( |
| 140 std::map<std::string, int64>* host_usage) const { | 140 std::map<std::string, int64>* host_usage) const { |
| 141 DCHECK(host_usage); | 141 DCHECK(host_usage); |
| 142 host_usage->clear(); | 142 host_usage->clear(); |
| 143 for (const auto& client_id_and_tracker : client_tracker_map_) | 143 for (const auto& client_id_and_tracker : client_tracker_map_) |
| 144 client_id_and_tracker.second->GetCachedHostsUsage(host_usage); | 144 client_id_and_tracker.second->GetCachedHostsUsage(host_usage); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void UsageTracker::GetCachedOriginsUsage( |
| 148 std::map<GURL, int64>* origin_usage) const { |
| 149 DCHECK(origin_usage); |
| 150 origin_usage->clear(); |
| 151 for (const auto& client_id_and_tracker : client_tracker_map_) |
| 152 client_id_and_tracker.second->GetUsageForCachedOrigins(origin_usage); |
| 153 } |
| 154 |
| 147 void UsageTracker::GetCachedOrigins(std::set<GURL>* origins) const { | 155 void UsageTracker::GetCachedOrigins(std::set<GURL>* origins) const { |
| 148 DCHECK(origins); | 156 DCHECK(origins); |
| 149 origins->clear(); | 157 origins->clear(); |
| 150 for (const auto& client_id_and_tracker : client_tracker_map_) | 158 for (const auto& client_id_and_tracker : client_tracker_map_) |
| 151 client_id_and_tracker.second->GetCachedOrigins(origins); | 159 client_id_and_tracker.second->GetCachedOrigins(origins); |
| 152 } | 160 } |
| 153 | 161 |
| 154 void UsageTracker::SetUsageCacheEnabled(QuotaClient::ID client_id, | 162 void UsageTracker::SetUsageCacheEnabled(QuotaClient::ID client_id, |
| 155 const GURL& origin, | 163 const GURL& origin, |
| 156 bool enabled) { | 164 bool enabled) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 // Defend against confusing inputs from clients. | 213 // Defend against confusing inputs from clients. |
| 206 if (info->usage < 0) | 214 if (info->usage < 0) |
| 207 info->usage = 0; | 215 info->usage = 0; |
| 208 | 216 |
| 209 // All the clients have returned their usage data. Dispatch the | 217 // All the clients have returned their usage data. Dispatch the |
| 210 // pending callbacks. | 218 // pending callbacks. |
| 211 host_usage_callbacks_.Run(host, info->usage); | 219 host_usage_callbacks_.Run(host, info->usage); |
| 212 } | 220 } |
| 213 | 221 |
| 214 } // namespace storage | 222 } // namespace storage |
| OLD | NEW |