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

Unified Diff: base/metrics/statistics_recorder.h

Issue 2036643004: Create ForTesting method rather than declaring a dozen "friend" classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 6 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/sparse_histogram_unittest.cc ('k') | base/metrics/statistics_recorder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/statistics_recorder.h
diff --git a/base/metrics/statistics_recorder.h b/base/metrics/statistics_recorder.h
index f40bb4e5495fcaa21fbdc59b9b22d65751ec9e29..002758e840e1aa404409e6a14785615e790c9ce5 100644
--- a/base/metrics/statistics_recorder.h
+++ b/base/metrics/statistics_recorder.h
@@ -172,7 +172,15 @@ class BASE_EXPORT StatisticsRecorder {
// memory is being released.
static void ForgetHistogramForTesting(base::StringPiece name);
- // Reset any global instance of the statistics-recorder that was created
+ // Creates a local StatisticsRecorder object for testing purposes. All new
+ // histograms will be registered in it until it is destructed or pushed
+ // aside for the lifetime of yet another SR object. The destruction of the
+ // returned object will re-activate the previous one. Always release SR
+ // objects in the opposite order to which they're created.
+ static std::unique_ptr<StatisticsRecorder> CreateTemporaryForTesting()
+ WARN_UNUSED_RESULT;
+
+ // Resets any global instance of the statistics-recorder that was created
// by a call to Initialize().
static void UninitializeForTesting();
@@ -187,17 +195,6 @@ class BASE_EXPORT StatisticsRecorder {
typedef std::map<uint32_t, std::list<const BucketRanges*>*> RangesMap;
friend struct DefaultLazyInstanceTraits<StatisticsRecorder>;
- friend class ::SubprocessMetricsProviderTest;
- friend class HistogramBaseTest;
- friend class HistogramSnapshotManagerTest;
- friend class HistogramTest;
- friend class JsonPrefStoreTest;
- friend class PersistentHistogramAllocatorTest;
- friend class SharedHistogramTest;
- friend class SparseHistogramTest;
- friend class StatisticsRecorderTest;
- FRIEND_TEST_ALL_PREFIXES(HistogramDeltaSerializationTest,
- DeserializeHistogramAndAddSamples);
// Imports histograms from global persistent memory. The global lock must
// not be held during this call.
« no previous file with comments | « base/metrics/sparse_histogram_unittest.cc ('k') | base/metrics/statistics_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698