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

Unified Diff: net/disk_cache/stats_histogram.cc

Issue 462027: Use factory to create histograms, and refcounts to track lifetimes... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/stats_histogram.h ('k') | net/ftp/ftp_network_transaction.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/stats_histogram.cc
===================================================================
--- net/disk_cache/stats_histogram.cc (revision 33932)
+++ net/disk_cache/stats_histogram.cc (working copy)
@@ -12,6 +12,37 @@
// Static.
const Stats* StatsHistogram::stats_ = NULL;
+scoped_refptr<StatsHistogram> StatsHistogram::StatsHistogramFactoryGet(
+ const std::string& name) {
+ scoped_refptr<Histogram> histogram(NULL);
+
+ Sample minimum = 1;
+ Sample maximum = disk_cache::Stats::kDataSizesLength - 1;
+ size_t bucket_count = disk_cache::Stats::kDataSizesLength;
+
+ if (StatisticsRecorder::FindHistogram(name, &histogram)) {
+ DCHECK(histogram.get() != NULL);
+ } else {
+ histogram = new StatsHistogram(name, minimum, maximum, bucket_count);
+ scoped_refptr<Histogram> registered_histogram(NULL);
+ StatisticsRecorder::FindHistogram(name, &registered_histogram);
+ if (registered_histogram.get() != NULL &&
+ registered_histogram.get() != histogram.get())
+ histogram = registered_histogram;
+ }
+
+ DCHECK(HISTOGRAM == histogram->histogram_type());
+ DCHECK(histogram->HasConstructorArguments(minimum, maximum, bucket_count));
+
+ // We're preparing for an otherwise unsafe upcast by ensuring we have the
+ // proper class type.
+ Histogram* temp_histogram = histogram.get();
+ StatsHistogram* temp_stats_histogram =
+ static_cast<StatsHistogram*>(temp_histogram);
+ scoped_refptr<StatsHistogram> return_histogram = temp_stats_histogram;
+ return return_histogram;
+}
+
bool StatsHistogram::Init(const Stats* stats) {
DCHECK(stats);
if (stats_)
« no previous file with comments | « net/disk_cache/stats_histogram.h ('k') | net/ftp/ftp_network_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698