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_STATS_H_ | 5 #ifndef NET_DISK_CACHE_STATS_H_ |
6 #define NET_DISK_CACHE_STATS_H_ | 6 #define NET_DISK_CACHE_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/stats_histogram.h" | 12 #include "net/disk_cache/stats_histogram.h" |
13 | 13 |
| 14 namespace base { |
| 15 class HistogramSamples; |
| 16 } // namespace base |
| 17 |
14 namespace disk_cache { | 18 namespace disk_cache { |
15 | 19 |
16 class BackendImpl; | 20 class BackendImpl; |
17 | 21 |
18 typedef std::vector<std::pair<std::string, std::string> > StatsItems; | 22 typedef std::vector<std::pair<std::string, std::string> > StatsItems; |
19 | 23 |
20 // This class stores cache-specific usage information, for tunning purposes. | 24 // This class stores cache-specific usage information, for tunning purposes. |
21 class Stats { | 25 class Stats { |
22 public: | 26 public: |
23 static const int kDataSizesLength = 28; | 27 static const int kDataSizesLength = 28; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 71 |
68 // Returns the lower bound of the space used by entries bigger than 512 KB. | 72 // Returns the lower bound of the space used by entries bigger than 512 KB. |
69 int GetLargeEntriesSize(); | 73 int GetLargeEntriesSize(); |
70 | 74 |
71 // Saves the stats to disk. | 75 // Saves the stats to disk. |
72 void Store(); | 76 void Store(); |
73 | 77 |
74 // Support for StatsHistograms. Together, these methods allow StatsHistograms | 78 // Support for StatsHistograms. Together, these methods allow StatsHistograms |
75 // to take a snapshot of the data_sizes_ as the histogram data. | 79 // to take a snapshot of the data_sizes_ as the histogram data. |
76 int GetBucketRange(size_t i) const; | 80 int GetBucketRange(size_t i) const; |
77 void Snapshot(StatsHistogram::StatsSamples* samples) const; | 81 void Snapshot(base::HistogramSamples* samples) const; |
78 | 82 |
79 private: | 83 private: |
80 int GetStatsBucket(int32 size); | 84 int GetStatsBucket(int32 size); |
81 int GetRatio(Counters hit, Counters miss) const; | 85 int GetRatio(Counters hit, Counters miss) const; |
82 | 86 |
83 BackendImpl* backend_; | 87 BackendImpl* backend_; |
84 uint32 storage_addr_; | 88 uint32 storage_addr_; |
85 int data_sizes_[kDataSizesLength]; | 89 int data_sizes_[kDataSizesLength]; |
86 int64 counters_[MAX_COUNTER]; | 90 int64 counters_[MAX_COUNTER]; |
87 StatsHistogram* size_histogram_; | 91 StatsHistogram* size_histogram_; |
88 | 92 |
89 DISALLOW_COPY_AND_ASSIGN(Stats); | 93 DISALLOW_COPY_AND_ASSIGN(Stats); |
90 }; | 94 }; |
91 | 95 |
92 } // namespace disk_cache | 96 } // namespace disk_cache |
93 | 97 |
94 #endif // NET_DISK_CACHE_STATS_H_ | 98 #endif // NET_DISK_CACHE_STATS_H_ |
OLD | NEW |