| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // PersistentSampleMap implements HistogramSamples interface. It is used | 5 // PersistentSampleMap implements HistogramSamples interface. It is used |
| 6 // by the SparseHistogram class to store samples in persistent memory which | 6 // by the SparseHistogram class to store samples in persistent memory which |
| 7 // allows it to be shared between processes or live across restarts. | 7 // allows it to be shared between processes or live across restarts. |
| 8 | 8 |
| 9 #ifndef BASE_METRICS_PERSISTENT_SAMPLE_MAP_H_ | 9 #ifndef BASE_METRICS_PERSISTENT_SAMPLE_MAP_H_ |
| 10 #define BASE_METRICS_PERSISTENT_SAMPLE_MAP_H_ | 10 #define BASE_METRICS_PERSISTENT_SAMPLE_MAP_H_ |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // Gets a pointer to a "count" corresponding to a given |value|. Returns NULL | 74 // Gets a pointer to a "count" corresponding to a given |value|. Returns NULL |
| 75 // if sample does not exist. | 75 // if sample does not exist. |
| 76 HistogramBase::Count* GetSampleCountStorage(HistogramBase::Sample value); | 76 HistogramBase::Count* GetSampleCountStorage(HistogramBase::Sample value); |
| 77 | 77 |
| 78 // Gets a pointer to a "count" corresponding to a given |value|, creating | 78 // Gets a pointer to a "count" corresponding to a given |value|, creating |
| 79 // the sample (initialized to zero) if it does not already exists. | 79 // the sample (initialized to zero) if it does not already exists. |
| 80 HistogramBase::Count* GetOrCreateSampleCountStorage( | 80 HistogramBase::Count* GetOrCreateSampleCountStorage( |
| 81 HistogramBase::Sample value); | 81 HistogramBase::Sample value); |
| 82 | 82 |
| 83 private: | 83 private: |
| 84 enum : HistogramBase::Sample { kAllSamples = -1 }; | |
| 85 | |
| 86 // Imports samples from persistent memory by iterating over all sample | 84 // Imports samples from persistent memory by iterating over all sample |
| 87 // records found therein, adding them to the sample_counts_ map. If a | 85 // records found therein, adding them to the sample_counts_ map. If a |
| 88 // count for the sample |until_value| is found, stop the import and return | 86 // count for the sample |until_value| is found, stop the import and return |
| 89 // a pointer to that counter. If that value is not found, null will be | 87 // a pointer to that counter. If that value is not found, null will be |
| 90 // returned after all currently available samples have been loaded. Pass | 88 // returned after all currently available samples have been loaded. Pass |
| 91 // kAllSamples to force the importing of all available samples. | 89 // true for |import_everything| to force the importing of all available |
| 92 HistogramBase::Count* ImportSamples(HistogramBase::Sample until_value); | 90 // samples even if a match is found. |
| 91 HistogramBase::Count* ImportSamples(HistogramBase::Sample until_value, |
| 92 bool import_everything); |
| 93 | 93 |
| 94 // All created/loaded sample values and their associated counts. The storage | 94 // All created/loaded sample values and their associated counts. The storage |
| 95 // for the actual Count numbers is owned by the |records_| object and its | 95 // for the actual Count numbers is owned by the |records_| object and its |
| 96 // underlying allocator. | 96 // underlying allocator. |
| 97 std::map<HistogramBase::Sample, HistogramBase::Count*> sample_counts_; | 97 std::map<HistogramBase::Sample, HistogramBase::Count*> sample_counts_; |
| 98 | 98 |
| 99 // The object that manages records inside persistent memory. This is owned | 99 // The object that manages records inside persistent memory. This is owned |
| 100 // externally (typically by a PersistentHistogramAllocator) and is expected | 100 // externally (typically by a PersistentHistogramAllocator) and is expected |
| 101 // to live beyond the life of this object. | 101 // to live beyond the life of this object. |
| 102 PersistentSampleMapRecords* records_; | 102 PersistentSampleMapRecords* records_; |
| 103 | 103 |
| 104 DISALLOW_COPY_AND_ASSIGN(PersistentSampleMap); | 104 DISALLOW_COPY_AND_ASSIGN(PersistentSampleMap); |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 } // namespace base | 107 } // namespace base |
| 108 | 108 |
| 109 #endif // BASE_METRICS_PERSISTENT_SAMPLE_MAP_H_ | 109 #endif // BASE_METRICS_PERSISTENT_SAMPLE_MAP_H_ |
| OLD | NEW |