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

Side by Side Diff: base/metrics/histogram_snapshot_manager.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
Property Changes:
Added: svn:executable
## -0,0 +1 ##
+*
Added: svn:eol-style
## -0,0 +1 ##
+LF
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 BASE_METRICS_HISTOGRAM_SNAPSHOT_MANAGER_H_
6 #define BASE_METRICS_HISTOGRAM_SNAPSHOT_MANAGER_H_
7 #pragma once
8
9 #include <map>
10 #include <string>
11
12 #include "base/basictypes.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/metrics/histogram.h"
15 #include "base/metrics/histogram_flattener.h"
16
17 namespace base {
18
19 // HistogramSnapshotManager handles the logistics of gathering up available
20 // histograms for recording either to disk or for transmission (such as from
21 // renderer to browser, or from browser to UMA upload). Since histograms can sit
22 // in memory for an extended period of time, and are vulnerable to memory
23 // corruption, this class also validates as much rendundancy as it can before
24 // calling for the marginal change (a.k.a., delta) in a histogram to be
25 // recorded.
26 class BASE_EXPORT HistogramSnapshotManager {
27 public:
28 explicit HistogramSnapshotManager(HistogramFlattener* histogram_flattener);
29 virtual ~HistogramSnapshotManager();
30
31 // Snapshot all histograms, and ask |histogram_flattener_| to record the
32 // delta. The arguments allow selecting only a subset of histograms for
33 // recording, or to set a flag in each recorded histogram.
34 void PrepareDeltas(base::Histogram::Flags flags_to_set, bool record_only_uma);
35
36 private:
37 // Maintain a map of histogram names to the sample stats we've recorded.
38 typedef std::map<std::string, base::Histogram::SampleSet> LoggedSampleMap;
39 // List of histograms names, and their encontered corruptions.
40 typedef std::map<std::string, int> ProblemMap;
41
42 // Snapshot this histogram, and record the delta.
43 void PrepareDelta(const base::Histogram& histogram);
44
45 // For histograms, track what we've already recorded (as a sample for
46 // each histogram) so that we can record only the delta with the next log.
47 LoggedSampleMap logged_samples_;
48
49 // List of histograms found corrupt to be corrupt, and their problems.
50 scoped_ptr<ProblemMap> inconsistencies_;
51
52 // |histogram_flattener_| handles the logistics of recording the histogram
53 // deltas.
54 HistogramFlattener* histogram_flattener_; // Weak.
55
56 DISALLOW_COPY_AND_ASSIGN(HistogramSnapshotManager);
57 };
58
59 } // namespace base
60
61 #endif // BASE_METRICS_HISTOGRAM_SNAPSHOT_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698