1 // Copyright 2017 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_DUMMY_HISTOGRAM_H_ 6 #define BASE_METRICS_DUMMY_HISTOGRAM_H_ 7 8 #include <stdint.h> 9 10 #include <memory> 11 #include <string> 12 13 #include "base/base_export.h" 14 #include "base/metrics/histogram_base.h" 15 #include "base/no_destructor.h" 16 17 namespace base { 18 19 // DummyHistogram is used for mocking histogram objects for histograms that 20 // shouldn't be recorded. It doesn't do any actual processing. 21 class BASE_EXPORT DummyHistogram : public HistogramBase { 22 public: 23 static DummyHistogram* GetInstance(); 24 25 // HistogramBase: CheckName(const StringPiece & name)26 void CheckName(const StringPiece& name) const override {} 27 uint64_t name_hash() const override; 28 HistogramType GetHistogramType() const override; 29 bool HasConstructionArguments(Sample expected_minimum, 30 Sample expected_maximum, 31 uint32_t expected_bucket_count) const override; Add(Sample value)32 void Add(Sample value) override {} AddCount(Sample value,int count)33 void AddCount(Sample value, int count) override {} AddSamples(const HistogramSamples & samples)34 void AddSamples(const HistogramSamples& samples) override {} 35 bool AddSamplesFromPickle(PickleIterator* iter) override; 36 std::unique_ptr<HistogramSamples> SnapshotSamples() const override; 37 std::unique_ptr<HistogramSamples> SnapshotDelta() override; 38 std::unique_ptr<HistogramSamples> SnapshotFinalDelta() const override; WriteHTMLGraph(std::string * output)39 void WriteHTMLGraph(std::string* output) const override {} WriteAscii(std::string * output)40 void WriteAscii(std::string* output) const override {} 41 42 protected: 43 // HistogramBase: SerializeInfoImpl(Pickle * pickle)44 void SerializeInfoImpl(Pickle* pickle) const override {} GetParameters(DictionaryValue * params)45 void GetParameters(DictionaryValue* params) const override {} GetCountAndBucketData(Count * count,int64_t * sum,ListValue * buckets)46 void GetCountAndBucketData(Count* count, 47 int64_t* sum, 48 ListValue* buckets) const override {} 49 50 private: 51 friend class NoDestructor<DummyHistogram>; 52 DummyHistogram()53 DummyHistogram() : HistogramBase("dummy_histogram") {} ~DummyHistogram()54 ~DummyHistogram() override {} 55 56 DISALLOW_COPY_AND_ASSIGN(DummyHistogram); 57 }; 58 59 } // namespace base 60 61 #endif // BASE_METRICS_DUMMY_HISTOGRAM_H_ 62