dummy_histogram.h 2.0 KB

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