OLD | NEW |
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> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/metrics/histogram_base.h" | 16 #include "base/metrics/histogram_base.h" |
| 17 #include "base/threading/thread_checker.h" |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 | 20 |
20 class HistogramSamples; | 21 class HistogramSamples; |
21 class HistogramFlattener; | 22 class HistogramFlattener; |
22 | 23 |
23 // HistogramSnapshotManager handles the logistics of gathering up available | 24 // HistogramSnapshotManager handles the logistics of gathering up available |
24 // histograms for recording either to disk or for transmission (such as from | 25 // histograms for recording either to disk or for transmission (such as from |
25 // renderer to browser, or from browser to UMA upload). Since histograms can sit | 26 // renderer to browser, or from browser to UMA upload). Since histograms can sit |
26 // in memory for an extended period of time, and are vulnerable to memory | 27 // in memory for an extended period of time, and are vulnerable to memory |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // The set of inconsistencies (flags) already seen for the histogram. | 69 // The set of inconsistencies (flags) already seen for the histogram. |
69 // See HistogramBase::Inconsistency for values. | 70 // See HistogramBase::Inconsistency for values. |
70 uint32_t inconsistencies = 0; | 71 uint32_t inconsistencies = 0; |
71 }; | 72 }; |
72 | 73 |
73 // Capture and hold samples from a histogram. This does all the heavy | 74 // Capture and hold samples from a histogram. This does all the heavy |
74 // lifting for PrepareDelta() and PrepareAbsolute(). | 75 // lifting for PrepareDelta() and PrepareAbsolute(). |
75 void PrepareSamples(const HistogramBase* histogram, | 76 void PrepareSamples(const HistogramBase* histogram, |
76 std::unique_ptr<HistogramSamples> samples); | 77 std::unique_ptr<HistogramSamples> samples); |
77 | 78 |
78 // Try to detect and fix count inconsistency of logged samples. | |
79 void InspectLoggedSamplesInconsistency( | |
80 const HistogramSamples& new_snapshot, | |
81 HistogramSamples* logged_samples); | |
82 | |
83 // For histograms, track what has been previously seen, indexed | 79 // For histograms, track what has been previously seen, indexed |
84 // by the hash of the histogram name. | 80 // by the hash of the histogram name. |
85 std::map<uint64_t, SampleInfo> known_histograms_; | 81 std::map<uint64_t, SampleInfo> known_histograms_; |
86 | 82 |
87 // |histogram_flattener_| handles the logistics of recording the histogram | 83 // |histogram_flattener_| handles the logistics of recording the histogram |
88 // deltas. | 84 // deltas. |
89 HistogramFlattener* histogram_flattener_; // Weak. | 85 HistogramFlattener* histogram_flattener_; // Weak. |
90 | 86 |
| 87 ThreadChecker thread_checker_; |
| 88 |
91 DISALLOW_COPY_AND_ASSIGN(HistogramSnapshotManager); | 89 DISALLOW_COPY_AND_ASSIGN(HistogramSnapshotManager); |
92 }; | 90 }; |
93 | 91 |
94 } // namespace base | 92 } // namespace base |
95 | 93 |
96 #endif // BASE_METRICS_HISTOGRAM_SNAPSHOT_MANAGER_H_ | 94 #endif // BASE_METRICS_HISTOGRAM_SNAPSHOT_MANAGER_H_ |
OLD | NEW |