Compute can_use_lcd_text using property trees.
[chromium-blink-merge.git] / base / metrics / histogram_delta_serialization.h
bloba379914c0db48c23be5c910330c026a507431145
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_METRICS_HISTOGRAM_DELTA_SERIALIZATION_H_
6 #define BASE_METRICS_HISTOGRAM_DELTA_SERIALIZATION_H_
8 #include <string>
9 #include <vector>
11 #include "base/base_export.h"
12 #include "base/basictypes.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/metrics/histogram_flattener.h"
15 #include "base/metrics/histogram_snapshot_manager.h"
17 namespace base {
19 class HistogramBase;
21 // Serializes and restores histograms deltas.
22 class BASE_EXPORT HistogramDeltaSerialization : public HistogramFlattener {
23 public:
24 // |caller_name| is string used in histograms for counting inconsistencies.
25 explicit HistogramDeltaSerialization(const std::string& caller_name);
26 ~HistogramDeltaSerialization() override;
28 // Computes deltas in histogram bucket counts relative to the previous call to
29 // this method. Stores the deltas in serialized form into |serialized_deltas|.
30 // If |serialized_deltas| is NULL, no data is serialized, though the next call
31 // will compute the deltas relative to this one.
32 void PrepareAndSerializeDeltas(std::vector<std::string>* serialized_deltas);
34 // Deserialize deltas and add samples to corresponding histograms, creating
35 // them if necessary. Silently ignores errors in |serialized_deltas|.
36 static void DeserializeAndAddSamples(
37 const std::vector<std::string>& serialized_deltas);
39 private:
40 // HistogramFlattener implementation.
41 void RecordDelta(const HistogramBase& histogram,
42 const HistogramSamples& snapshot) override;
43 void InconsistencyDetected(HistogramBase::Inconsistency problem) override;
44 void UniqueInconsistencyDetected(
45 HistogramBase::Inconsistency problem) override;
46 void InconsistencyDetectedInLoggedCount(int amount) override;
48 // Calculates deltas in histogram counters.
49 HistogramSnapshotManager histogram_snapshot_manager_;
51 // Output buffer for serialized deltas.
52 std::vector<std::string>* serialized_deltas_;
54 // Histograms to count inconsistencies in snapshots.
55 HistogramBase* inconsistencies_histogram_;
56 HistogramBase* inconsistencies_unique_histogram_;
57 HistogramBase* inconsistent_snapshot_histogram_;
59 DISALLOW_COPY_AND_ASSIGN(HistogramDeltaSerialization);
62 } // namespace base
64 #endif // BASE_METRICS_HISTOGRAM_DELTA_SERIALIZATION_H_