Chromium Code Reviews| Index: base/metrics/histogram_delta_serializer.h |
| diff --git a/base/metrics/histogram_delta_serializer.h b/base/metrics/histogram_delta_serializer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..092c3b5461057695e7e4dc273a1e8f20bfbb92aa |
| --- /dev/null |
| +++ b/base/metrics/histogram_delta_serializer.h |
| @@ -0,0 +1,62 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BASE_METRICS_HISTOGRAM_DELTA_SERIALIZER_BASE_H_ |
| +#define BASE_METRICS_HISTOGRAM_DELTA_SERIALIZER_BASE_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/base_export.h" |
| +#include "base/basictypes.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/metrics/histogram_flattener.h" |
| +#include "base/metrics/histogram_snapshot_manager.h" |
| + |
| +namespace base { |
| + |
| +class HistogramBase; |
| + |
| +// Serializes and restores histograms deltas. |
| +class BASE_EXPORT HistogramDeltasSerializer : public HistogramFlattener { |
| + public: |
| + // |caller_name| is string used in histograms for counting inconsistencies. |
| + explicit HistogramDeltasSerializer(const std::string& caller_name); |
| + virtual ~HistogramDeltasSerializer(); |
| + |
| + // Returns serialized deltas in histograms counters happened after previous |
| + // call. |
|
Ilya Sherman
2013/10/17 22:41:47
nit: I'd suggest a wording more like: "Computes de
Vitaly Buka (NO REVIEWS)
2013/10/18 05:33:35
Done.
|
| + const std::vector<std::string>& GetNewDeltas(); |
| + |
| + // Deserialize deltas and add samples to corresponding histograms, creating |
| + // them if necessary. Silently ignores errors in |deltas|. |
| + static void DeserializeAndAddSamples(const std::vector<std::string>& deltas); |
| + |
| + private: |
| + // HistogramFlattener implementation. |
| + virtual void RecordDelta(const HistogramBase& histogram, |
| + const HistogramSamples& snapshot) OVERRIDE; |
| + virtual void InconsistencyDetected( |
| + HistogramBase::Inconsistency problem) OVERRIDE; |
| + virtual void UniqueInconsistencyDetected( |
| + HistogramBase::Inconsistency problem) OVERRIDE; |
| + virtual void InconsistencyDetectedInLoggedCount(int amount) OVERRIDE; |
| + |
| + // Calculates deltas in histogram counters. |
| + HistogramSnapshotManager histogram_snapshot_manager_; |
| + |
| + // Output buffet for serialized deltas. |
|
Ilya Sherman
2013/10/17 22:41:47
nit: "buffet" -> "buffer"
Vitaly Buka (NO REVIEWS)
2013/10/18 05:33:35
Done.
|
| + std::vector<std::string> serialized_deltas_; |
| + |
| + // Histograms to count inconsistencies in snapshots. |
| + HistogramBase* inconsistencies_histogram_; |
| + HistogramBase* inconsistencies_unique_histogram_; |
| + HistogramBase* inconsistent_stapshot_histogram_; |
|
Ilya Sherman
2013/10/17 22:41:47
nit: "stapshot" -> "snapshot"
Vitaly Buka (NO REVIEWS)
2013/10/18 05:33:35
Done.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(HistogramDeltasSerializer); |
| +}; |
| + |
| +} // namespace base |
| + |
| +#endif // BASE_METRICS_HISTOGRAM_DELTA_SERIALIZER_BASE_H_ |