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

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: added a couple tests (and fixed related issues) Created 5 years 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
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 <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 16 matching lines...) Expand all
27 public: 27 public:
28 explicit HistogramSnapshotManager(HistogramFlattener* histogram_flattener); 28 explicit HistogramSnapshotManager(HistogramFlattener* histogram_flattener);
29 virtual ~HistogramSnapshotManager(); 29 virtual ~HistogramSnapshotManager();
30 30
31 // Snapshot all histograms, and ask |histogram_flattener_| to record the 31 // Snapshot all histograms, and ask |histogram_flattener_| to record the
32 // delta. |flags_to_set| is used to set flags for each histogram. 32 // delta. |flags_to_set| is used to set flags for each histogram.
33 // |required_flags| is used to select histograms to be recorded. 33 // |required_flags| is used to select histograms to be recorded.
34 // Only histograms that have all the flags specified by the argument will be 34 // Only histograms that have all the flags specified by the argument will be
35 // chosen. If all histograms should be recorded, set it to 35 // chosen. If all histograms should be recorded, set it to
36 // |Histogram::kNoFlags|. 36 // |Histogram::kNoFlags|.
37 void PrepareDeltas(HistogramBase::Flags flags_to_set, 37 template <class ForwardHistogramIterator>
38 HistogramBase::Flags required_flags); 38 void PrepareDeltas(ForwardHistogramIterator begin,
39 ForwardHistogramIterator end,
40 HistogramBase::Flags flags_to_set,
41 HistogramBase::Flags required_flags) {
42 for (ForwardHistogramIterator it = begin; it != end; ++it) {
43 (*it)->SetFlags(flags_to_set);
44 if (((*it)->flags() & required_flags) == required_flags)
45 PrepareDelta(**it);
46 }
47 }
39 48
40 private: 49 private:
41 // Snapshot this histogram, and record the delta. 50 // Snapshot this histogram, and record the delta.
42 void PrepareDelta(const HistogramBase& histogram); 51 void PrepareDelta(const HistogramBase& histogram);
43 52
44 // Try to detect and fix count inconsistency of logged samples. 53 // Try to detect and fix count inconsistency of logged samples.
45 void InspectLoggedSamplesInconsistency( 54 void InspectLoggedSamplesInconsistency(
46 const HistogramSamples& new_snapshot, 55 const HistogramSamples& new_snapshot,
47 HistogramSamples* logged_samples); 56 HistogramSamples* logged_samples);
48 57
49 // For histograms, track what we've already recorded (as a sample for 58 // For histograms, track what we've already recorded (as a sample for
50 // each histogram) so that we can record only the delta with the next log. 59 // each histogram) so that we can record only the delta with the next log.
51 std::map<uint64_t, HistogramSamples*> logged_samples_; 60 std::map<uint64_t, HistogramSamples*> logged_samples_;
52 61
53 // List of histograms found to be corrupt, and their problems. 62 // List of histograms found to be corrupt, and their problems.
54 std::map<uint64_t, int> inconsistencies_; 63 std::map<uint64_t, int> inconsistencies_;
55 64
56 // |histogram_flattener_| handles the logistics of recording the histogram 65 // |histogram_flattener_| handles the logistics of recording the histogram
57 // deltas. 66 // deltas.
58 HistogramFlattener* histogram_flattener_; // Weak. 67 HistogramFlattener* histogram_flattener_; // Weak.
59 68
60 DISALLOW_COPY_AND_ASSIGN(HistogramSnapshotManager); 69 DISALLOW_COPY_AND_ASSIGN(HistogramSnapshotManager);
61 }; 70 };
62 71
63 } // namespace base 72 } // namespace base
64 73
65 #endif // BASE_METRICS_HISTOGRAM_SNAPSHOT_MANAGER_H_ 74 #endif // BASE_METRICS_HISTOGRAM_SNAPSHOT_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698