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

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

Powered by Google App Engine
This is Rietveld 408576698