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

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

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 years, 8 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_samples.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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // iterator, the steps can be performed separately. Call PerpareDelta() 59 // iterator, the steps can be performed separately. Call PerpareDelta()
60 // as many times as necessary with a single StartDeltas() before and 60 // as many times as necessary with a single StartDeltas() before and
61 // a single FinishDeltas() after. All passed histograms must live 61 // a single FinishDeltas() after. All passed histograms must live
62 // until FinishDeltas() completes. PrepareAbsolute() works the same 62 // until FinishDeltas() completes. PrepareAbsolute() works the same
63 // but assumes there were no previous logged values and no future deltas 63 // but assumes there were no previous logged values and no future deltas
64 // will be created (and thus can work on read-only histograms). 64 // will be created (and thus can work on read-only histograms).
65 // Use Prepare*TakingOwnership() if it is desireable to have this class 65 // Use Prepare*TakingOwnership() if it is desireable to have this class
66 // automatically delete the histogram once it is "finished". 66 // automatically delete the histogram once it is "finished".
67 void StartDeltas(); 67 void StartDeltas();
68 void PrepareDelta(HistogramBase* histogram); 68 void PrepareDelta(HistogramBase* histogram);
69 void PrepareDeltaTakingOwnership(scoped_ptr<HistogramBase> histogram); 69 void PrepareDeltaTakingOwnership(std::unique_ptr<HistogramBase> histogram);
70 void PrepareAbsolute(const HistogramBase* histogram); 70 void PrepareAbsolute(const HistogramBase* histogram);
71 void PrepareAbsoluteTakingOwnership( 71 void PrepareAbsoluteTakingOwnership(
72 scoped_ptr<const HistogramBase> histogram); 72 std::unique_ptr<const HistogramBase> histogram);
73 void FinishDeltas(); 73 void FinishDeltas();
74 74
75 private: 75 private:
76 FRIEND_TEST_ALL_PREFIXES(HistogramSnapshotManagerTest, CheckMerge); 76 FRIEND_TEST_ALL_PREFIXES(HistogramSnapshotManagerTest, CheckMerge);
77 77
78 // During a snapshot, samples are acquired and aggregated. This structure 78 // During a snapshot, samples are acquired and aggregated. This structure
79 // contains all the information collected for a given histogram. Once a 79 // contains all the information collected for a given histogram. Once a
80 // snapshot operation is finished, it is generally emptied except for 80 // snapshot operation is finished, it is generally emptied except for
81 // information that must persist from one report to the next, such as 81 // information that must persist from one report to the next, such as
82 // the "inconsistencies". 82 // the "inconsistencies".
(...skipping 10 matching lines...) Expand all
93 HistogramSamples* accumulated_samples = nullptr; 93 HistogramSamples* accumulated_samples = nullptr;
94 94
95 // The set of inconsistencies (flags) already seen for the histogram. 95 // The set of inconsistencies (flags) already seen for the histogram.
96 // See HistogramBase::Inconsistency for values. 96 // See HistogramBase::Inconsistency for values.
97 uint32_t inconsistencies = 0; 97 uint32_t inconsistencies = 0;
98 }; 98 };
99 99
100 // Capture and hold samples from a histogram. This does all the heavy 100 // Capture and hold samples from a histogram. This does all the heavy
101 // lifting for PrepareDelta() and PrepareAbsolute(). 101 // lifting for PrepareDelta() and PrepareAbsolute().
102 void PrepareSamples(const HistogramBase* histogram, 102 void PrepareSamples(const HistogramBase* histogram,
103 scoped_ptr<HistogramSamples> samples); 103 std::unique_ptr<HistogramSamples> samples);
104 104
105 // Try to detect and fix count inconsistency of logged samples. 105 // Try to detect and fix count inconsistency of logged samples.
106 void InspectLoggedSamplesInconsistency( 106 void InspectLoggedSamplesInconsistency(
107 const HistogramSamples& new_snapshot, 107 const HistogramSamples& new_snapshot,
108 HistogramSamples* logged_samples); 108 HistogramSamples* logged_samples);
109 109
110 // For histograms, track what has been previously seen, indexed 110 // For histograms, track what has been previously seen, indexed
111 // by the hash of the histogram name. 111 // by the hash of the histogram name.
112 std::map<uint64_t, SampleInfo> known_histograms_; 112 std::map<uint64_t, SampleInfo> known_histograms_;
113 113
114 // Collection of histograms of which ownership has been passed to this 114 // Collection of histograms of which ownership has been passed to this
115 // object. They will be deleted by FinishDeltas(). 115 // object. They will be deleted by FinishDeltas().
116 std::vector<scoped_ptr<const HistogramBase>> owned_histograms_; 116 std::vector<std::unique_ptr<const HistogramBase>> owned_histograms_;
117 117
118 // Indicates if deltas are currently being prepared. 118 // Indicates if deltas are currently being prepared.
119 bool preparing_deltas_; 119 bool preparing_deltas_;
120 120
121 // |histogram_flattener_| handles the logistics of recording the histogram 121 // |histogram_flattener_| handles the logistics of recording the histogram
122 // deltas. 122 // deltas.
123 HistogramFlattener* histogram_flattener_; // Weak. 123 HistogramFlattener* histogram_flattener_; // Weak.
124 124
125 DISALLOW_COPY_AND_ASSIGN(HistogramSnapshotManager); 125 DISALLOW_COPY_AND_ASSIGN(HistogramSnapshotManager);
126 }; 126 };
127 127
128 } // namespace base 128 } // namespace base
129 129
130 #endif // BASE_METRICS_HISTOGRAM_SNAPSHOT_MANAGER_H_ 130 #endif // BASE_METRICS_HISTOGRAM_SNAPSHOT_MANAGER_H_
OLDNEW
« no previous file with comments | « base/metrics/histogram_samples.cc ('k') | base/metrics/histogram_snapshot_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698