| Index: base/metrics/histogram_base.cc
|
| diff --git a/base/metrics/histogram_base.cc b/base/metrics/histogram_base.cc
|
| index bcfb57feb231ce7be9b31bbf4eb34b0e8b441b0d..63961327a0422fdc9ef75f2f2e160459c8f1afcc 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 {
|
| @@ -31,6 +35,41 @@ std::string HistogramTypeToString(HistogramType type) {
|
| return "UNKNOWN";
|
| }
|
|
|
| +HistogramBase* DeserializeHistogramInfo(PickleIterator* iter) {
|
| + int type;
|
| + if (!iter->ReadInt(&type))
|
| + return NULL;
|
| +
|
| + switch (type) {
|
| + case HISTOGRAM:
|
| + return Histogram::DeserializeInfoImpl(iter);
|
| + case LINEAR_HISTOGRAM:
|
| + return LinearHistogram::DeserializeInfoImpl(iter);
|
| + case BOOLEAN_HISTOGRAM:
|
| + return BooleanHistogram::DeserializeInfoImpl(iter);
|
| + case CUSTOM_HISTOGRAM:
|
| + return CustomHistogram::DeserializeInfoImpl(iter);
|
| + case SPARSE_HISTOGRAM:
|
| + return SparseHistogram::DeserializeInfoImpl(iter);
|
| + default:
|
| + return NULL;
|
| + }
|
| +}
|
| +
|
| +void DeserializeHistogramAndAddSamples(PickleIterator* iter) {
|
| + HistogramBase* histogram = DeserializeHistogramInfo(iter);
|
| + if (!histogram)
|
| + return;
|
| +
|
| + if (histogram->flags() & base::HistogramBase::kIPCSerializationSourceFlag) {
|
| + DVLOG(1) << "Single process mode, histogram observed and not copied: "
|
| + << histogram->histogram_name();
|
| + return;
|
| + }
|
| + histogram->AddSamplesFromPickle(iter);
|
| +}
|
| +
|
| +
|
| const HistogramBase::Sample HistogramBase::kSampleType_MAX = INT_MAX;
|
|
|
| HistogramBase::HistogramBase(const std::string& name)
|
| @@ -47,6 +86,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());
|
|
|