OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/quota/quota_temporary_storage_evictor.h" | 5 #include "webkit/quota/quota_temporary_storage_evictor.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 quota_eviction_handler_->GetUsageAndQuotaForEviction( | 159 quota_eviction_handler_->GetUsageAndQuotaForEviction( |
160 base::Bind(&QuotaTemporaryStorageEvictor::OnGotUsageAndQuotaForEviction, | 160 base::Bind(&QuotaTemporaryStorageEvictor::OnGotUsageAndQuotaForEviction, |
161 weak_factory_.GetWeakPtr())); | 161 weak_factory_.GetWeakPtr())); |
162 } | 162 } |
163 | 163 |
164 void QuotaTemporaryStorageEvictor::OnGotUsageAndQuotaForEviction( | 164 void QuotaTemporaryStorageEvictor::OnGotUsageAndQuotaForEviction( |
165 QuotaStatusCode status, | 165 QuotaStatusCode status, |
166 const UsageAndQuota& qau) { | 166 const UsageAndQuota& qau) { |
167 DCHECK(CalledOnValidThread()); | 167 DCHECK(CalledOnValidThread()); |
168 | 168 |
169 // unlimited_usage is a subset of usage | 169 int64 usage = qau.global_limited_usage; |
170 DCHECK_GE(qau.global_usage, qau.global_unlimited_usage); | 170 DCHECK_GE(usage, 0); |
171 | |
172 int64 usage = qau.global_usage - qau.global_unlimited_usage; | |
173 | 171 |
174 if (status != kQuotaStatusOk) | 172 if (status != kQuotaStatusOk) |
175 ++statistics_.num_errors_on_getting_usage_and_quota; | 173 ++statistics_.num_errors_on_getting_usage_and_quota; |
176 | 174 |
177 int64 usage_overage = std::max( | 175 int64 usage_overage = std::max( |
178 static_cast<int64>(0), | 176 static_cast<int64>(0), |
179 usage - static_cast<int64>(qau.quota * kUsageRatioToStartEviction)); | 177 usage - static_cast<int64>(qau.quota * kUsageRatioToStartEviction)); |
180 | 178 |
181 // min_available_disk_space_to_start_eviction_ might be < 0 if no value | 179 // min_available_disk_space_to_start_eviction_ might be < 0 if no value |
182 // is explicitly configured yet. | 180 // is explicitly configured yet. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 ++statistics_.num_errors_on_evicting_origin; | 252 ++statistics_.num_errors_on_evicting_origin; |
255 if (repeated_eviction_) { | 253 if (repeated_eviction_) { |
256 // Sleep for a while and retry again until we see too many errors. | 254 // Sleep for a while and retry again until we see too many errors. |
257 StartEvictionTimerWithDelay(interval_ms_); | 255 StartEvictionTimerWithDelay(interval_ms_); |
258 } | 256 } |
259 OnEvictionRoundFinished(); | 257 OnEvictionRoundFinished(); |
260 } | 258 } |
261 } | 259 } |
262 | 260 |
263 } // namespace quota | 261 } // namespace quota |
OLD | NEW |