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

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

Issue 10454086: Histograms - Support histograms for Plugins, GPU (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
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 "chrome/common/metrics/histogram_sender.h" 5 #include "base/metrics/histogram_sender.h"
6 6
7 using base::Histogram; 7 using base::Histogram;
8 using base::StatisticsRecorder; 8 using base::StatisticsRecorder;
9 9
10 namespace base {
11
10 HistogramSender::HistogramSender() {} 12 HistogramSender::HistogramSender() {}
11 13
12 HistogramSender::~HistogramSender() {} 14 HistogramSender::~HistogramSender() {}
13 15
14 void HistogramSender::TransmitAllHistograms(Histogram::Flags flag_to_set, 16 void HistogramSender::TransmitAllHistograms(Histogram::Flags flag_to_set,
15 bool send_only_uma) { 17 bool send_only_uma) {
16 StatisticsRecorder::Histograms histograms; 18 StatisticsRecorder::Histograms histograms;
17 StatisticsRecorder::GetHistograms(&histograms); 19 StatisticsRecorder::GetHistograms(&histograms);
18 for (StatisticsRecorder::Histograms::const_iterator it = histograms.begin(); 20 for (StatisticsRecorder::Histograms::const_iterator it = histograms.begin();
19 histograms.end() != it; 21 histograms.end() != it;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // snapshot anything that we've already sent. 65 // snapshot anything that we've already sent.
64 LoggedSampleMap::iterator it = logged_samples_.find(histogram_name); 66 LoggedSampleMap::iterator it = logged_samples_.find(histogram_name);
65 Histogram::SampleSet* already_logged; 67 Histogram::SampleSet* already_logged;
66 if (logged_samples_.end() == it) { 68 if (logged_samples_.end() == it) {
67 // Add new entry 69 // Add new entry
68 already_logged = &logged_samples_[histogram.histogram_name()]; 70 already_logged = &logged_samples_[histogram.histogram_name()];
69 already_logged->Resize(histogram); // Complete initialization. 71 already_logged->Resize(histogram); // Complete initialization.
70 } else { 72 } else {
71 already_logged = &(it->second); 73 already_logged = &(it->second);
72 int64 discrepancy(already_logged->TotalCount() - 74 int64 discrepancy(already_logged->TotalCount() -
73 already_logged->redundant_count()); 75 already_logged->redundant_count());
74 if (discrepancy) { 76 if (discrepancy) {
75 NOTREACHED(); // Already_logged has become corrupt. 77 NOTREACHED(); // Already_logged has become corrupt.
76 int problem = static_cast<int>(discrepancy); 78 int problem = static_cast<int>(discrepancy);
77 if (problem != discrepancy) 79 if (problem != discrepancy)
78 problem = INT_MAX; 80 problem = INT_MAX;
79 SnapshotProblemResolved(problem); 81 SnapshotProblemResolved(problem);
80 // With no valid baseline, we'll act like we've sent everything in our 82 // With no valid baseline, we'll act like we've sent everything in our
81 // snapshot. 83 // snapshot.
82 already_logged->Subtract(*already_logged); 84 already_logged->Subtract(*already_logged);
83 already_logged->Add(snapshot); 85 already_logged->Add(snapshot);
84 } 86 }
85 // Deduct any stats we've already logged from our snapshot. 87 // Deduct any stats we've already logged from our snapshot.
86 snapshot.Subtract(*already_logged); 88 snapshot.Subtract(*already_logged);
87 } 89 }
88 90
89 // Snapshot now contains only a delta to what we've already_logged. 91 // Snapshot now contains only a delta to what we've already_logged.
90 if (snapshot.redundant_count() > 0) { 92 if (snapshot.redundant_count() > 0) {
91 TransmitHistogramDelta(histogram, snapshot); 93 TransmitHistogramDelta(histogram, snapshot);
92 // Add new data into our running total. 94 // Add new data into our running total.
93 already_logged->Add(snapshot); 95 already_logged->Add(snapshot);
94 } 96 }
95 } 97 }
98 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698