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

Unified Diff: base/metrics/sparse_histogram.cc

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 years, 8 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 | « base/metrics/sparse_histogram.h ('k') | base/metrics/sparse_histogram_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/sparse_histogram.cc
diff --git a/base/metrics/sparse_histogram.cc b/base/metrics/sparse_histogram.cc
index ee18cfa6b15ffb0b69b56604ac17529cddd1a9bb..1118c4149ef95f6c8e734ef7fca3646b58b8c50c 100644
--- a/base/metrics/sparse_histogram.cc
+++ b/base/metrics/sparse_histogram.cc
@@ -6,6 +6,7 @@
#include <utility>
+#include "base/memory/ptr_util.h"
#include "base/metrics/metrics_hashes.h"
#include "base/metrics/persistent_histogram_allocator.h"
#include "base/metrics/persistent_sample_map.h"
@@ -37,7 +38,7 @@ HistogramBase* SparseHistogram::FactoryGet(const std::string& name,
// allocating from it fails, code below will allocate the histogram from
// the process heap.
PersistentMemoryAllocator::Reference histogram_ref = 0;
- scoped_ptr<HistogramBase> tentative_histogram;
+ std::unique_ptr<HistogramBase> tentative_histogram;
PersistentHistogramAllocator* allocator =
PersistentHistogramAllocator::GetGlobalAllocator();
if (allocator) {
@@ -79,12 +80,12 @@ HistogramBase* SparseHistogram::FactoryGet(const std::string& name,
}
// static
-scoped_ptr<HistogramBase> SparseHistogram::PersistentCreate(
+std::unique_ptr<HistogramBase> SparseHistogram::PersistentCreate(
PersistentMemoryAllocator* allocator,
const std::string& name,
HistogramSamples::Metadata* meta,
HistogramSamples::Metadata* logged_meta) {
- return make_scoped_ptr(
+ return WrapUnique(
new SparseHistogram(allocator, name, meta, logged_meta));
}
@@ -123,16 +124,16 @@ void SparseHistogram::AddCount(Sample value, int count) {
FindAndRunCallback(value);
}
-scoped_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const {
- scoped_ptr<SampleMap> snapshot(new SampleMap(name_hash()));
+std::unique_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const {
+ std::unique_ptr<SampleMap> snapshot(new SampleMap(name_hash()));
base::AutoLock auto_lock(lock_);
snapshot->Add(*samples_);
return std::move(snapshot);
}
-scoped_ptr<HistogramSamples> SparseHistogram::SnapshotDelta() {
- scoped_ptr<SampleMap> snapshot(new SampleMap(name_hash()));
+std::unique_ptr<HistogramSamples> SparseHistogram::SnapshotDelta() {
+ std::unique_ptr<SampleMap> snapshot(new SampleMap(name_hash()));
base::AutoLock auto_lock(lock_);
snapshot->Add(*samples_);
@@ -219,7 +220,7 @@ void SparseHistogram::WriteAsciiImpl(bool graph_it,
const std::string& newline,
std::string* output) const {
// Get a local copy of the data so we are consistent.
- scoped_ptr<HistogramSamples> snapshot = SnapshotSamples();
+ std::unique_ptr<HistogramSamples> snapshot = SnapshotSamples();
Count total_count = snapshot->TotalCount();
double scaled_total_count = total_count / 100.0;
@@ -232,7 +233,7 @@ void SparseHistogram::WriteAsciiImpl(bool graph_it,
// normalize the graphical bar-width relative to that sample count.
Count largest_count = 0;
Sample largest_sample = 0;
- scoped_ptr<SampleCountIterator> it = snapshot->Iterator();
+ std::unique_ptr<SampleCountIterator> it = snapshot->Iterator();
while (!it->Done()) {
Sample min;
Sample max;
« no previous file with comments | « base/metrics/sparse_histogram.h ('k') | base/metrics/sparse_histogram_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698