OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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_HISTOGRAM_H_ | 5 #ifndef NET_DISK_CACHE_STATS_HISTOGRAM_H_ |
6 #define NET_DISK_CACHE_STATS_HISTOGRAM_H_ | 6 #define NET_DISK_CACHE_STATS_HISTOGRAM_H_ |
7 | 7 |
| 8 #include <string> |
| 9 |
8 #include "base/histogram.h" | 10 #include "base/histogram.h" |
9 | 11 |
10 namespace disk_cache { | 12 namespace disk_cache { |
11 | 13 |
12 class Stats; | 14 class Stats; |
13 | 15 |
14 // This class provides support for sending the disk cache size stats as a UMA | 16 // This class provides support for sending the disk cache size stats as a UMA |
15 // histogram. We'll provide our own storage and management for the data, and a | 17 // histogram. We'll provide our own storage and management for the data, and a |
16 // SampleSet with a copy of our data. | 18 // SampleSet with a copy of our data. |
| 19 // |
| 20 // Class derivation of Histogram "deprecated," and should not be copied, and |
| 21 // may eventually go away. |
| 22 // |
17 class StatsHistogram : public Histogram { | 23 class StatsHistogram : public Histogram { |
18 public: | 24 public: |
19 class StatsSamples : public SampleSet { | 25 class StatsSamples : public SampleSet { |
20 public: | 26 public: |
21 Counts* GetCounts() { | 27 Counts* GetCounts() { |
22 return &counts_; | 28 return &counts_; |
23 } | 29 } |
24 }; | 30 }; |
25 | 31 |
26 explicit StatsHistogram(const char* name) | 32 explicit StatsHistogram(const std::string& name, Sample minimum, |
27 : Histogram(name, 1, 1, 2), init_(false) {} | 33 Sample maximum, size_t bucket_count) |
| 34 : Histogram(name, minimum, maximum, bucket_count), init_(false) {} |
28 ~StatsHistogram(); | 35 ~StatsHistogram(); |
29 | 36 |
| 37 static scoped_refptr<StatsHistogram> |
| 38 StatsHistogramFactoryGet(const std::string& name); |
| 39 |
30 // We'll be reporting data from the given set of cache stats. | 40 // We'll be reporting data from the given set of cache stats. |
31 bool Init(const Stats* stats); | 41 bool Init(const Stats* stats); |
32 | 42 |
33 virtual Sample ranges(size_t i) const; | 43 virtual Sample ranges(size_t i) const; |
34 virtual size_t bucket_count() const; | 44 virtual size_t bucket_count() const; |
35 virtual void SnapshotSample(SampleSet* sample) const; | 45 virtual void SnapshotSample(SampleSet* sample) const; |
36 | 46 |
37 private: | 47 private: |
| 48 friend class Histogram; |
| 49 |
38 bool init_; | 50 bool init_; |
39 static const Stats* stats_; | 51 static const Stats* stats_; |
40 DISALLOW_COPY_AND_ASSIGN(StatsHistogram); | 52 DISALLOW_COPY_AND_ASSIGN(StatsHistogram); |
41 }; | 53 }; |
42 | 54 |
43 } // namespace disk_cache | 55 } // namespace disk_cache |
44 | 56 |
45 #endif // NET_DISK_CACHE_STATS_HISTOGRAM_H_ | 57 #endif // NET_DISK_CACHE_STATS_HISTOGRAM_H_ |
OLD | NEW |