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

Unified Diff: base/metrics/histogram_snapshot_manager.h

Issue 1891913002: Support saving browser metrics to disk and reading them during next run. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed some unnecessary includes Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/metrics/histogram_base.h ('k') | base/metrics/histogram_snapshot_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/histogram_snapshot_manager.h
diff --git a/base/metrics/histogram_snapshot_manager.h b/base/metrics/histogram_snapshot_manager.h
index 42dbac225d830838db4f998020265ec8fe03e380..83bd5feaa85ca9a0c51414ca0ed3f6f4bb5ba969 100644
--- a/base/metrics/histogram_snapshot_manager.h
+++ b/base/metrics/histogram_snapshot_manager.h
@@ -40,18 +40,28 @@ class BASE_EXPORT HistogramSnapshotManager {
// |Histogram::kNoFlags|. Though any "forward" iterator will work, the
// histograms over which it iterates *must* remain valid until this method
// returns; the iterator cannot deallocate histograms once it iterates past
- // them.
+ // them and FinishDeltas() has been called after. StartDeltas() must be
+ // called before.
template <class ForwardHistogramIterator>
- void PrepareDeltas(ForwardHistogramIterator begin,
- ForwardHistogramIterator end,
- HistogramBase::Flags flags_to_set,
- HistogramBase::Flags required_flags) {
- StartDeltas();
+ void PrepareDeltasWithoutStartFinish(ForwardHistogramIterator begin,
+ ForwardHistogramIterator end,
+ HistogramBase::Flags flags_to_set,
+ HistogramBase::Flags required_flags) {
for (ForwardHistogramIterator it = begin; it != end; ++it) {
(*it)->SetFlags(flags_to_set);
if (((*it)->flags() & required_flags) == required_flags)
PrepareDelta(*it);
}
+ }
+
+ // As above but also calls StartDeltas() and FinishDeltas().
+ template <class ForwardHistogramIterator>
+ void PrepareDeltas(ForwardHistogramIterator begin,
+ ForwardHistogramIterator end,
+ HistogramBase::Flags flags_to_set,
+ HistogramBase::Flags required_flags) {
+ StartDeltas();
+ PrepareDeltasWithoutStartFinish(begin, end, flags_to_set, required_flags);
FinishDeltas();
}
@@ -62,6 +72,9 @@ class BASE_EXPORT HistogramSnapshotManager {
// until FinishDeltas() completes. PrepareAbsolute() works the same
// but assumes there were no previous logged values and no future deltas
// will be created (and thus can work on read-only histograms).
+ // PrepareFinalDelta() works like PrepareDelta() except that it does
+ // not update the previous logged values and can thus be used with
+ // read-only files.
// Use Prepare*TakingOwnership() if it is desireable to have this class
// automatically delete the histogram once it is "finished".
void StartDeltas();
@@ -70,6 +83,8 @@ class BASE_EXPORT HistogramSnapshotManager {
void PrepareAbsolute(const HistogramBase* histogram);
void PrepareAbsoluteTakingOwnership(
std::unique_ptr<const HistogramBase> histogram);
+ void PrepareFinalDeltaTakingOwnership(
+ std::unique_ptr<const HistogramBase> histogram);
void FinishDeltas();
private:
« no previous file with comments | « base/metrics/histogram_base.h ('k') | base/metrics/histogram_snapshot_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698