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

Unified Diff: base/metrics/persistent_sample_map.h

Issue 1909673002: Support negative sample values in PersistentHistogramMap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: get kAllSamples value directly from PersistentSampleMap class Created 4 years, 8 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 | « no previous file | base/metrics/persistent_sample_map.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/persistent_sample_map.h
diff --git a/base/metrics/persistent_sample_map.h b/base/metrics/persistent_sample_map.h
index 6cde349390db6acfd7cdf5771b847a505e3253af..10be75f22cc3b7ca2261e6d70cd8cb06b4614639 100644
--- a/base/metrics/persistent_sample_map.h
+++ b/base/metrics/persistent_sample_map.h
@@ -15,6 +15,7 @@
#include <memory>
#include "base/compiler_specific.h"
+#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/histogram_samples.h"
@@ -81,7 +82,12 @@ class BASE_EXPORT PersistentSampleMap : public HistogramSamples {
HistogramBase::Sample value);
private:
- enum : HistogramBase::Sample { kAllSamples = -1 };
+ FRIEND_TEST_ALL_PREFIXES(PersistentSampleMapTest, PersistenceTest);
+
+ // Since all values are possible in a SparseHistogram, the value of
+ // kAllSamples is chosen to be something unlikely. In the case that this
+ // value is used within the sample map, it is still safe.
+ enum : HistogramBase::Sample { kAllSamples = -10000 };
Alexei Svitkine (slow) 2016/04/20 21:51:18 Can we avoid having this constant completely? For
Alexei Svitkine (slow) 2016/04/20 21:51:55 Or a separate boolean parameter?
bcwhite 2016/04/21 10:33:15 Sure, though the two parameters would generally be
// Imports samples from persistent memory by iterating over all sample
// records found therein, adding them to the sample_counts_ map. If a
« no previous file with comments | « no previous file | base/metrics/persistent_sample_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698