diff options
author | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-06 00:09:37 +0000 |
---|---|---|
committer | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-06 00:09:37 +0000 |
commit | e8829a1981a2d9d849c377c28f9444fdefee0f44 (patch) | |
tree | 3cfe522cf76d308dec9fca773d3f9495e12abc5e /net/disk_cache/stats_histogram.h | |
parent | 4f3b65a30cad88c1f1e482f7bda69ef50f8e1364 (diff) | |
download | chromium_src-e8829a1981a2d9d849c377c28f9444fdefee0f44.zip chromium_src-e8829a1981a2d9d849c377c28f9444fdefee0f44.tar.gz chromium_src-e8829a1981a2d9d849c377c28f9444fdefee0f44.tar.bz2 |
Use factory to create histograms, and refcounts to track lifetimes
This is CL patch 377028 by Raman Tenneti, with minor changes to
make the try-bots happier.
It is cleanup that better ensures lifetimes of histograms (making it harder
for users to abuse them).
bug=16495 (repairs leak induced by the first landing)
bug=18840 (should make leaks less possible)
tbr=raman.tenneti
Review URL: http://codereview.chromium.org/462027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33933 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/stats_histogram.h')
-rw-r--r-- | net/disk_cache/stats_histogram.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/net/disk_cache/stats_histogram.h b/net/disk_cache/stats_histogram.h index 8db3bb3..995d486 100644 --- a/net/disk_cache/stats_histogram.h +++ b/net/disk_cache/stats_histogram.h @@ -5,6 +5,8 @@ #ifndef NET_DISK_CACHE_STATS_HISTOGRAM_H_ #define NET_DISK_CACHE_STATS_HISTOGRAM_H_ +#include <string> + #include "base/histogram.h" namespace disk_cache { @@ -14,6 +16,10 @@ class Stats; // This class provides support for sending the disk cache size stats as a UMA // histogram. We'll provide our own storage and management for the data, and a // SampleSet with a copy of our data. +// +// Class derivation of Histogram "deprecated," and should not be copied, and +// may eventually go away. +// class StatsHistogram : public Histogram { public: class StatsSamples : public SampleSet { @@ -23,10 +29,14 @@ class StatsHistogram : public Histogram { } }; - explicit StatsHistogram(const char* name) - : Histogram(name, 1, 1, 2), init_(false) {} + explicit StatsHistogram(const std::string& name, Sample minimum, + Sample maximum, size_t bucket_count) + : Histogram(name, minimum, maximum, bucket_count), init_(false) {} ~StatsHistogram(); + static scoped_refptr<StatsHistogram> + StatsHistogramFactoryGet(const std::string& name); + // We'll be reporting data from the given set of cache stats. bool Init(const Stats* stats); @@ -35,6 +45,8 @@ class StatsHistogram : public Histogram { virtual void SnapshotSample(SampleSet* sample) const; private: + friend class Histogram; + bool init_; static const Stats* stats_; DISALLOW_COPY_AND_ASSIGN(StatsHistogram); |