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

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

Issue 7582027: Refine UMA stats of QuotaTemporaryStorageEvictor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 4 months 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 | webkit/quota/quota_temporary_storage_evictor.cc » ('j') | 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 #ifndef WEBKIT_QUOTA_QUOTA_TEMPORARY_STORAGE_EVICTOR_H_ 5 #ifndef WEBKIT_QUOTA_QUOTA_TEMPORARY_STORAGE_EVICTOR_H_
6 #define WEBKIT_QUOTA_QUOTA_TEMPORARY_STORAGE_EVICTOR_H_ 6 #define WEBKIT_QUOTA_QUOTA_TEMPORARY_STORAGE_EVICTOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 20 matching lines...) Expand all
31 : num_errors_on_evicting_origin(0), 31 : num_errors_on_evicting_origin(0),
32 num_errors_on_getting_usage_and_quota(0), 32 num_errors_on_getting_usage_and_quota(0),
33 num_evicted_origins(0), 33 num_evicted_origins(0),
34 num_eviction_rounds(0), 34 num_eviction_rounds(0),
35 num_skipped_eviction_rounds(0) {} 35 num_skipped_eviction_rounds(0) {}
36 int64 num_errors_on_evicting_origin; 36 int64 num_errors_on_evicting_origin;
37 int64 num_errors_on_getting_usage_and_quota; 37 int64 num_errors_on_getting_usage_and_quota;
38 int64 num_evicted_origins; 38 int64 num_evicted_origins;
39 int64 num_eviction_rounds; 39 int64 num_eviction_rounds;
40 int64 num_skipped_eviction_rounds; 40 int64 num_skipped_eviction_rounds;
41
42 Statistics& operator -=(const Statistics& rhs) {
kinuko 2011/08/12 03:57:45 As we chatted locally, unfortunately operator over
tzik 2011/08/12 07:12:06 Done.
43 num_errors_on_evicting_origin -= rhs.num_errors_on_evicting_origin;
44 num_errors_on_getting_usage_and_quota -=
45 rhs.num_errors_on_getting_usage_and_quota;
46 num_evicted_origins -= rhs.num_evicted_origins;
47 num_eviction_rounds -= rhs.num_eviction_rounds;
48 num_skipped_eviction_rounds -= rhs.num_skipped_eviction_rounds;
49 return *this;
50 }
51 };
52
53 struct EvictionRoundStatistics {
54 EvictionRoundStatistics()
55 : started(false),
56 amount_of_usage_overage(-1),
57 amount_of_diskspace_shortage(-1),
58 usage_on_beginning_of_round(-1),
59 usage_on_end_of_round(-1),
60 num_evicted_origins(0) {
61 }
62
63 void put_usage_overage(int64 overage) {
Dai Mikurube (NOT FULLTIME) 2011/08/12 04:19:03 Maybe "set" looks better?
tzik 2011/08/12 07:12:06 As we chatted, I added |is_initialized| flag. So w
64 if (amount_of_usage_overage < 0)
65 amount_of_usage_overage = overage;
66 }
67
68 void put_diskspace_shortage(int64 diskspace_shortage) {
69 if (amount_of_diskspace_shortage < 0)
70 amount_of_diskspace_shortage = diskspace_shortage;
71 }
72
73 void put_usage(int64 usage) {
74 if (usage_on_beginning_of_round < 0)
75 usage_on_beginning_of_round = usage;
76 usage_on_end_of_round = usage;
77 }
78
79 bool started;
80
81 base::Time start_time;
82 int64 amount_of_usage_overage;
83 int64 amount_of_diskspace_shortage;
Dai Mikurube (NOT FULLTIME) 2011/08/12 04:19:03 In my understanding, overage and shortage include
tzik 2011/08/12 07:12:06 Done. I feel, "in this round" sounds as if the sho
Dai Mikurube (NOT FULLTIME) 2011/08/12 07:32:39 Sounds good.
84
85 int64 usage_on_beginning_of_round;
86 int64 usage_on_end_of_round;
87 int64 num_evicted_origins;
Dai Mikurube (NOT FULLTIME) 2011/08/12 04:19:03 Adding "in_round" could be better though it looks
tzik 2011/08/12 07:12:06 Done.
41 }; 88 };
42 89
43 QuotaTemporaryStorageEvictor( 90 QuotaTemporaryStorageEvictor(
44 QuotaEvictionHandler* quota_eviction_handler, 91 QuotaEvictionHandler* quota_eviction_handler,
45 int64 interval_ms); 92 int64 interval_ms);
46 virtual ~QuotaTemporaryStorageEvictor(); 93 virtual ~QuotaTemporaryStorageEvictor();
47 94
48 void GetStatistics(std::map<std::string, int64>* statistics); 95 void GetStatistics(std::map<std::string, int64>* statistics);
49 void ReportHistogram(); 96 void ReportPerRoundHistogram();
97 void ReportPerHourHistogram();
50 void Start(); 98 void Start();
51 99
52 private: 100 private:
53 friend class QuotaTemporaryStorageEvictorTest; 101 friend class QuotaTemporaryStorageEvictorTest;
54 102
55 void StartEvictionTimerWithDelay(int delay_ms); 103 void StartEvictionTimerWithDelay(int delay_ms);
56 void ConsiderEviction(); 104 void ConsiderEviction();
57 void OnGotUsageAndQuotaForEviction( 105 void OnGotUsageAndQuotaForEviction(
58 QuotaStatusCode status, 106 QuotaStatusCode status,
59 int64 usage, 107 int64 usage,
60 int64 unlimited_usage, 108 int64 unlimited_usage,
61 int64 quota, 109 int64 quota,
62 int64 available_disk_space); 110 int64 available_disk_space);
63 void OnGotLRUOrigin(const GURL& origin); 111 void OnGotLRUOrigin(const GURL& origin);
64 void OnEvictionComplete(QuotaStatusCode status); 112 void OnEvictionComplete(QuotaStatusCode status);
65 113
114 void OnEvictionRoundStarted();
115 void OnEvictionRoundFinished();
116
66 // This is only used for tests. 117 // This is only used for tests.
67 void set_repeated_eviction(bool repeated_eviction) { 118 void set_repeated_eviction(bool repeated_eviction) {
68 repeated_eviction_ = repeated_eviction; 119 repeated_eviction_ = repeated_eviction;
69 } 120 }
70 121
71 static const double kUsageRatioToStartEviction; 122 static const double kUsageRatioToStartEviction;
72 static const int64 kDefaultMinAvailableDiskSpaceToStartEviction; 123 static const int64 kDefaultMinAvailableDiskSpaceToStartEviction;
73 static const int kThresholdOfErrorsToStopEviction; 124 static const int kThresholdOfErrorsToStopEviction;
74 static const base::TimeDelta kHistogramReportInterval; 125 static const base::TimeDelta kHistogramReportInterval;
75 126
76 const int64 min_available_disk_space_to_start_eviction_; 127 const int64 min_available_disk_space_to_start_eviction_;
77 128
78 // Not owned; quota_eviction_handler owns us. 129 // Not owned; quota_eviction_handler owns us.
79 QuotaEvictionHandler* quota_eviction_handler_; 130 QuotaEvictionHandler* quota_eviction_handler_;
80 131
81 Statistics statistics_; 132 Statistics statistics_, reported_hourly_statistics_;
Dai Mikurube (NOT FULLTIME) 2011/08/12 04:19:03 Declare them in two lines. Does reported_hourly_s
tzik 2011/08/12 07:12:06 Done.
133 EvictionRoundStatistics round_statistics_;
134 base::Time time_of_last_nonskipped_round_;
Dai Mikurube (NOT FULLTIME) 2011/08/12 04:19:03 Does this "time" point the beginning of last non-s
tzik 2011/08/12 07:12:06 Done.
135 base::Time time_of_end_of_last_round_;
82 136
83 int64 interval_ms_; 137 int64 interval_ms_;
84 bool repeated_eviction_; 138 bool repeated_eviction_;
85 int num_evicted_origins_in_round_;
86
87 int64 usage_on_beginning_of_round_;
88 base::Time time_of_beginning_of_round_;
89 base::Time time_of_end_of_last_round_;
90 139
91 base::OneShotTimer<QuotaTemporaryStorageEvictor> eviction_timer_; 140 base::OneShotTimer<QuotaTemporaryStorageEvictor> eviction_timer_;
92 base::RepeatingTimer<QuotaTemporaryStorageEvictor> histogram_timer_; 141 base::RepeatingTimer<QuotaTemporaryStorageEvictor> histogram_timer_;
93 142
94 base::ScopedCallbackFactory<QuotaTemporaryStorageEvictor> callback_factory_; 143 base::ScopedCallbackFactory<QuotaTemporaryStorageEvictor> callback_factory_;
95 144
96 DISALLOW_COPY_AND_ASSIGN(QuotaTemporaryStorageEvictor); 145 DISALLOW_COPY_AND_ASSIGN(QuotaTemporaryStorageEvictor);
97 }; 146 };
98 147
99 } // namespace quota 148 } // namespace quota
100 149
101 #endif // WEBKIT_QUOTA_QUOTA_TEMPORARY_STORAGE_EVICTOR_H_ 150 #endif // WEBKIT_QUOTA_QUOTA_TEMPORARY_STORAGE_EVICTOR_H_
OLDNEW
« no previous file with comments | « no previous file | webkit/quota/quota_temporary_storage_evictor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698