Chromium Code Reviews| 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_; |