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

Unified Diff: base/metrics/histogram_base.cc

Issue 11682003: Serialize/Deserialize support in HistogramBase (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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.cc
diff --git a/base/metrics/histogram_base.cc b/base/metrics/histogram_base.cc
index bcfb57feb231ce7be9b31bbf4eb34b0e8b441b0d..2854fd4d0fb15d473b41b5f2d61c86fc788f1e53 100644
--- a/base/metrics/histogram_base.cc
+++ b/base/metrics/histogram_base.cc
@@ -9,6 +9,10 @@
#include "base/logging.h"
#include "base/json/json_string_value_serializer.h"
#include "base/memory/scoped_ptr.h"
+#include "base/metrics/histogram.h"
+#include "base/metrics/histogram_samples.h"
+#include "base/metrics/sparse_histogram.h"
+#include "base/pickle.h"
#include "base/values.h"
namespace base {
@@ -39,6 +43,28 @@ HistogramBase::HistogramBase(const std::string& name)
HistogramBase::~HistogramBase() {}
+// static
+HistogramBase* HistogramBase::DeserializeHistogramInfo(PickleIterator* iter) {
+ int type;
+ if (!iter->ReadInt(&type))
+ return NULL;
+
+ switch (type) {
+ case HISTOGRAM:
+ return Histogram::DeserializeHistogramInfo(iter);
+ case LINEAR_HISTOGRAM:
+ return LinearHistogram::DeserializeHistogramInfo(iter);
+ case BOOLEAN_HISTOGRAM:
+ return BooleanHistogram::DeserializeHistogramInfo(iter);
+ case CUSTOM_HISTOGRAM:
+ return CustomHistogram::DeserializeHistogramInfo(iter);
+ case SPARSE_HISTOGRAM:
+ return SparseHistogram::DeserializeHistogramInfo(iter);
+ default:
+ return NULL;
+ }
+}
+
void HistogramBase::SetFlags(int32 flags) {
flags_ |= flags;
}
@@ -47,6 +73,12 @@ void HistogramBase::ClearFlags(int32 flags) {
flags_ &= ~flags;
}
+bool HistogramBase::SerializeInfo(Pickle* pickle) const {
+ if (!pickle->WriteInt(GetHistogramType()))
+ return false;
+ return SerializeInfoImpl(pickle);
+}
+
void HistogramBase::WriteJSON(std::string* output) const {
Count count;
scoped_ptr<ListValue> buckets(new ListValue());

Powered by Google App Engine
This is Rietveld 408576698