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

Unified Diff: base/metrics/histogram_snapshot_manager.h

Issue 1537743006: Persist setup metrics and have Chrome report them during UMA upload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shared-histograms
Patch Set: address (many) comments by Greg 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 side-by-side diff with in-line comments
Download patch
Index: base/metrics/histogram_snapshot_manager.h
diff --git a/base/metrics/histogram_snapshot_manager.h b/base/metrics/histogram_snapshot_manager.h
index 97bd693966fd6b1ed8ef2c84bcaaafee9eb8a0bc..c991fa6e64d597b2b7db8849bd5e13f97f142060 100644
--- a/base/metrics/histogram_snapshot_manager.h
+++ b/base/metrics/histogram_snapshot_manager.h
@@ -9,6 +9,7 @@
#include <map>
#include <string>
+#include <vector>
#include "base/gtest_prod_util.h"
#include "base/macros.h"
@@ -83,9 +84,13 @@ class BASE_EXPORT HistogramSnapshotManager {
// until FinishDeltas() completes. PrepareOnce() 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).
+ // Use Prepare*TakingOwnership() if it is desireable to have this class
+ // automatically delete the histogram once it is "finished".
void StartDeltas();
void PrepareDelta(HistogramBase* histogram);
+ void PrepareDeltaTakingOwnership(HistogramBase* histogram);
void PrepareOnce(const HistogramBase* histogram);
+ void PrepareOnceTakingOwnership(const HistogramBase* histogram);
void FinishDeltas();
private:
@@ -94,7 +99,8 @@ class BASE_EXPORT HistogramSnapshotManager {
// Capture and hold samples from a histogram. This does all the heavy
// lifting for PrepareDelta() and PrepareOnce().
void PrepareSamples(const HistogramBase* histogram,
- scoped_ptr<HistogramSamples> samples);
+ scoped_ptr<HistogramSamples> samples,
+ bool take_ownership);
// Try to detect and fix count inconsistency of logged samples.
void InspectLoggedSamplesInconsistency(
@@ -105,6 +111,10 @@ class BASE_EXPORT HistogramSnapshotManager {
// by the hash of the histogram name.
HashInfoMap known_histograms_;
+ // Collection of histograms of which ownership has been passed to this
+ // object. They will be deleted by FinishDeltas().
+ std::vector<const HistogramBase*> owned_histograms_;
grt (UTC plus 2) 2016/02/08 18:09:18 use std::vector<scoped_ptr<HistogramBase>> here. c
bcwhite 2016/02/09 21:08:45 Done. Is this new? A lot of code uses STL utils
grt (UTC plus 2) 2016/02/10 16:01:53 It is fairly new, yes: https://groups.google.com/a
+
// Indicates if deltas are currently being prepared.
bool preparing_deltas_;

Powered by Google App Engine
This is Rietveld 408576698