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

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

Issue 2836993002: Add ThreadChecker to HistogramSnapshotManager. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« no previous file with comments | « base/metrics/histogram_snapshot_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 17 matching lines...) Expand all
28 } 28 }
29 29
30 void HistogramSnapshotManager::PrepareFinalDelta( 30 void HistogramSnapshotManager::PrepareFinalDelta(
31 const HistogramBase* histogram) { 31 const HistogramBase* histogram) {
32 PrepareSamples(histogram, histogram->SnapshotFinalDelta()); 32 PrepareSamples(histogram, histogram->SnapshotFinalDelta());
33 } 33 }
34 34
35 void HistogramSnapshotManager::PrepareSamples( 35 void HistogramSnapshotManager::PrepareSamples(
36 const HistogramBase* histogram, 36 const HistogramBase* histogram,
37 std::unique_ptr<HistogramSamples> samples) { 37 std::unique_ptr<HistogramSamples> samples) {
38 DCHECK(thread_checker_.CalledOnValidThread());
38 DCHECK(histogram_flattener_); 39 DCHECK(histogram_flattener_);
39 40
40 // Get information known about this histogram. If it did not previously 41 // Get information known about this histogram. If it did not previously
41 // exist, one will be created and initialized. 42 // exist, one will be created and initialized.
42 SampleInfo* sample_info = &known_histograms_[histogram->name_hash()]; 43 SampleInfo* sample_info = &known_histograms_[histogram->name_hash()];
43 44
44 // Crash if we detect that our histograms have been overwritten. This may be 45 // Crash if we detect that our histograms have been overwritten. This may be
45 // a fair distance from the memory smasher, but we hope to correlate these 46 // a fair distance from the memory smasher, but we hope to correlate these
46 // crashes with other events, such as plugins, or usage patterns, etc. 47 // crashes with other events, such as plugins, or usage patterns, etc.
47 uint32_t corruption = histogram->FindCorruption(*samples); 48 uint32_t corruption = histogram->FindCorruption(*samples);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 sample_info->inconsistencies |= corruption; 87 sample_info->inconsistencies |= corruption;
87 histogram_flattener_->UniqueInconsistencyDetected( 88 histogram_flattener_->UniqueInconsistencyDetected(
88 static_cast<HistogramBase::Inconsistency>(corruption)); 89 static_cast<HistogramBase::Inconsistency>(corruption));
89 return; 90 return;
90 } 91 }
91 92
92 if (samples->TotalCount() > 0) 93 if (samples->TotalCount() > 0)
93 histogram_flattener_->RecordDelta(*histogram, *samples); 94 histogram_flattener_->RecordDelta(*histogram, *samples);
94 } 95 }
95 96
96 void HistogramSnapshotManager::InspectLoggedSamplesInconsistency( 97 void HistogramSnapshotManager::InspectLoggedSamplesInconsistency(
Alexei Svitkine (slow) 2017/04/24 16:33:09 I don't see this being called anywhere. Can you re
bcwhite 2017/04/24 19:28:28 Done.
97 const HistogramSamples& new_snapshot, 98 const HistogramSamples& new_snapshot,
98 HistogramSamples* logged_samples) { 99 HistogramSamples* logged_samples) {
99 HistogramBase::Count discrepancy = 100 HistogramBase::Count discrepancy =
100 logged_samples->TotalCount() - logged_samples->redundant_count(); 101 logged_samples->TotalCount() - logged_samples->redundant_count();
101 if (!discrepancy) 102 if (!discrepancy)
102 return; 103 return;
103 104
104 histogram_flattener_->InconsistencyDetectedInLoggedCount(discrepancy); 105 histogram_flattener_->InconsistencyDetectedInLoggedCount(discrepancy);
105 if (discrepancy > Histogram::kCommonRaceBasedCountMismatch) { 106 if (discrepancy > Histogram::kCommonRaceBasedCountMismatch) {
106 // Fix logged_samples. 107 // Fix logged_samples.
107 logged_samples->Subtract(*logged_samples); 108 logged_samples->Subtract(*logged_samples);
108 logged_samples->Add(new_snapshot); 109 logged_samples->Add(new_snapshot);
109 } 110 }
110 } 111 }
111 112
112 } // namespace base 113 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/histogram_snapshot_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698