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

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

Issue 1425533011: Support "shared" histograms between processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shmem-alloc
Patch Set: moved Create-Result histogram to private space and added to histograms.xml Created 4 years, 10 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
« no previous file with comments | « base/metrics/histogram_persistence.cc ('k') | base/metrics/histogram_snapshot_manager.cc » ('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 BASE_METRICS_HISTOGRAM_SNAPSHOT_MANAGER_H_ 5 #ifndef BASE_METRICS_HISTOGRAM_SNAPSHOT_MANAGER_H_
6 #define BASE_METRICS_HISTOGRAM_SNAPSHOT_MANAGER_H_ 6 #define BASE_METRICS_HISTOGRAM_SNAPSHOT_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 18 matching lines...) Expand all
29 public: 29 public:
30 explicit HistogramSnapshotManager(HistogramFlattener* histogram_flattener); 30 explicit HistogramSnapshotManager(HistogramFlattener* histogram_flattener);
31 virtual ~HistogramSnapshotManager(); 31 virtual ~HistogramSnapshotManager();
32 32
33 // Snapshot all histograms, and ask |histogram_flattener_| to record the 33 // Snapshot all histograms, and ask |histogram_flattener_| to record the
34 // delta. |flags_to_set| is used to set flags for each histogram. 34 // delta. |flags_to_set| is used to set flags for each histogram.
35 // |required_flags| is used to select histograms to be recorded. 35 // |required_flags| is used to select histograms to be recorded.
36 // Only histograms that have all the flags specified by the argument will be 36 // Only histograms that have all the flags specified by the argument will be
37 // chosen. If all histograms should be recorded, set it to 37 // chosen. If all histograms should be recorded, set it to
38 // |Histogram::kNoFlags|. 38 // |Histogram::kNoFlags|.
39 void PrepareDeltas(HistogramBase::Flags flags_to_set, 39 template <class ForwardHistogramIterator>
40 HistogramBase::Flags required_flags); 40 void PrepareDeltas(ForwardHistogramIterator begin,
41 ForwardHistogramIterator end,
42 HistogramBase::Flags flags_to_set,
43 HistogramBase::Flags required_flags) {
44 for (ForwardHistogramIterator it = begin; it != end; ++it) {
45 (*it)->SetFlags(flags_to_set);
46 if (((*it)->flags() & required_flags) == required_flags)
47 PrepareDelta(**it);
48 }
49 }
41 50
42 private: 51 private:
43 // Snapshot this histogram, and record the delta. 52 // Snapshot this histogram, and record the delta.
44 void PrepareDelta(const HistogramBase& histogram); 53 void PrepareDelta(const HistogramBase& histogram);
45 54
46 // Try to detect and fix count inconsistency of logged samples. 55 // Try to detect and fix count inconsistency of logged samples.
47 void InspectLoggedSamplesInconsistency( 56 void InspectLoggedSamplesInconsistency(
48 const HistogramSamples& new_snapshot, 57 const HistogramSamples& new_snapshot,
49 HistogramSamples* logged_samples); 58 HistogramSamples* logged_samples);
50 59
51 // For histograms, track what we've already recorded (as a sample for 60 // For histograms, track what we've already recorded (as a sample for
52 // each histogram) so that we can record only the delta with the next log. 61 // each histogram) so that we can record only the delta with the next log.
53 // The information is indexed by the hash of the histogram name. 62 // The information is indexed by the hash of the histogram name.
54 std::map<uint64_t, HistogramSamples*> logged_samples_; 63 std::map<uint64_t, HistogramSamples*> logged_samples_;
55 64
56 // Set of histograms found to be corrupt and their problems, indexed 65 // Set of histograms found to be corrupt and their problems, indexed
57 // by the hash of the histogram name. 66 // by the hash of the histogram name.
58 std::map<uint64_t, int> inconsistencies_; 67 std::map<uint64_t, int> inconsistencies_;
59 68
60 // |histogram_flattener_| handles the logistics of recording the histogram 69 // |histogram_flattener_| handles the logistics of recording the histogram
61 // deltas. 70 // deltas.
62 HistogramFlattener* histogram_flattener_; // Weak. 71 HistogramFlattener* histogram_flattener_; // Weak.
63 72
64 DISALLOW_COPY_AND_ASSIGN(HistogramSnapshotManager); 73 DISALLOW_COPY_AND_ASSIGN(HistogramSnapshotManager);
65 }; 74 };
66 75
67 } // namespace base 76 } // namespace base
68 77
69 #endif // BASE_METRICS_HISTOGRAM_SNAPSHOT_MANAGER_H_ 78 #endif // BASE_METRICS_HISTOGRAM_SNAPSHOT_MANAGER_H_
OLDNEW
« no previous file with comments | « base/metrics/histogram_persistence.cc ('k') | base/metrics/histogram_snapshot_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698