Index: base/metrics/persistent_histogram_allocator.h |
diff --git a/base/metrics/persistent_histogram_allocator.h b/base/metrics/persistent_histogram_allocator.h |
index cc8d0233d3d337456651fe9ae9cdadca82d22f0f..527e19c4c5cb1207724740a4e30fba9e559b738b 100644 |
--- a/base/metrics/persistent_histogram_allocator.h |
+++ b/base/metrics/persistent_histogram_allocator.h |
@@ -22,19 +22,36 @@ BASE_EXPORT extern const Feature kPersistentHistogramsFeature; |
// This class manages histograms created within a PersistentMemoryAllocator. |
class BASE_EXPORT PersistentHistogramAllocator { |
public: |
- // This iterator is used for fetching persistent histograms from an allocator. |
- class Iterator { |
+ using Reference = PersistentMemoryAllocator::Reference; |
+ |
+ // Iterator used for fetching persistent histograms from an allocator. |
+ // It is lock-free and thread-safe. |
+ // See PersistentMemoryAllocator::Iterator for more information. |
+ class BASE_EXPORT Iterator { |
public: |
- bool is_clear() { return memory_iter.is_clear(); } |
+ Iterator(PersistentHistogramAllocator* allocator); |
Ilya Sherman
2016/03/24 02:03:58
nit: explicit
Ilya Sherman
2016/03/24 02:03:58
nit: Please document lifetime expectations for the
bcwhite
2016/03/24 14:22:34
Done.
bcwhite
2016/03/24 14:22:34
Done.
|
+ |
+ // Gets the next histogram from persistent memory. Null will be returned |
+ // if there are no more histograms to return. This may still be called |
Ilya Sherman
2016/03/24 02:03:58
Optional nit: s/Null will be returned/Returns null
bcwhite
2016/03/24 14:22:34
Done.
|
+ // again later to retrieve any new histograms added in the meantime. |
+ scoped_ptr<HistogramBase> GetNext() { return GetNextWithIgnore(0); } |
private: |
friend class PersistentHistogramAllocator; |
- // The iterator used for stepping through persistent memory iterables. |
- PersistentMemoryAllocator::Iterator memory_iter; |
- }; |
+ // Gets the next histogram from persistent memory, ignoring one particular |
+ // reference in the process. Pass |ignore| of zero (0) to ignore nothing. |
+ scoped_ptr<HistogramBase> GetNextWithIgnore(Reference ignore); |
- using Reference = PersistentMemoryAllocator::Reference; |
+ // Weak-pointer to histogram allocator being iterated over. |
+ PersistentHistogramAllocator* allocator_; |
+ |
+ // The iterator used for stepping through objects in persistent memory. |
+ // It is lock-free and thread-safe which is why this class is also so. |
+ PersistentMemoryAllocator::Iterator memory_iter_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(Iterator); |
+ }; |
// A PersistentHistogramAllocator is constructed from a PersistentMemory- |
// Allocator object of which it takes ownership. |
@@ -63,14 +80,6 @@ class BASE_EXPORT PersistentHistogramAllocator { |
// This method will return null if any problem is detected with the data. |
scoped_ptr<HistogramBase> GetHistogram(Reference ref); |
- // Get the next histogram in persistent data based on iterator. |
- scoped_ptr<HistogramBase> GetNextHistogram(Iterator* iter) { |
- return GetNextHistogramWithIgnore(iter, 0); |
- } |
- |
- // Create an iterator for going through all histograms in an allocator. |
- void CreateIterator(Iterator* iter); |
- |
// Allocate a new persistent histogram. The returned histogram will not |
// be able to be located by other allocators until it is "finalized". |
scoped_ptr<HistogramBase> AllocateHistogram( |