| Index: base/metrics/statistics_recorder.cc
|
| diff --git a/base/metrics/statistics_recorder.cc b/base/metrics/statistics_recorder.cc
|
| index d0fa2add3603b3f574dfa9ef9e5ee2e6b152aafc..3d8504baa1ef5ddf68585080652c5a6adf1fb19e 100644
|
| --- a/base/metrics/statistics_recorder.cc
|
| +++ b/base/metrics/statistics_recorder.cc
|
| @@ -83,7 +83,11 @@ bool StatisticsRecorder::IsActive() {
|
|
|
| // static
|
| HistogramBase* StatisticsRecorder::RegisterOrDeleteDuplicate(
|
| - HistogramBase* histogram) {
|
| + scoped_ptr<HistogramBase> histogram_ptr) {
|
| + // Ownership is managed outside of scoped_ptr, the use of which is only to
|
| + // explicitly document the transfer of ownership during the call.
|
| + HistogramBase* histogram = histogram_ptr.release();
|
| +
|
| // As per crbug.com/79322 the histograms are intentionally leaked, so we need
|
| // to annotate them. Because ANNOTATE_LEAKING_OBJECT_PTR may be used only once
|
| // for an object, the duplicates should not be annotated.
|
| @@ -119,7 +123,9 @@ HistogramBase* StatisticsRecorder::RegisterOrDeleteDuplicate(
|
| }
|
| histogram_to_return = histogram;
|
| } else if (histogram == it->second) {
|
| - // The histogram was registered before.
|
| + // The histogram was registered before. This should never happen since
|
| + // the method signature ensures moving of the histogram pointer.
|
| + NOTREACHED();
|
| histogram_to_return = histogram;
|
| } else {
|
| // We already have one histogram with this name.
|
| @@ -136,7 +142,11 @@ HistogramBase* StatisticsRecorder::RegisterOrDeleteDuplicate(
|
|
|
| // static
|
| const BucketRanges* StatisticsRecorder::RegisterOrDeleteDuplicateRanges(
|
| - const BucketRanges* ranges) {
|
| + scoped_ptr<const BucketRanges> ranges_ptr) {
|
| + // Ownership is managed outside of scoped_ptr, the use of which is only to
|
| + // explicitly document the transfer of ownership during the call.
|
| + const BucketRanges* ranges = ranges_ptr.release();
|
| +
|
| DCHECK(ranges->HasValidChecksum());
|
| scoped_ptr<const BucketRanges> ranges_deleter;
|
|
|
|
|