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

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

Issue 137623002: Let MetricsService know about some Android Activities (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 10 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 "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/metrics/histogram_flattener.h" 8 #include "base/metrics/histogram_flattener.h"
9 #include "base/metrics/histogram_samples.h" 9 #include "base/metrics/histogram_samples.h"
10 #include "base/metrics/statistics_recorder.h" 10 #include "base/metrics/statistics_recorder.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 12
13 using std::map; 13 using std::map;
14 using std::string; 14 using std::string;
15 15
16 namespace base { 16 namespace base {
17 17
18 HistogramSnapshotManager::HistogramSnapshotManager( 18 HistogramSnapshotManager::HistogramSnapshotManager(
19 HistogramFlattener* histogram_flattener) 19 HistogramFlattener* histogram_flattener)
20 : histogram_flattener_(histogram_flattener) { 20 : histogram_flattener_(histogram_flattener) {
21 DCHECK(histogram_flattener_); 21 DCHECK(histogram_flattener_);
22 } 22 }
23 23
24 HistogramSnapshotManager::~HistogramSnapshotManager() { 24 HistogramSnapshotManager::~HistogramSnapshotManager() {
25 STLDeleteValues(&logged_samples_); 25 STLDeleteValues(&logged_samples_);
26 } 26 }
27 27
28 void HistogramSnapshotManager::PrepareDeltas(HistogramBase::Flags flag_to_set, 28 void HistogramSnapshotManager::PrepareDeltas(
29 bool record_only_uma) { 29 HistogramBase::Flags flag_to_set,
30 HistogramBase::Flags required_flags) {
30 StatisticsRecorder::Histograms histograms; 31 StatisticsRecorder::Histograms histograms;
31 StatisticsRecorder::GetHistograms(&histograms); 32 StatisticsRecorder::GetHistograms(&histograms);
32 for (StatisticsRecorder::Histograms::const_iterator it = histograms.begin(); 33 for (StatisticsRecorder::Histograms::const_iterator it = histograms.begin();
33 histograms.end() != it; 34 histograms.end() != it;
34 ++it) { 35 ++it) {
35 (*it)->SetFlags(flag_to_set); 36 (*it)->SetFlags(flag_to_set);
36 if (record_only_uma && 37 if (((*it)->flags() & required_flags) == required_flags)
37 0 == ((*it)->flags() & Histogram::kUmaTargetedHistogramFlag)) 38 PrepareDelta(**it);
38 continue;
39 PrepareDelta(**it);
40 } 39 }
41 } 40 }
42 41
43 void HistogramSnapshotManager::PrepareDelta(const HistogramBase& histogram) { 42 void HistogramSnapshotManager::PrepareDelta(const HistogramBase& histogram) {
44 DCHECK(histogram_flattener_); 43 DCHECK(histogram_flattener_);
45 44
46 // Get up-to-date snapshot of sample stats. 45 // Get up-to-date snapshot of sample stats.
47 scoped_ptr<HistogramSamples> snapshot(histogram.SnapshotSamples()); 46 scoped_ptr<HistogramSamples> snapshot(histogram.SnapshotSamples());
48 const std::string& histogram_name = histogram.histogram_name(); 47 const std::string& histogram_name = histogram.histogram_name();
49 48
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 107
109 histogram_flattener_->InconsistencyDetectedInLoggedCount(discrepancy); 108 histogram_flattener_->InconsistencyDetectedInLoggedCount(discrepancy);
110 if (discrepancy > Histogram::kCommonRaceBasedCountMismatch) { 109 if (discrepancy > Histogram::kCommonRaceBasedCountMismatch) {
111 // Fix logged_samples. 110 // Fix logged_samples.
112 logged_samples->Subtract(*logged_samples); 111 logged_samples->Subtract(*logged_samples);
113 logged_samples->Add(new_snapshot); 112 logged_samples->Add(new_snapshot);
114 } 113 }
115 } 114 }
116 115
117 } // namespace base 116 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698