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 "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
9 #include "webkit/quota/quota_manager.h" | 9 #include "webkit/quota/quota_manager.h" |
10 | 10 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // Reset stats for next round. | 121 // Reset stats for next round. |
122 round_statistics_ = EvictionRoundStatistics(); | 122 round_statistics_ = EvictionRoundStatistics(); |
123 } | 123 } |
124 | 124 |
125 void QuotaTemporaryStorageEvictor::Start() { | 125 void QuotaTemporaryStorageEvictor::Start() { |
126 DCHECK(CalledOnValidThread()); | 126 DCHECK(CalledOnValidThread()); |
127 StartEvictionTimerWithDelay(0); | 127 StartEvictionTimerWithDelay(0); |
128 | 128 |
129 if (histogram_timer_.IsRunning()) | 129 if (histogram_timer_.IsRunning()) |
130 return; | 130 return; |
131 histogram_timer_.Start(FROM_HERE, kHistogramReportInterval, this, | 131 histogram_timer_.Start(kHistogramReportInterval, this, |
132 &QuotaTemporaryStorageEvictor::ReportPerHourHistogram); | 132 &QuotaTemporaryStorageEvictor::ReportPerHourHistogram); |
133 } | 133 } |
134 | 134 |
135 void QuotaTemporaryStorageEvictor::StartEvictionTimerWithDelay(int delay_ms) { | 135 void QuotaTemporaryStorageEvictor::StartEvictionTimerWithDelay(int delay_ms) { |
136 if (eviction_timer_.IsRunning()) | 136 if (eviction_timer_.IsRunning()) |
137 return; | 137 return; |
138 eviction_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(delay_ms), | 138 eviction_timer_.Start(base::TimeDelta::FromMilliseconds(delay_ms), this, |
139 this, &QuotaTemporaryStorageEvictor::ConsiderEviction); | 139 &QuotaTemporaryStorageEvictor::ConsiderEviction); |
140 } | 140 } |
141 | 141 |
142 void QuotaTemporaryStorageEvictor::ConsiderEviction() { | 142 void QuotaTemporaryStorageEvictor::ConsiderEviction() { |
143 OnEvictionRoundStarted(); | 143 OnEvictionRoundStarted(); |
144 | 144 |
145 // Get usage and disk space, then continue. | 145 // Get usage and disk space, then continue. |
146 quota_eviction_handler_->GetUsageAndQuotaForEviction(callback_factory_. | 146 quota_eviction_handler_->GetUsageAndQuotaForEviction(callback_factory_. |
147 NewCallback( | 147 NewCallback( |
148 &QuotaTemporaryStorageEvictor::OnGotUsageAndQuotaForEviction)); | 148 &QuotaTemporaryStorageEvictor::OnGotUsageAndQuotaForEviction)); |
149 } | 149 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 ++statistics_.num_errors_on_evicting_origin; | 238 ++statistics_.num_errors_on_evicting_origin; |
239 if (repeated_eviction_) { | 239 if (repeated_eviction_) { |
240 // Sleep for a while and retry again until we see too many errors. | 240 // Sleep for a while and retry again until we see too many errors. |
241 StartEvictionTimerWithDelay(interval_ms_); | 241 StartEvictionTimerWithDelay(interval_ms_); |
242 } | 242 } |
243 OnEvictionRoundFinished(); | 243 OnEvictionRoundFinished(); |
244 } | 244 } |
245 } | 245 } |
246 | 246 |
247 } // namespace quota | 247 } // namespace quota |
OLD | NEW |