| Index: base/metrics/histogram.cc
|
| diff --git a/base/metrics/histogram.cc b/base/metrics/histogram.cc
|
| index ea4f8167fa28cc7098ce233cddbd7ed77fd23a77..40ae9c116fd18e1d353d5333631b762f778f7ef1 100644
|
| --- a/base/metrics/histogram.cc
|
| +++ b/base/metrics/histogram.cc
|
| @@ -156,9 +156,10 @@ HistogramBase* Histogram::Factory::Build() {
|
| HistogramBase* histogram = StatisticsRecorder::FindHistogram(name_);
|
| if (!histogram) {
|
| // To avoid racy destruction at shutdown, the following will be leaked.
|
| - const BucketRanges* created_ranges = CreateRanges();
|
| + scoped_ptr<const BucketRanges> created_ranges(CreateRanges());
|
| const BucketRanges* registered_ranges =
|
| - StatisticsRecorder::RegisterOrDeleteDuplicateRanges(created_ranges);
|
| + StatisticsRecorder::RegisterOrDeleteDuplicateRanges(
|
| + std::move(created_ranges));
|
|
|
| // In most cases, the bucket-count, minimum, and maximum values are known
|
| // when the code is written and so are passed in explicitly. In other
|
| @@ -177,7 +178,7 @@ HistogramBase* Histogram::Factory::Build() {
|
| // allocating from it fails, code below will allocate the histogram from
|
| // the process heap.
|
| PersistentMemoryAllocator::Reference histogram_ref = 0;
|
| - HistogramBase* tentative_histogram = nullptr;
|
| + scoped_ptr<HistogramBase> tentative_histogram;
|
| PersistentMemoryAllocator* allocator =
|
| GetPersistentHistogramMemoryAllocator();
|
| if (allocator) {
|
| @@ -199,17 +200,18 @@ HistogramBase* Histogram::Factory::Build() {
|
| DCHECK(!histogram_ref); // Should never have been set.
|
| DCHECK(!allocator); // Shouldn't have failed.
|
| flags_ &= ~HistogramBase::kIsPersistent;
|
| - tentative_histogram = HeapAlloc(registered_ranges);
|
| + tentative_histogram.reset(HeapAlloc(registered_ranges));
|
| }
|
|
|
| - FillHistogram(tentative_histogram);
|
| - histogram =
|
| - StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
|
| + FillHistogram(tentative_histogram.get());
|
| + const void* allocated_histogram = tentative_histogram.get();
|
| + histogram = StatisticsRecorder::RegisterOrDeleteDuplicate(
|
| + std::move(tentative_histogram));
|
|
|
| // Persistent histograms need some follow-up processing.
|
| if (histogram_ref) {
|
| FinalizePersistentHistogram(histogram_ref,
|
| - histogram == tentative_histogram);
|
| + histogram == allocated_histogram);
|
| }
|
| }
|
|
|
|
|