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

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: test needs to clear out statistics-recorder before releasing histogram memory 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 3010a6d703bf3f67bca9dde01c9f6f87a5e7fb5f..5d6889ba02739272264e697fa79ee5b29f488891 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"
@@ -61,9 +62,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(scoped_ptr<HistogramBase> histogram);
void PrepareOnce(const HistogramBase* histogram);
+ void PrepareOnceTakingOwnership(scoped_ptr<const HistogramBase> histogram);
void FinishDeltas();
private:
@@ -98,7 +103,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(
@@ -109,6 +115,10 @@ class BASE_EXPORT HistogramSnapshotManager {
// by the hash of the histogram name.
std::map<uint64_t, SampleInfo> known_histograms_;
+ // Collection of histograms of which ownership has been passed to this
+ // object. They will be deleted by FinishDeltas().
+ std::vector<scoped_ptr<const HistogramBase>> owned_histograms_;
+
// Indicates if deltas are currently being prepared.
bool preparing_deltas_;

Powered by Google App Engine
This is Rietveld 408576698