1*6777b538SAndroid Build Coastguard Worker // Copyright 2024 The Chromium Authors 2*6777b538SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be 3*6777b538SAndroid Build Coastguard Worker // found in the LICENSE file. 4*6777b538SAndroid Build Coastguard Worker 5*6777b538SAndroid Build Coastguard Worker #ifndef BASE_FEATURE_VISITOR_H_ 6*6777b538SAndroid Build Coastguard Worker #define BASE_FEATURE_VISITOR_H_ 7*6777b538SAndroid Build Coastguard Worker 8*6777b538SAndroid Build Coastguard Worker #include <map> 9*6777b538SAndroid Build Coastguard Worker #include <string> 10*6777b538SAndroid Build Coastguard Worker 11*6777b538SAndroid Build Coastguard Worker #include "base/feature_list.h" 12*6777b538SAndroid Build Coastguard Worker #include "build/chromeos_buildflags.h" 13*6777b538SAndroid Build Coastguard Worker 14*6777b538SAndroid Build Coastguard Worker static_assert(BUILDFLAG(IS_CHROMEOS_ASH), "For ChromeOS ash-chrome only"); 15*6777b538SAndroid Build Coastguard Worker 16*6777b538SAndroid Build Coastguard Worker namespace variations::cros_early_boot::evaluate_seed { 17*6777b538SAndroid Build Coastguard Worker class EarlyBootFeatureVisitor; 18*6777b538SAndroid Build Coastguard Worker } 19*6777b538SAndroid Build Coastguard Worker 20*6777b538SAndroid Build Coastguard Worker namespace base { 21*6777b538SAndroid Build Coastguard Worker 22*6777b538SAndroid Build Coastguard Worker class TestFeatureVisitor; 23*6777b538SAndroid Build Coastguard Worker 24*6777b538SAndroid Build Coastguard Worker // An interface for EarlyBootFeatureVisitor that provides a method to 25*6777b538SAndroid Build Coastguard Worker // iterate over a feature's name, override state, parameters, and associated 26*6777b538SAndroid Build Coastguard Worker // field trial. 27*6777b538SAndroid Build Coastguard Worker // 28*6777b538SAndroid Build Coastguard Worker // NOTE: This is intended only for the special case of needing to get all 29*6777b538SAndroid Build Coastguard Worker // feature overrides. Most users should call FeatureList::IsEnabled() to query 30*6777b538SAndroid Build Coastguard Worker // a feature's state. 31*6777b538SAndroid Build Coastguard Worker class FeatureVisitor { 32*6777b538SAndroid Build Coastguard Worker public: 33*6777b538SAndroid Build Coastguard Worker FeatureVisitor(const FeatureVisitor&) = delete; 34*6777b538SAndroid Build Coastguard Worker FeatureVisitor& operator=(const FeatureVisitor&) = delete; 35*6777b538SAndroid Build Coastguard Worker 36*6777b538SAndroid Build Coastguard Worker virtual ~FeatureVisitor() = default; 37*6777b538SAndroid Build Coastguard Worker 38*6777b538SAndroid Build Coastguard Worker // Intended to be called in FeatureList::VisitFeaturesAndParams(). This method 39*6777b538SAndroid Build Coastguard Worker // is called once per feature. 40*6777b538SAndroid Build Coastguard Worker virtual void Visit(const std::string& feature_name, 41*6777b538SAndroid Build Coastguard Worker FeatureList::OverrideState override_state, 42*6777b538SAndroid Build Coastguard Worker const std::map<std::string, std::string>& params, 43*6777b538SAndroid Build Coastguard Worker const std::string& trial_name, 44*6777b538SAndroid Build Coastguard Worker const std::string& group_name) = 0; 45*6777b538SAndroid Build Coastguard Worker 46*6777b538SAndroid Build Coastguard Worker private: 47*6777b538SAndroid Build Coastguard Worker friend variations::cros_early_boot::evaluate_seed::EarlyBootFeatureVisitor; 48*6777b538SAndroid Build Coastguard Worker friend TestFeatureVisitor; 49*6777b538SAndroid Build Coastguard Worker 50*6777b538SAndroid Build Coastguard Worker // The constructor is private so only friend classes can inherit from this 51*6777b538SAndroid Build Coastguard Worker // class. This limits access to who can iterate over features in 52*6777b538SAndroid Build Coastguard Worker // FeatureList::VisitFeaturesAndParams(). 53*6777b538SAndroid Build Coastguard Worker FeatureVisitor() = default; 54*6777b538SAndroid Build Coastguard Worker }; 55*6777b538SAndroid Build Coastguard Worker 56*6777b538SAndroid Build Coastguard Worker } // namespace base 57*6777b538SAndroid Build Coastguard Worker 58*6777b538SAndroid Build Coastguard Worker #endif // BASE_FEATURE_VISITOR_H_ 59