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

Unified Diff: net/disk_cache/stats_histogram.cc

Issue 6780035: Use lock-free lazy initialization for static histogram references (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 months 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/socket/client_socket_pool_histograms.h » ('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 80382)
+++ net/disk_cache/stats_histogram.cc (working copy)
@@ -21,23 +21,23 @@
stats_ = NULL;
}
-scoped_refptr<StatsHistogram> StatsHistogram::StatsHistogramFactoryGet(
+StatsHistogram* StatsHistogram::StatsHistogramFactoryGet(
const std::string& name) {
- scoped_refptr<Histogram> histogram(NULL);
+ 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);
+ DCHECK(histogram != NULL);
} else {
- StatsHistogram* stats_histogram = new StatsHistogram(name, minimum, maximum,
- bucket_count);
+ // To avoid racy destruction at shutdown, the following will be leaked.
+ StatsHistogram* stats_histogram =
+ new StatsHistogram(name, minimum, maximum, bucket_count);
stats_histogram->InitializeBucketRange();
- histogram = stats_histogram;
- histogram->SetFlags(kUmaTargetedHistogramFlag);
- StatisticsRecorder::RegisterOrDiscardDuplicate(&histogram);
+ stats_histogram->SetFlags(kUmaTargetedHistogramFlag);
+ histogram = StatisticsRecorder::RegisterOrDeleteDuplicate(stats_histogram);
}
DCHECK(HISTOGRAM == histogram->histogram_type());
@@ -45,13 +45,10 @@
// 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);
+ StatsHistogram* return_histogram = static_cast<StatsHistogram*>(histogram);
// Validate upcast by seeing that we're probably providing the checksum.
- CHECK_EQ(temp_stats_histogram->StatsHistogram::CalculateRangeChecksum(),
- temp_stats_histogram->CalculateRangeChecksum());
- scoped_refptr<StatsHistogram> return_histogram(temp_stats_histogram);
+ CHECK_EQ(return_histogram->StatsHistogram::CalculateRangeChecksum(),
+ return_histogram->CalculateRangeChecksum());
return return_histogram;
}
« no previous file with comments | « net/disk_cache/stats_histogram.h ('k') | net/socket/client_socket_pool_histograms.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698