1 // Copyright 2023 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.
5 #ifndef BASE_ANDROID_FEATURE_MAP_H_
6 #define BASE_ANDROID_FEATURE_MAP_H_
8 #include "base/base_export.h"
9 #include "base/containers/flat_map.h"
10 #include "base/feature_list.h"
11 #include "base/strings/string_piece_forward.h"
13 namespace base::android {
15 // A FeatureMap is a mapping from base:Feature's names to a pointer to the
17 // This is necessary because in Java, features flags are identified by the
18 // feature name, a string, so calls from Java to (for example) check the state
19 // of a feature flag need to convert the string to a non-owning Feature*.
20 // Each component should have its own FeatureMap.
21 class BASE_EXPORT FeatureMap {
23 explicit FeatureMap(std::vector<const Feature*> featuresExposedToJava);
26 // Map a |feature_name| to a Feature*.
27 const Feature* FindFeatureExposedToJava(const StringPiece& feature_name);
30 flat_map<StringPiece, const Feature*> mapping_;
33 } // namespace base::android
35 #endif // BASE_ANDROID_FEATURE_MAP_H_