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 16 matching lines...) Expand all Loading... |
27 const double kUsageRatioToStartEviction = 0.7; | 27 const double kUsageRatioToStartEviction = 0.7; |
28 const int kThresholdOfErrorsToStopEviction = 5; | 28 const int kThresholdOfErrorsToStopEviction = 5; |
29 const int kHistogramReportIntervalMinutes = 60; | 29 const int kHistogramReportIntervalMinutes = 60; |
30 } | 30 } |
31 | 31 |
32 namespace quota { | 32 namespace quota { |
33 | 33 |
34 const int QuotaTemporaryStorageEvictor:: | 34 const int QuotaTemporaryStorageEvictor:: |
35 kMinAvailableDiskSpaceToStartEvictionNotSpecified = -1; | 35 kMinAvailableDiskSpaceToStartEvictionNotSpecified = -1; |
36 | 36 |
| 37 QuotaTemporaryStorageEvictor::EvictionRoundStatistics::EvictionRoundStatistics() |
| 38 : in_round(false), |
| 39 is_initialized(false), |
| 40 usage_overage_at_round(-1), |
| 41 diskspace_shortage_at_round(-1), |
| 42 usage_on_beginning_of_round(-1), |
| 43 usage_on_end_of_round(-1), |
| 44 num_evicted_origins_in_round(0) { |
| 45 } |
| 46 |
37 QuotaTemporaryStorageEvictor::QuotaTemporaryStorageEvictor( | 47 QuotaTemporaryStorageEvictor::QuotaTemporaryStorageEvictor( |
38 QuotaEvictionHandler* quota_eviction_handler, | 48 QuotaEvictionHandler* quota_eviction_handler, |
39 int64 interval_ms) | 49 int64 interval_ms) |
40 : min_available_disk_space_to_start_eviction_( | 50 : min_available_disk_space_to_start_eviction_( |
41 kMinAvailableDiskSpaceToStartEvictionNotSpecified), | 51 kMinAvailableDiskSpaceToStartEvictionNotSpecified), |
42 quota_eviction_handler_(quota_eviction_handler), | 52 quota_eviction_handler_(quota_eviction_handler), |
43 interval_ms_(interval_ms), | 53 interval_ms_(interval_ms), |
44 repeated_eviction_(true), | 54 repeated_eviction_(true), |
45 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 55 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
46 DCHECK(quota_eviction_handler); | 56 DCHECK(quota_eviction_handler); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 ++statistics_.num_errors_on_evicting_origin; | 254 ++statistics_.num_errors_on_evicting_origin; |
245 if (repeated_eviction_) { | 255 if (repeated_eviction_) { |
246 // Sleep for a while and retry again until we see too many errors. | 256 // Sleep for a while and retry again until we see too many errors. |
247 StartEvictionTimerWithDelay(interval_ms_); | 257 StartEvictionTimerWithDelay(interval_ms_); |
248 } | 258 } |
249 OnEvictionRoundFinished(); | 259 OnEvictionRoundFinished(); |
250 } | 260 } |
251 } | 261 } |
252 | 262 |
253 } // namespace quota | 263 } // namespace quota |
OLD | NEW |