OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 NET_DISK_CACHE_BLOCKFILE_STATS_H_ | 5 #ifndef NET_DISK_CACHE_BLOCKFILE_STATS_H_ |
6 #define NET_DISK_CACHE_BLOCKFILE_STATS_H_ | 6 #define NET_DISK_CACHE_BLOCKFILE_STATS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "net/disk_cache/blockfile/addr.h" | 12 #include "net/disk_cache/blockfile/addr.h" |
13 #include "net/disk_cache/blockfile/stats_histogram.h" | |
14 | 13 |
15 namespace base { | 14 namespace base { |
16 class HistogramSamples; | 15 class HistogramSamples; |
17 } // namespace base | 16 } // namespace base |
18 | 17 |
19 namespace disk_cache { | 18 namespace disk_cache { |
20 | 19 |
21 typedef std::vector<std::pair<std::string, std::string> > StatsItems; | 20 typedef std::vector<std::pair<std::string, std::string> > StatsItems; |
22 | 21 |
23 // This class stores cache-specific usage information, for tunning purposes. | 22 // This class stores cache-specific usage information, for tunning purposes. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 int GetResurrectRatio() const; | 75 int GetResurrectRatio() const; |
77 void ResetRatios(); | 76 void ResetRatios(); |
78 | 77 |
79 // Returns the lower bound of the space used by entries bigger than 512 KB. | 78 // Returns the lower bound of the space used by entries bigger than 512 KB. |
80 int GetLargeEntriesSize(); | 79 int GetLargeEntriesSize(); |
81 | 80 |
82 // Writes the stats into |data|, to be stored at the given cache address. | 81 // Writes the stats into |data|, to be stored at the given cache address. |
83 // Returns the number of bytes copied. | 82 // Returns the number of bytes copied. |
84 int SerializeStats(void* data, int num_bytes, Addr* address); | 83 int SerializeStats(void* data, int num_bytes, Addr* address); |
85 | 84 |
86 // Support for StatsHistograms. Together, these methods allow StatsHistograms | 85 private: |
87 // to take a snapshot of the data_sizes_ as the histogram data. | 86 // Supports generation of SizeStats histogram data. |
88 int GetBucketRange(size_t i) const; | 87 int GetBucketRange(size_t i) const; |
89 void Snapshot(base::HistogramSamples* samples) const; | |
90 | |
91 private: | |
92 int GetStatsBucket(int32 size); | 88 int GetStatsBucket(int32 size); |
93 int GetRatio(Counters hit, Counters miss) const; | 89 int GetRatio(Counters hit, Counters miss) const; |
94 | 90 |
95 Addr storage_addr_; | 91 Addr storage_addr_; |
96 int data_sizes_[kDataSizesLength]; | 92 int data_sizes_[kDataSizesLength]; |
97 int64 counters_[MAX_COUNTER]; | 93 int64 counters_[MAX_COUNTER]; |
98 StatsHistogram* size_histogram_; | |
99 | 94 |
100 DISALLOW_COPY_AND_ASSIGN(Stats); | 95 DISALLOW_COPY_AND_ASSIGN(Stats); |
101 }; | 96 }; |
102 | 97 |
103 } // namespace disk_cache | 98 } // namespace disk_cache |
104 | 99 |
105 #endif // NET_DISK_CACHE_BLOCKFILE_STATS_H_ | 100 #endif // NET_DISK_CACHE_BLOCKFILE_STATS_H_ |
OLD | NEW |