histogram_enum_reader.h 994 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2018 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_TEST_METRICS_HISTOGRAM_ENUM_READER_H_
  5. #define BASE_TEST_METRICS_HISTOGRAM_ENUM_READER_H_
  6. #include <map>
  7. #include <string>
  8. #include "base/metrics/histogram_base.h"
  9. #include "third_party/abseil-cpp/absl/types/optional.h"
  10. namespace base {
  11. using HistogramEnumEntryMap = std::map<HistogramBase::Sample, std::string>;
  12. // Find and read the enum with the given |enum_name| (with integer values) from
  13. // tools/metrics/histograms/enums.xml.
  14. //
  15. // Returns map { value => label } so that:
  16. // <int value="9" label="enable-pinch-virtual-viewport"/>
  17. // becomes:
  18. // { 9 => "enable-pinch-virtual-viewport" }
  19. // Returns empty absl::nullopt on failure.
  20. absl::optional<HistogramEnumEntryMap> ReadEnumFromEnumsXml(
  21. const std::string& enum_name);
  22. } // namespace base
  23. #endif // BASE_TEST_METRICS_HISTOGRAM_ENUM_READER_H_