123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- #ifndef BASE_METRICS_PERSISTENT_SAMPLE_MAP_H_
- #define BASE_METRICS_PERSISTENT_SAMPLE_MAP_H_
- #include <stdint.h>
- #include <map>
- #include <memory>
- #include "base/compiler_specific.h"
- #include "base/macros.h"
- #include "base/metrics/histogram_base.h"
- #include "base/metrics/histogram_samples.h"
- #include "base/metrics/persistent_memory_allocator.h"
- namespace base {
- class PersistentHistogramAllocator;
- class PersistentSampleMapRecords;
- class BASE_EXPORT PersistentSampleMap : public HistogramSamples {
- public:
-
-
- PersistentSampleMap(uint64_t id,
- PersistentHistogramAllocator* allocator,
- Metadata* meta);
- ~PersistentSampleMap() override;
-
- void Accumulate(HistogramBase::Sample value,
- HistogramBase::Count count) override;
- HistogramBase::Count GetCount(HistogramBase::Sample value) const override;
- HistogramBase::Count TotalCount() const override;
- std::unique_ptr<SampleCountIterator> Iterator() const override;
-
-
-
- static PersistentMemoryAllocator::Reference GetNextPersistentRecord(
- PersistentMemoryAllocator::Iterator& iterator,
- uint64_t* sample_map_id);
-
-
- static PersistentMemoryAllocator::Reference CreatePersistentRecord(
- PersistentMemoryAllocator* allocator,
- uint64_t sample_map_id,
- HistogramBase::Sample value);
- protected:
-
- bool AddSubtractImpl(SampleCountIterator* iter, Operator op) override;
-
-
- HistogramBase::Count* GetSampleCountStorage(HistogramBase::Sample value);
-
-
- HistogramBase::Count* GetOrCreateSampleCountStorage(
- HistogramBase::Sample value);
- private:
-
-
- PersistentSampleMapRecords* GetRecords();
-
-
-
-
-
-
-
- HistogramBase::Count* ImportSamples(HistogramBase::Sample until_value,
- bool import_everything);
-
-
-
- std::map<HistogramBase::Sample, HistogramBase::Count*> sample_counts_;
-
-
- PersistentHistogramAllocator* allocator_;
-
-
-
-
- PersistentSampleMapRecords* records_ = nullptr;
- DISALLOW_COPY_AND_ASSIGN(PersistentSampleMap);
- };
- }
- #endif
|