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

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: moved allocator create/destroy to be beside snapshot (simpler code) Created 4 years, 11 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);
grt (UTC plus 2) 2016/02/04 15:36:42 take a scoped_ptr rather than a raw ptr so that th
bcwhite 2016/02/04 21:51:13 These call through to the private PrepareSamples w
grt (UTC plus 2) 2016/02/08 18:09:18 SGTM.
bcwhite 2016/02/09 21:08:45 Done.
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_;
+
// Indicates if deltas are currently being prepared.
bool preparing_deltas_;

Powered by Google App Engine
This is Rietveld 408576698