| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef BASE_METRICS_HISTOGRAM_SAMPLES_H_ | 5 #ifndef BASE_METRICS_HISTOGRAM_SAMPLES_H_ |
| 6 #define BASE_METRICS_HISTOGRAM_SAMPLES_H_ | 6 #define BASE_METRICS_HISTOGRAM_SAMPLES_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> |
| 12 |
| 11 #include "base/atomicops.h" | 13 #include "base/atomicops.h" |
| 12 #include "base/macros.h" | 14 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/metrics/histogram_base.h" | 15 #include "base/metrics/histogram_base.h" |
| 15 | 16 |
| 16 namespace base { | 17 namespace base { |
| 17 | 18 |
| 18 class Pickle; | 19 class Pickle; |
| 19 class PickleIterator; | 20 class PickleIterator; |
| 20 class SampleCountIterator; | 21 class SampleCountIterator; |
| 21 | 22 |
| 22 // HistogramSamples is a container storing all samples of a histogram. All | 23 // HistogramSamples is a container storing all samples of a histogram. All |
| 23 // elements must be of a fixed width to ensure 32/64-bit interoperability. | 24 // elements must be of a fixed width to ensure 32/64-bit interoperability. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 virtual HistogramBase::Count GetCount(HistogramBase::Sample value) const = 0; | 62 virtual HistogramBase::Count GetCount(HistogramBase::Sample value) const = 0; |
| 62 virtual HistogramBase::Count TotalCount() const = 0; | 63 virtual HistogramBase::Count TotalCount() const = 0; |
| 63 | 64 |
| 64 virtual void Add(const HistogramSamples& other); | 65 virtual void Add(const HistogramSamples& other); |
| 65 | 66 |
| 66 // Add from serialized samples. | 67 // Add from serialized samples. |
| 67 virtual bool AddFromPickle(PickleIterator* iter); | 68 virtual bool AddFromPickle(PickleIterator* iter); |
| 68 | 69 |
| 69 virtual void Subtract(const HistogramSamples& other); | 70 virtual void Subtract(const HistogramSamples& other); |
| 70 | 71 |
| 71 virtual scoped_ptr<SampleCountIterator> Iterator() const = 0; | 72 virtual std::unique_ptr<SampleCountIterator> Iterator() const = 0; |
| 72 virtual bool Serialize(Pickle* pickle) const; | 73 virtual bool Serialize(Pickle* pickle) const; |
| 73 | 74 |
| 74 // Accessor fuctions. | 75 // Accessor fuctions. |
| 75 uint64_t id() const { return meta_->id; } | 76 uint64_t id() const { return meta_->id; } |
| 76 int64_t sum() const { return meta_->sum; } | 77 int64_t sum() const { return meta_->sum; } |
| 77 HistogramBase::Count redundant_count() const { | 78 HistogramBase::Count redundant_count() const { |
| 78 return subtle::NoBarrier_Load(&meta_->redundant_count); | 79 return subtle::NoBarrier_Load(&meta_->redundant_count); |
| 79 } | 80 } |
| 80 | 81 |
| 81 protected: | 82 protected: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 112 | 113 |
| 113 // Get the index of current histogram bucket. | 114 // Get the index of current histogram bucket. |
| 114 // For histograms that don't use predefined buckets, it returns false. | 115 // For histograms that don't use predefined buckets, it returns false. |
| 115 // Requires: !Done(); | 116 // Requires: !Done(); |
| 116 virtual bool GetBucketIndex(size_t* index) const; | 117 virtual bool GetBucketIndex(size_t* index) const; |
| 117 }; | 118 }; |
| 118 | 119 |
| 119 } // namespace base | 120 } // namespace base |
| 120 | 121 |
| 121 #endif // BASE_METRICS_HISTOGRAM_SAMPLES_H_ | 122 #endif // BASE_METRICS_HISTOGRAM_SAMPLES_H_ |
| OLD | NEW |