Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Unified Diff: base/metrics/histogram_base.h

Issue 11682003: Serialize/Deserialize support in HistogramBase (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Some changes about deserializing Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/metrics/histogram_base.h
diff --git a/base/metrics/histogram_base.h b/base/metrics/histogram_base.h
index 302795a73fc7a4072bb4fc26ccb86461a5f790c0..53cb3e9b9400fa76ad7be3ff5eba61f674cf13c0 100644
--- a/base/metrics/histogram_base.h
+++ b/base/metrics/histogram_base.h
@@ -11,9 +11,13 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
+class Pickle;
+class PickleIterator;
+
namespace base {
class DictionaryValue;
+class HistogramBase;
class HistogramSamples;
class ListValue;
@@ -32,6 +36,13 @@ enum BASE_EXPORT HistogramType {
std::string HistogramTypeToString(HistogramType type);
+// Create or find existing histogram that matches the pickled info.
+// Returns NULL if the pickled data has problems.
+HistogramBase* DeserializeHistogramInfo(PickleIterator* iter);
Ilya Sherman 2013/01/09 05:48:37 nit: Please tuck this into an anonymous namespace
kaiwang 2013/01/10 23:02:24 It's used by unittest. Although this is not direct
+
+// Create or find existing histogram and add the samples from pickle.
+bool DeserializeHistogramAndAddSamples(PickleIterator* iter);
Ilya Sherman 2013/01/09 05:48:37 nit: Why does this function need a return value?
kaiwang 2013/01/10 23:02:24 Done.
+
////////////////////////////////////////////////////////////////////////////////
class BASE_EXPORT HistogramBase {
@@ -69,14 +80,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 serializes the construction arguments of the histogram, but
Ilya Sherman 2013/01/09 05:48:37 nit: "Note." -> "Note:"; "but not" -> "but does no
kaiwang 2013/01/10 23:02:24 Done.
+ // not serialize the samples.
+ 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 +110,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;

Powered by Google App Engine
This is Rietveld 408576698