| Index: components/metrics/metrics_service.cc
|
| diff --git a/components/metrics/metrics_service.cc b/components/metrics/metrics_service.cc
|
| index e868ea7c9bb1cc087644257b65c44e3edcf9e346..ebbf4275bed5dd764109315a5a0cfbeb709abce6 100644
|
| --- a/components/metrics/metrics_service.cc
|
| +++ b/components/metrics/metrics_service.cc
|
| @@ -252,10 +252,12 @@ SyntheticTrialGroup::~SyntheticTrialGroup() {
|
| }
|
|
|
| MetricsService::PersistentHistogramIterator::PersistentHistogramIterator(
|
| + HistogramSet* found_histograms,
|
| AllocatorSet& allocators,
|
| AllocatorSet::iterator pos)
|
| : allocators_(allocators),
|
| - allocator_iter_(pos) {
|
| + allocator_iter_(pos),
|
| + found_histograms_(found_histograms) {
|
| if (pos != allocators_.end()) {
|
| (*allocator_iter_)->CreateIterator(&histogram_iter_);
|
| // Have to call ++ to advance iterator to the first persistent histogram.
|
| @@ -267,10 +269,12 @@ MetricsService::PersistentHistogramIterator&
|
| MetricsService::PersistentHistogramIterator::operator++() {
|
| if (allocator_iter_ != allocators_.end()) {
|
| for (;;) {
|
| - base::HistogramBase* h = base::HistogramBase::GetNextPersistentHistogram(
|
| + current_histogram_ = base::HistogramBase::GetNextPersistentHistogram(
|
| *allocator_iter_, &histogram_iter_);
|
| - if (h) {
|
| - current_histogram_ = new HistogramPointer(h);
|
| + if (current_histogram_) {
|
| + DCHECK(found_histograms_->find(current_histogram_) ==
|
| + found_histograms_->end());
|
| + found_histograms_->insert(current_histogram_);
|
| break;
|
| }
|
| allocator_iter_++;
|
| @@ -1158,9 +1162,11 @@ void MetricsService::RecordCurrentHistograms() {
|
| histogram_snapshot_manager_.PrepareDeltas(
|
| base::StatisticsRecorder::begin(true), base::StatisticsRecorder::end(),
|
| base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag);
|
| + HistogramSet persistent_histograms;
|
| histogram_snapshot_manager_.PrepareDeltas(
|
| - persistent_begin(), persistent_end(),
|
| + persistent_begin(&persistent_histograms), persistent_end(),
|
| base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag);
|
| + STLDeleteElements(&persistent_histograms);
|
| }
|
|
|
| void MetricsService::RecordCurrentStabilityHistograms() {
|
| @@ -1205,12 +1211,13 @@ void MetricsService::SkipAndDiscardUpload() {
|
| log_upload_in_progress_ = false;
|
| }
|
|
|
| -MetricsService::PersistentHistogramIterator MetricsService::persistent_begin() {
|
| - return PersistentHistogramIterator(allocators_, allocators_.begin());
|
| +MetricsService::PersistentHistogramIterator MetricsService::persistent_begin(
|
| + HistogramSet* found) {
|
| + return PersistentHistogramIterator(found, allocators_, allocators_.begin());
|
| }
|
|
|
| MetricsService::PersistentHistogramIterator MetricsService::persistent_end() {
|
| - return PersistentHistogramIterator(allocators_, allocators_.end());
|
| + return PersistentHistogramIterator(nullptr, allocators_, allocators_.end());
|
| }
|
|
|
| } // namespace metrics
|
|
|