Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: webkit/quota/quota_temporary_storage_evictor.cc

Issue 8775031: Remove static initializer from quota_temporary_storage_evictor.cc (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
12 #include "webkit/quota/quota_manager.h" 12 #include "webkit/quota/quota_manager.h"
13 13
14 #define UMA_HISTOGRAM_MBYTES(name, sample) \ 14 #define UMA_HISTOGRAM_MBYTES(name, sample) \
15 UMA_HISTOGRAM_CUSTOM_COUNTS( \ 15 UMA_HISTOGRAM_CUSTOM_COUNTS( \
16 (name), static_cast<int>((sample) / kMBytes), \ 16 (name), static_cast<int>((sample) / kMBytes), \
17 1, 10 * 1024 * 1024 /* 10TB */, 100) 17 1, 10 * 1024 * 1024 /* 10TB */, 100)
18 18
19 #define UMA_HISTOGRAM_MINUTES(name, sample) \ 19 #define UMA_HISTOGRAM_MINUTES(name, sample) \
20 UMA_HISTOGRAM_CUSTOM_TIMES( \ 20 UMA_HISTOGRAM_CUSTOM_TIMES( \
21 (name), (sample), \ 21 (name), (sample), \
22 base::TimeDelta::FromMinutes(1), \ 22 base::TimeDelta::FromMinutes(1), \
23 base::TimeDelta::FromDays(1), 50) 23 base::TimeDelta::FromDays(1), 50)
24 24
25 namespace { 25 namespace {
26 const int64 kMBytes = 1024 * 1024; 26 const int64 kMBytes = 1024 * 1024;
27 const double kUsageRatioToStartEviction = 0.7; 27 const double kUsageRatioToStartEviction = 0.7;
28 const int kThresholdOfErrorsToStopEviction = 5; 28 const int kThresholdOfErrorsToStopEviction = 5;
29 const base::TimeDelta kHistogramReportInterval = 29 const int kHistogramReportIntervalMinutes = 60;
30 base::TimeDelta::FromMilliseconds(60 * 60 * 1000); // 1 hour
31 } 30 }
32 31
33 namespace quota { 32 namespace quota {
34 33
35 const int QuotaTemporaryStorageEvictor:: 34 const int QuotaTemporaryStorageEvictor::
36 kMinAvailableDiskSpaceToStartEvictionNotSpecified = -1; 35 kMinAvailableDiskSpaceToStartEvictionNotSpecified = -1;
37 36
38 QuotaTemporaryStorageEvictor::QuotaTemporaryStorageEvictor( 37 QuotaTemporaryStorageEvictor::QuotaTemporaryStorageEvictor(
39 QuotaEvictionHandler* quota_eviction_handler, 38 QuotaEvictionHandler* quota_eviction_handler,
40 int64 interval_ms) 39 int64 interval_ms)
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // Reset stats for next round. 122 // Reset stats for next round.
124 round_statistics_ = EvictionRoundStatistics(); 123 round_statistics_ = EvictionRoundStatistics();
125 } 124 }
126 125
127 void QuotaTemporaryStorageEvictor::Start() { 126 void QuotaTemporaryStorageEvictor::Start() {
128 DCHECK(CalledOnValidThread()); 127 DCHECK(CalledOnValidThread());
129 StartEvictionTimerWithDelay(0); 128 StartEvictionTimerWithDelay(0);
130 129
131 if (histogram_timer_.IsRunning()) 130 if (histogram_timer_.IsRunning())
132 return; 131 return;
133 histogram_timer_.Start(FROM_HERE, kHistogramReportInterval, this, 132
134 &QuotaTemporaryStorageEvictor::ReportPerHourHistogram); 133 histogram_timer_.Start(
134 FROM_HERE, base::TimeDelta::FromMinutes(kHistogramReportIntervalMinutes),
135 this, &QuotaTemporaryStorageEvictor::ReportPerHourHistogram);
135 } 136 }
136 137
137 void QuotaTemporaryStorageEvictor::StartEvictionTimerWithDelay(int delay_ms) { 138 void QuotaTemporaryStorageEvictor::StartEvictionTimerWithDelay(int delay_ms) {
138 if (eviction_timer_.IsRunning()) 139 if (eviction_timer_.IsRunning())
139 return; 140 return;
140 eviction_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(delay_ms), 141 eviction_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(delay_ms),
141 this, &QuotaTemporaryStorageEvictor::ConsiderEviction); 142 this, &QuotaTemporaryStorageEvictor::ConsiderEviction);
142 } 143 }
143 144
144 void QuotaTemporaryStorageEvictor::ConsiderEviction() { 145 void QuotaTemporaryStorageEvictor::ConsiderEviction() {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 ++statistics_.num_errors_on_evicting_origin; 244 ++statistics_.num_errors_on_evicting_origin;
244 if (repeated_eviction_) { 245 if (repeated_eviction_) {
245 // Sleep for a while and retry again until we see too many errors. 246 // Sleep for a while and retry again until we see too many errors.
246 StartEvictionTimerWithDelay(interval_ms_); 247 StartEvictionTimerWithDelay(interval_ms_);
247 } 248 }
248 OnEvictionRoundFinished(); 249 OnEvictionRoundFinished();
249 } 250 }
250 } 251 }
251 252
252 } // namespace quota 253 } // namespace quota
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698