| OLD | NEW |
| 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 Loading... |
| 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::PrepareDifference( |
| 64 const HistogramBase* histogram) { |
| 65 PrepareSamples(histogram, histogram->SnapshotDifference()); |
| 66 } |
| 67 |
| 68 void HistogramSnapshotManager::PrepareDifferenceTakingOwnership( |
| 69 std::unique_ptr<const HistogramBase> histogram) { |
| 70 PrepareSamples(histogram.get(), histogram->SnapshotDifference()); |
| 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 Loading... |
| 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 |
| OLD | NEW |