1 // Copyright 2021 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "components/metrics/structured/event_validator.h" 6 7 #include <cstdint> 8 #include <string_view> 9 10 namespace metrics::structured { 11 EventValidator(uint64_t event_hash,bool force_record)12EventValidator::EventValidator(uint64_t event_hash, bool force_record) 13 : event_hash_(event_hash), force_record_(force_record) {} 14 EventValidator::~EventValidator() = default; 15 event_hash() const16uint64_t EventValidator::event_hash() const { 17 return event_hash_; 18 } 19 can_force_record() const20bool EventValidator::can_force_record() const { 21 return force_record_; 22 } 23 GetMetricMetadata(const std::string & metric_name) const24std::optional<EventValidator::MetricMetadata> EventValidator::GetMetricMetadata( 25 const std::string& metric_name) const { 26 const auto it = metric_metadata_.find(metric_name); 27 if (it == metric_metadata_.end()) { 28 return std::nullopt; 29 } 30 return it->second; 31 } 32 GetMetricName(uint64_t metric_name_hash) const33std::optional<std::string_view> EventValidator::GetMetricName( 34 uint64_t metric_name_hash) const { 35 const auto it = metrics_name_map_.find(metric_name_hash); 36 if (it == metrics_name_map_.end()) { 37 return std::nullopt; 38 } 39 return it->second; 40 } 41 42 } // namespace metrics::structured 43