Chromium Code Reviews| Index: base/metrics/histogram_base.h |
| diff --git a/base/metrics/histogram_base.h b/base/metrics/histogram_base.h |
| index 302795a73fc7a4072bb4fc26ccb86461a5f790c0..5a9d413f76401df515d9f9860850782934ac5f36 100644 |
| --- a/base/metrics/histogram_base.h |
| +++ b/base/metrics/histogram_base.h |
| @@ -11,6 +11,9 @@ |
| #include "base/basictypes.h" |
| #include "base/memory/scoped_ptr.h" |
| +class Pickle; |
| +class PickleIterator; |
| + |
| namespace base { |
| class DictionaryValue; |
| @@ -59,6 +62,10 @@ class BASE_EXPORT HistogramBase { |
| HistogramBase(const std::string& name); |
| virtual ~HistogramBase(); |
| + // Create or find existing histogram that matches the pickled info. Returns |
| + // NULL if the pickled data has problems. |
| + static HistogramBase* DeserializeHistogramInfo(PickleIterator* iter); |
| + |
| std::string histogram_name() const { return histogram_name_; } |
| // Operations with Flags enum. |
| @@ -69,14 +76,22 @@ class BASE_EXPORT HistogramBase { |
| virtual HistogramType GetHistogramType() const = 0; |
| // Whether the histogram has construction arguments as parameters specified. |
| - // For histograms that don't have the concept of minimum, maximum or |
| - // bucket_count, this function always returns false. |
| + // For histograms that don't have the concept of |minimum|, |maximum| or |
| + // |bucket_count|, this function always returns false. |
| virtual bool HasConstructionArguments(Sample minimum, |
| Sample maximum, |
| size_t bucket_count) const = 0; |
| virtual void Add(Sample value) = 0; |
| + virtual void AddSamples(const HistogramSamples& samples) = 0; |
| + virtual bool AddSamplesFromPickle(PickleIterator* iter) = 0; |
| + |
| + // Serialize the histogram info into |pickle|. |
| + // Note. This only serialize construction info of the histogram, but not |
| + // serialize the samples. |
|
Ilya Sherman
2012/12/29 00:17:30
nit: "Note: This only serializes the construction
kaiwang
2013/01/08 00:51:40
Done.
|
| + bool SerializeInfo(Pickle* pickle) const; |
| + |
| // Snapshot the current complete set of sample data. |
| // Override with atomic/locked snapshot if needed. |
| virtual scoped_ptr<HistogramSamples> SnapshotSamples() const = 0; |
| @@ -91,6 +106,9 @@ class BASE_EXPORT HistogramBase { |
| void WriteJSON(std::string* output) const; |
| protected: |
| + // Subclasses should implement this function to make SerializeInfo work. |
| + virtual bool SerializeInfoImpl(Pickle* pickle) const = 0; |
| + |
| // Writes information about the construction parameters in |params|. |
| virtual void GetParameters(DictionaryValue* params) const = 0; |