Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef BASE_METRICS_HISTOGRAM_DELTA_SERIALIZER_BASE_H_ | |
|
darin (slow to review)
2013/10/21 21:59:58
nit: include guard is wrong
Vitaly Buka (NO REVIEWS)
2013/10/21 23:05:32
Done.
| |
| 6 #define BASE_METRICS_HISTOGRAM_DELTA_SERIALIZER_BASE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 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" | |
| 16 | |
| 17 namespace base { | |
| 18 | |
| 19 class HistogramBase; | |
| 20 | |
| 21 // Serializes and restores histograms deltas. | |
| 22 class BASE_EXPORT HistogramDeltasSerializer : public HistogramFlattener { | |
|
darin (slow to review)
2013/10/21 21:59:58
nit: the file name and class name do not precisely
Vitaly Buka (NO REVIEWS)
2013/10/21 23:05:32
Done.
| |
| 23 public: | |
| 24 // |caller_name| is string used in histograms for counting inconsistencies. | |
| 25 explicit HistogramDeltasSerializer(const std::string& caller_name); | |
| 26 virtual ~HistogramDeltasSerializer(); | |
| 27 | |
| 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); | |
| 33 | |
| 34 // Deserialize deltas and add samples to corresponding histograms, creating | |
| 35 // them if necessary. Silently ignores errors in |deltas|. | |
| 36 static void DeserializeAndAddSamples(const std::vector<std::string>& deltas); | |
|
darin (slow to review)
2013/10/21 21:59:58
nit: Is this class really a Serializer if it provi
Vitaly Buka (NO REVIEWS)
2013/10/21 23:05:32
Done.
| |
| 37 | |
| 38 private: | |
| 39 // HistogramFlattener implementation. | |
| 40 virtual void RecordDelta(const HistogramBase& histogram, | |
| 41 const HistogramSamples& snapshot) OVERRIDE; | |
| 42 virtual void InconsistencyDetected( | |
| 43 HistogramBase::Inconsistency problem) OVERRIDE; | |
| 44 virtual void UniqueInconsistencyDetected( | |
| 45 HistogramBase::Inconsistency problem) OVERRIDE; | |
| 46 virtual void InconsistencyDetectedInLoggedCount(int amount) OVERRIDE; | |
| 47 | |
| 48 // Calculates deltas in histogram counters. | |
| 49 HistogramSnapshotManager histogram_snapshot_manager_; | |
| 50 | |
| 51 // Output buffer for serialized deltas. | |
| 52 std::vector<std::string>* serialized_deltas_; | |
| 53 | |
| 54 // Histograms to count inconsistencies in snapshots. | |
| 55 HistogramBase* inconsistencies_histogram_; | |
| 56 HistogramBase* inconsistencies_unique_histogram_; | |
| 57 HistogramBase* inconsistent_snapshot_histogram_; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(HistogramDeltasSerializer); | |
| 60 }; | |
| 61 | |
| 62 } // namespace base | |
| 63 | |
| 64 #endif // BASE_METRICS_HISTOGRAM_DELTA_SERIALIZER_BASE_H_ | |
| OLD | NEW |