Home | History | Annotate | Download | only in metrics
      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 
      5 #ifndef BASE_TEST_METRICS_HISTOGRAM_ENUM_READER_H_
      6 #define BASE_TEST_METRICS_HISTOGRAM_ENUM_READER_H_
      7 
      8 #include <map>
      9 #include <string>
     10 
     11 #include "base/metrics/histogram_base.h"
     12 #include "base/optional.h"
     13 
     14 namespace base {
     15 
     16 using HistogramEnumEntryMap = std::map<HistogramBase::Sample, std::string>;
     17 
     18 // Find and read the enum with the given |enum_name| (with integer values) from
     19 // tools/metrics/histograms/enums.xml.
     20 //
     21 // Returns map { value => label } so that:
     22 //   <int value="9" label="enable-pinch-virtual-viewport"/>
     23 // becomes:
     24 //   { 9 => "enable-pinch-virtual-viewport" }
     25 // Returns empty base::nullopt on failure.
     26 base::Optional<HistogramEnumEntryMap> ReadEnumFromEnumsXml(
     27     const std::string& enum_name);
     28 
     29 }  // namespace base
     30 
     31 #endif  // BASE_TEST_METRICS_HISTOGRAM_ENUM_READER_H_
     32