Index: base/metrics/histogram.cc |
diff --git a/base/metrics/histogram.cc b/base/metrics/histogram.cc |
index 35197e26e395a9d08bd4bd9826938241e37754fe..a48716f60ed6bb2751a2dcde3122f90dee7c2a8d 100644 |
--- a/base/metrics/histogram.cc |
+++ b/base/metrics/histogram.cc |
@@ -18,6 +18,7 @@ |
#include "base/compiler_specific.h" |
#include "base/debug/alias.h" |
#include "base/logging.h" |
+#include "base/memory/ptr_util.h" |
#include "base/metrics/histogram_macros.h" |
#include "base/metrics/metrics_hashes.h" |
#include "base/metrics/persistent_histogram_allocator.h" |
@@ -122,8 +123,8 @@ class Histogram::Factory { |
// Allocate the correct Histogram object off the heap (in case persistent |
// memory is not available). |
- virtual scoped_ptr<HistogramBase> HeapAlloc(const BucketRanges* ranges) { |
- return make_scoped_ptr(new Histogram(name_, minimum_, maximum_, ranges)); |
+ virtual std::unique_ptr<HistogramBase> HeapAlloc(const BucketRanges* ranges) { |
+ return WrapUnique(new Histogram(name_, minimum_, maximum_, ranges)); |
} |
// Perform any required datafill on the just-created histogram. If |
@@ -176,7 +177,7 @@ HistogramBase* Histogram::Factory::Build() { |
// allocating from it fails, code below will allocate the histogram from |
// the process heap. |
PersistentHistogramAllocator::Reference histogram_ref = 0; |
- scoped_ptr<HistogramBase> tentative_histogram; |
+ std::unique_ptr<HistogramBase> tentative_histogram; |
PersistentHistogramAllocator* allocator = |
PersistentHistogramAllocator::GetGlobalAllocator(); |
if (allocator) { |
@@ -277,7 +278,7 @@ HistogramBase* Histogram::FactoryTimeGet(const char* name, |
flags); |
} |
-scoped_ptr<HistogramBase> Histogram::PersistentCreate( |
+std::unique_ptr<HistogramBase> Histogram::PersistentCreate( |
const std::string& name, |
Sample minimum, |
Sample maximum, |
@@ -287,9 +288,9 @@ scoped_ptr<HistogramBase> Histogram::PersistentCreate( |
uint32_t counts_size, |
HistogramSamples::Metadata* meta, |
HistogramSamples::Metadata* logged_meta) { |
- return make_scoped_ptr(new Histogram( |
- name, minimum, maximum, ranges, counts, logged_counts, counts_size, |
- meta, logged_meta)); |
+ return WrapUnique(new Histogram(name, minimum, maximum, ranges, counts, |
+ logged_counts, counts_size, meta, |
+ logged_meta)); |
} |
// Calculate what range of values are held in each bucket. |
@@ -440,12 +441,12 @@ void Histogram::AddCount(int value, int count) { |
FindAndRunCallback(value); |
} |
-scoped_ptr<HistogramSamples> Histogram::SnapshotSamples() const { |
+std::unique_ptr<HistogramSamples> Histogram::SnapshotSamples() const { |
return SnapshotSampleVector(); |
} |
-scoped_ptr<HistogramSamples> Histogram::SnapshotDelta() { |
- scoped_ptr<HistogramSamples> snapshot = SnapshotSampleVector(); |
+std::unique_ptr<HistogramSamples> Histogram::SnapshotDelta() { |
+ std::unique_ptr<HistogramSamples> snapshot = SnapshotSampleVector(); |
if (!logged_samples_) { |
// If nothing has been previously logged, save this one as |
// |logged_samples_| and gather another snapshot to return. |
@@ -575,8 +576,8 @@ HistogramBase* Histogram::DeserializeInfoImpl(PickleIterator* iter) { |
return histogram; |
} |
-scoped_ptr<SampleVector> Histogram::SnapshotSampleVector() const { |
- scoped_ptr<SampleVector> samples( |
+std::unique_ptr<SampleVector> Histogram::SnapshotSampleVector() const { |
+ std::unique_ptr<SampleVector> samples( |
new SampleVector(samples_->id(), bucket_ranges())); |
samples->Add(*samples_); |
return samples; |
@@ -587,7 +588,7 @@ void Histogram::WriteAsciiImpl(bool graph_it, |
std::string* output) const { |
// Get local (stack) copies of all effectively volatile class data so that we |
// are consistent across our output activities. |
- scoped_ptr<SampleVector> snapshot = SnapshotSampleVector(); |
+ std::unique_ptr<SampleVector> snapshot = SnapshotSampleVector(); |
Count sample_count = snapshot->TotalCount(); |
WriteAsciiHeader(*snapshot, sample_count, output); |
@@ -700,14 +701,14 @@ void Histogram::GetParameters(DictionaryValue* params) const { |
void Histogram::GetCountAndBucketData(Count* count, |
int64_t* sum, |
ListValue* buckets) const { |
- scoped_ptr<SampleVector> snapshot = SnapshotSampleVector(); |
+ std::unique_ptr<SampleVector> snapshot = SnapshotSampleVector(); |
*count = snapshot->TotalCount(); |
*sum = snapshot->sum(); |
uint32_t index = 0; |
for (uint32_t i = 0; i < bucket_count(); ++i) { |
Sample count_at_index = snapshot->GetCountAtIndex(i); |
if (count_at_index > 0) { |
- scoped_ptr<DictionaryValue> bucket_value(new DictionaryValue()); |
+ std::unique_ptr<DictionaryValue> bucket_value(new DictionaryValue()); |
bucket_value->SetInteger("low", ranges(i)); |
if (i != bucket_count() - 1) |
bucket_value->SetInteger("high", ranges(i + 1)); |
@@ -743,8 +744,9 @@ class LinearHistogram::Factory : public Histogram::Factory { |
return ranges; |
} |
- scoped_ptr<HistogramBase> HeapAlloc(const BucketRanges* ranges) override { |
- return make_scoped_ptr( |
+ std::unique_ptr<HistogramBase> HeapAlloc( |
+ const BucketRanges* ranges) override { |
+ return WrapUnique( |
new LinearHistogram(name_, minimum_, maximum_, ranges)); |
} |
@@ -804,7 +806,7 @@ HistogramBase* LinearHistogram::FactoryTimeGet(const char* name, |
flags); |
} |
-scoped_ptr<HistogramBase> LinearHistogram::PersistentCreate( |
+std::unique_ptr<HistogramBase> LinearHistogram::PersistentCreate( |
const std::string& name, |
Sample minimum, |
Sample maximum, |
@@ -814,9 +816,9 @@ scoped_ptr<HistogramBase> LinearHistogram::PersistentCreate( |
uint32_t counts_size, |
HistogramSamples::Metadata* meta, |
HistogramSamples::Metadata* logged_meta) { |
- return make_scoped_ptr(new LinearHistogram( |
- name, minimum, maximum, ranges, counts, logged_counts, counts_size, |
- meta, logged_meta)); |
+ return WrapUnique(new LinearHistogram(name, minimum, maximum, ranges, |
+ counts, logged_counts, |
+ counts_size, meta, logged_meta)); |
} |
HistogramBase* LinearHistogram::FactoryGetWithRangeDescription( |
@@ -934,8 +936,9 @@ class BooleanHistogram::Factory : public Histogram::Factory { |
return ranges; |
} |
- scoped_ptr<HistogramBase> HeapAlloc(const BucketRanges* ranges) override { |
- return make_scoped_ptr(new BooleanHistogram(name_, ranges)); |
+ std::unique_ptr<HistogramBase> HeapAlloc( |
+ const BucketRanges* ranges) override { |
+ return WrapUnique(new BooleanHistogram(name_, ranges)); |
} |
private: |
@@ -951,14 +954,14 @@ HistogramBase* BooleanHistogram::FactoryGet(const char* name, int32_t flags) { |
return FactoryGet(std::string(name), flags); |
} |
-scoped_ptr<HistogramBase> BooleanHistogram::PersistentCreate( |
+std::unique_ptr<HistogramBase> BooleanHistogram::PersistentCreate( |
const std::string& name, |
const BucketRanges* ranges, |
HistogramBase::AtomicCount* counts, |
HistogramBase::AtomicCount* logged_counts, |
HistogramSamples::Metadata* meta, |
HistogramSamples::Metadata* logged_meta) { |
- return make_scoped_ptr(new BooleanHistogram( |
+ return WrapUnique(new BooleanHistogram( |
name, ranges, counts, logged_counts, meta, logged_meta)); |
} |
@@ -1031,8 +1034,9 @@ class CustomHistogram::Factory : public Histogram::Factory { |
return bucket_ranges; |
} |
- scoped_ptr<HistogramBase> HeapAlloc(const BucketRanges* ranges) override { |
- return make_scoped_ptr(new CustomHistogram(name_, ranges)); |
+ std::unique_ptr<HistogramBase> HeapAlloc( |
+ const BucketRanges* ranges) override { |
+ return WrapUnique(new CustomHistogram(name_, ranges)); |
} |
private: |
@@ -1057,7 +1061,7 @@ HistogramBase* CustomHistogram::FactoryGet( |
return FactoryGet(std::string(name), custom_ranges, flags); |
} |
-scoped_ptr<HistogramBase> CustomHistogram::PersistentCreate( |
+std::unique_ptr<HistogramBase> CustomHistogram::PersistentCreate( |
const std::string& name, |
const BucketRanges* ranges, |
HistogramBase::AtomicCount* counts, |
@@ -1065,7 +1069,7 @@ scoped_ptr<HistogramBase> CustomHistogram::PersistentCreate( |
uint32_t counts_size, |
HistogramSamples::Metadata* meta, |
HistogramSamples::Metadata* logged_meta) { |
- return make_scoped_ptr(new CustomHistogram( |
+ return WrapUnique(new CustomHistogram( |
name, ranges, counts, logged_counts, counts_size, meta, logged_meta)); |
} |