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

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, 5 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
« no previous file with comments | « base/base.gypi ('k') | base/metrics/histogram_snapshot_manager.h » ('j') | 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 #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
8 7
9 #include <map> 8 #include <map>
10 #include <string> 9 #include <string>
11 10
12 #include "base/basictypes.h" 11 #include "base/basictypes.h"
13 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
14 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
15 14
16 // HistogramSender handles the logistics of gathering up available histograms 15 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 16
30 // Snapshot all histograms, and transmit the delta. 17 // HistogramFlattener is an interface for the logistics of gathering up
31 // The arguments allow a derived class to select only a subset for 18 // available histograms for recording. The implementors handle the exact lower
32 // transmission, or to set a flag in each transmitted histogram. 19 // level recording mechanism, or error report mechanism.
33 void TransmitAllHistograms(base::Histogram::Flags flags_to_set, 20 class BASE_EXPORT HistogramFlattener {
34 bool send_only_uma); 21 public:
22 virtual void RecordDelta(const base::Histogram& histogram,
23 const base::Histogram::SampleSet& snapshot) = 0;
35 24
36 // Send the histograms onward, as defined in a derived class. 25 // 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; 26 virtual void InconsistencyDetected(int problem) = 0;
45 virtual void UniqueInconsistencyDetected(int problem) = 0; 27 virtual void UniqueInconsistencyDetected(int problem) = 0;
46 virtual void SnapshotProblemResolved(int amount) = 0; 28 virtual void SnapshotProblemResolved(int amount) = 0;
47 29
30 protected:
31 HistogramFlattener() {}
32 virtual ~HistogramFlattener() {}
33
48 private: 34 private:
49 // Maintain a map of histogram names to the sample stats we've sent. 35 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 }; 36 };
66 37
67 #endif // CHROME_COMMON_METRICS_HISTOGRAM_SENDER_H_ 38 } // namespace base
39
40 #endif // BASE_METRICS_HISTOGRAM_FLATTENER_H_
OLDNEW
« no previous file with comments | « base/base.gypi ('k') | base/metrics/histogram_snapshot_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698