skia_histogram.cc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2016 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. #include "skia/ext/skia_histogram.h"
  5. #include <type_traits>
  6. #include "base/metrics/histogram_macros_internal.h"
  7. namespace skia {
  8. // Wrapper around HISTOGRAM_POINTER_USE - mimics UMA_HISTOGRAM_BOOLEAN but
  9. // allows for an external atomic_histogram_pointer.
  10. void HistogramBoolean(std::atomic_uintptr_t* atomic_histogram_pointer,
  11. const char* name,
  12. bool sample) {
  13. HISTOGRAM_POINTER_USE(
  14. atomic_histogram_pointer, name, AddBoolean(sample),
  15. base::BooleanHistogram::FactoryGet(
  16. name, base::HistogramBase::kUmaTargetedHistogramFlag));
  17. }
  18. // Wrapper around HISTOGRAM_POINTER_USE - mimics UMA_HISTOGRAM_EXACT_LINEAR but
  19. // allows for an external atomic_histogram_pointer.
  20. void HistogramExactLinear(std::atomic_uintptr_t* atomic_histogram_pointer,
  21. const char* name,
  22. int sample,
  23. int value_max) {
  24. HISTOGRAM_POINTER_USE(atomic_histogram_pointer, name, Add(sample),
  25. base::LinearHistogram::FactoryGet(
  26. name, 1, value_max, value_max + 1,
  27. base::HistogramBase::kUmaTargetedHistogramFlag));
  28. }
  29. // Wrapper around HISTOGRAM_POINTER_USE - mimics UMA_HISTOGRAM_MEMORY_KB but
  30. // allows for an external atomic_histogram_pointer.
  31. void HistogramMemoryKB(std::atomic_uintptr_t* atomic_histogram_pointer,
  32. const char* name,
  33. int sample) {
  34. HISTOGRAM_POINTER_USE(atomic_histogram_pointer, name, Add(sample),
  35. base::Histogram::FactoryGet(
  36. name, 1000, 500000, 50,
  37. base::HistogramBase::kUmaTargetedHistogramFlag));
  38. }
  39. } // namespace skia