Index: base/metrics/bucket_ranges.h |
diff --git a/base/metrics/bucket_ranges.h b/base/metrics/bucket_ranges.h |
index c356195ba78ca2716897463b576f73a26bbe9b70..db82e552b3ac5c193ffbed00e7c195008dd15681 100644 |
--- a/base/metrics/bucket_ranges.h |
+++ b/base/metrics/bucket_ranges.h |
@@ -24,6 +24,7 @@ |
#include <limits.h> |
+#include "base/atomicops.h" |
#include "base/base_export.h" |
#include "base/macros.h" |
#include "base/metrics/histogram_base.h" |
@@ -58,6 +59,17 @@ class BASE_EXPORT BucketRanges { |
// Return true iff |other| object has same ranges_ as |this| object's ranges_. |
bool Equals(const BucketRanges* other) const; |
+ // Set and get a reference into persistent memory where this bucket data |
+ // can be found (and re-used). These calls are internally atomic with no |
+ // safety against overwriting an existing value since though it is wasteful |
+ // to have multiple identical persistent records, it is still safe. |
+ void set_persistent_reference(uint32_t ref) const { |
+ subtle::NoBarrier_Store(&persistent_reference_, ref); |
+ } |
+ uint32_t persistent_reference() const { |
+ return subtle::NoBarrier_Load(&persistent_reference_); |
+ } |
+ |
private: |
// A monotonically increasing list of values which determine which bucket to |
// put a sample into. For each index, show the smallest sample that can be |
@@ -71,6 +83,12 @@ class BASE_EXPORT BucketRanges { |
// noise on UMA dashboard. |
uint32_t checksum_; |
+ // A reference into a global PersistentMemoryAllocator where the ranges |
+ // information is stored. This allows for the record to be created once and |
+ // re-used simply by having all histograms with the same ranges use the |
+ // same reference. |
+ mutable subtle::Atomic32 persistent_reference_ = 0; |
+ |
DISALLOW_COPY_AND_ASSIGN(BucketRanges); |
}; |