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

Side by Side Diff: base/metrics/histogram_flattener.h

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 #ifndef CHROME_COMMON_METRICS_HISTOGRAM_SENDER_H_ 5 #ifndef BASE_METRICS_HISTOGRAM_FLATTENER_H_
6 #define CHROME_COMMON_METRICS_HISTOGRAM_SENDER_H_ 6 #define BASE_METRICS_HISTOGRAM_FLATTENER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 15
16 // HistogramSender handles the logistics of gathering up available histograms 16 namespace base {
17 // for transmission (such as from renderer to browser, or from browser to UMA
18 // upload). It has several pure virtual functions that are replaced in
19 // derived classes to allow the exact lower level transmission mechanism,
20 // or error report mechanism, to be replaced. Since histograms can sit in
21 // memory for an extended period of time, and are vulnerable to memory
22 // corruption, this class also validates as much rendundancy as it can before
23 // calling for the marginal change (a.k.a., delta) in a histogram to be sent
24 // onward.
25 class HistogramSender {
26 protected:
27 HistogramSender();
28 virtual ~HistogramSender();
29 17
30 // Snapshot all histograms, and transmit the delta. 18 // HistogramFlattener is an interface for the logistics of gathering up
31 // The arguments allow a derived class to select only a subset for 19 // available histograms for recording. The implementors handle the exact lower
32 // transmission, or to set a flag in each transmitted histogram. 20 // level recording mechanism, or error report mechanism.
33 void TransmitAllHistograms(base::Histogram::Flags flags_to_set, 21 class BASE_EXPORT HistogramFlattener {
34 bool send_only_uma); 22 public:
23 virtual void RecordDelta(const base::Histogram& histogram,
24 const base::Histogram::SampleSet& snapshot) = 0;
35 25
36 // Send the histograms onward, as defined in a derived class. 26 // Record various errors found during attempts to record histograms.
37 // This is only called with a delta, listing samples that have not previously
38 // been transmitted.
39 virtual void TransmitHistogramDelta(
40 const base::Histogram& histogram,
41 const base::Histogram::SampleSet& snapshot) = 0;
42
43 // Record various errors found during attempts to send histograms.
44 virtual void InconsistencyDetected(int problem) = 0; 27 virtual void InconsistencyDetected(int problem) = 0;
45 virtual void UniqueInconsistencyDetected(int problem) = 0; 28 virtual void UniqueInconsistencyDetected(int problem) = 0;
46 virtual void SnapshotProblemResolved(int amount) = 0; 29 virtual void SnapshotProblemResolved(int amount) = 0;
47 30
31 protected:
32 HistogramFlattener() {}
33 virtual ~HistogramFlattener() {}
34
48 private: 35 private:
49 // Maintain a map of histogram names to the sample stats we've sent. 36 DISALLOW_COPY_AND_ASSIGN(HistogramFlattener);
50 typedef std::map<std::string, base::Histogram::SampleSet> LoggedSampleMap;
51 // List of histograms names, and their encontered corruptions.
52 typedef std::map<std::string, int> ProblemMap;
53
54 // Snapshot this histogram, and transmit the delta.
55 void TransmitHistogram(const base::Histogram& histogram);
56
57 // For histograms, record what we've already transmitted (as a sample for each
58 // histogram) so that we can send only the delta with the next log.
59 LoggedSampleMap logged_samples_;
60
61 // List of histograms found corrupt to be corrupt, and their problems.
62 scoped_ptr<ProblemMap> inconsistencies_;
63
64 DISALLOW_COPY_AND_ASSIGN(HistogramSender);
65 }; 37 };
66 38
67 #endif // CHROME_COMMON_METRICS_HISTOGRAM_SENDER_H_ 39 } // namespace base
40
41 #endif // BASE_METRICS_HISTOGRAM_FLATTENER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698