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

Side by Side Diff: base/metrics/histogram_snapshot_manager.cc

Issue 1891913002: Support saving browser metrics to disk and reading them during next run. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove DCHECK_IS_ON from .h files because it's not always defined and don't want to add the include Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/metrics/histogram_snapshot_manager.h" 5 #include "base/metrics/histogram_snapshot_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/debug/alias.h" 9 #include "base/debug/alias.h"
10 #include "base/metrics/histogram_flattener.h" 10 #include "base/metrics/histogram_flattener.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 void HistogramSnapshotManager::PrepareAbsolute(const HistogramBase* histogram) { 53 void HistogramSnapshotManager::PrepareAbsolute(const HistogramBase* histogram) {
54 PrepareSamples(histogram, histogram->SnapshotSamples()); 54 PrepareSamples(histogram, histogram->SnapshotSamples());
55 } 55 }
56 56
57 void HistogramSnapshotManager::PrepareAbsoluteTakingOwnership( 57 void HistogramSnapshotManager::PrepareAbsoluteTakingOwnership(
58 std::unique_ptr<const HistogramBase> histogram) { 58 std::unique_ptr<const HistogramBase> histogram) {
59 PrepareSamples(histogram.get(), histogram->SnapshotSamples()); 59 PrepareSamples(histogram.get(), histogram->SnapshotSamples());
60 owned_histograms_.push_back(std::move(histogram)); 60 owned_histograms_.push_back(std::move(histogram));
61 } 61 }
62 62
63 void HistogramSnapshotManager::PrepareFinalDelta(
64 const HistogramBase* histogram) {
65 PrepareSamples(histogram, histogram->SnapshotFinalDelta());
66 }
67
68 void HistogramSnapshotManager::PrepareFinalDeltaTakingOwnership(
69 std::unique_ptr<const HistogramBase> histogram) {
70 PrepareSamples(histogram.get(), histogram->SnapshotFinalDelta());
71 owned_histograms_.push_back(std::move(histogram));
72 }
73
63 void HistogramSnapshotManager::FinishDeltas() { 74 void HistogramSnapshotManager::FinishDeltas() {
64 DCHECK(preparing_deltas_); 75 DCHECK(preparing_deltas_);
65 76
66 // Iterate over all known histograms to see what should be recorded. 77 // Iterate over all known histograms to see what should be recorded.
67 for (auto& hash_and_info : known_histograms_) { 78 for (auto& hash_and_info : known_histograms_) {
68 SampleInfo* sample_info = &hash_and_info.second; 79 SampleInfo* sample_info = &hash_and_info.second;
69 80
70 // First, record any histograms in which corruption was detected. 81 // First, record any histograms in which corruption was detected.
71 if (sample_info->inconsistencies & HistogramBase::NEW_INCONSISTENCY_FOUND) { 82 if (sample_info->inconsistencies & HistogramBase::NEW_INCONSISTENCY_FOUND) {
72 sample_info->inconsistencies &= ~HistogramBase::NEW_INCONSISTENCY_FOUND; 83 sample_info->inconsistencies &= ~HistogramBase::NEW_INCONSISTENCY_FOUND;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 175
165 histogram_flattener_->InconsistencyDetectedInLoggedCount(discrepancy); 176 histogram_flattener_->InconsistencyDetectedInLoggedCount(discrepancy);
166 if (discrepancy > Histogram::kCommonRaceBasedCountMismatch) { 177 if (discrepancy > Histogram::kCommonRaceBasedCountMismatch) {
167 // Fix logged_samples. 178 // Fix logged_samples.
168 logged_samples->Subtract(*logged_samples); 179 logged_samples->Subtract(*logged_samples);
169 logged_samples->Add(new_snapshot); 180 logged_samples->Add(new_snapshot);
170 } 181 }
171 } 182 }
172 183
173 } // namespace base 184 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698