| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_FEATURE_LIST_H_ | 5 #ifndef BASE_FEATURE_LIST_H_ |
| 6 #define BASE_FEATURE_LIST_H_ | 6 #define BASE_FEATURE_LIST_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // only after the instance has been initialized and registered. | 134 // only after the instance has been initialized and registered. |
| 135 void GetFeatureOverrides(std::string* enable_overrides, | 135 void GetFeatureOverrides(std::string* enable_overrides, |
| 136 std::string* disable_overrides); | 136 std::string* disable_overrides); |
| 137 | 137 |
| 138 // Returns whether the given |feature| is enabled. Must only be called after | 138 // Returns whether the given |feature| is enabled. Must only be called after |
| 139 // the singleton instance has been registered via SetInstance(). Additionally, | 139 // the singleton instance has been registered via SetInstance(). Additionally, |
| 140 // a feature with a given name must only have a single corresponding Feature | 140 // a feature with a given name must only have a single corresponding Feature |
| 141 // struct, which is checked in builds with DCHECKs enabled. | 141 // struct, which is checked in builds with DCHECKs enabled. |
| 142 static bool IsEnabled(const Feature& feature); | 142 static bool IsEnabled(const Feature& feature); |
| 143 | 143 |
| 144 // Returns the field trial associated with the given |feature|. Must only be |
| 145 // called after the singleton instance has been registered via SetInstance(). |
| 146 static FieldTrial* GetFieldTrial(const Feature& feature); |
| 147 |
| 144 // Splits a comma-separated string containing feature names into a vector. | 148 // Splits a comma-separated string containing feature names into a vector. |
| 145 static std::vector<std::string> SplitFeatureListString( | 149 static std::vector<std::string> SplitFeatureListString( |
| 146 const std::string& input); | 150 const std::string& input); |
| 147 | 151 |
| 148 // Initializes and sets an instance of FeatureList with feature overrides via | 152 // Initializes and sets an instance of FeatureList with feature overrides via |
| 149 // command-line flags |enable_features| and |disable_features| if one has not | 153 // command-line flags |enable_features| and |disable_features| if one has not |
| 150 // already been set from command-line flags. Returns true if an instance did | 154 // already been set from command-line flags. Returns true if an instance did |
| 151 // not previously exist. See InitializeFromCommandLine() for more details | 155 // not previously exist. See InitializeFromCommandLine() for more details |
| 152 // about |enable_features| and |disable_features| parameters. | 156 // about |enable_features| and |disable_features| parameters. |
| 153 static bool InitializeInstance(const std::string& enable_features, | 157 static bool InitializeInstance(const std::string& enable_features, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 // Finalizes the initialization state of the FeatureList, so that no further | 197 // Finalizes the initialization state of the FeatureList, so that no further |
| 194 // overrides can be registered. This is called by SetInstance() on the | 198 // overrides can be registered. This is called by SetInstance() on the |
| 195 // singleton feature list that is being registered. | 199 // singleton feature list that is being registered. |
| 196 void FinalizeInitialization(); | 200 void FinalizeInitialization(); |
| 197 | 201 |
| 198 // Returns whether the given |feature| is enabled. This is invoked by the | 202 // Returns whether the given |feature| is enabled. This is invoked by the |
| 199 // public FeatureList::IsEnabled() static function on the global singleton. | 203 // public FeatureList::IsEnabled() static function on the global singleton. |
| 200 // Requires the FeatureList to have already been fully initialized. | 204 // Requires the FeatureList to have already been fully initialized. |
| 201 bool IsFeatureEnabled(const Feature& feature); | 205 bool IsFeatureEnabled(const Feature& feature); |
| 202 | 206 |
| 207 // Returns the field trial associated with the given |feature|. This is |
| 208 // invoked by the public FeatureList::GetFieldTrial() static function on the |
| 209 // global singleton. Requires the FeatureList to have already been fully |
| 210 // initialized. |
| 211 base::FieldTrial* GetAssociatedFieldTrial(const Feature& feature); |
| 212 |
| 203 // For each feature name in comma-separated list of strings |feature_list|, | 213 // For each feature name in comma-separated list of strings |feature_list|, |
| 204 // registers an override with the specified |overridden_state|. Also, will | 214 // registers an override with the specified |overridden_state|. Also, will |
| 205 // associate an optional named field trial if the entry is of the format | 215 // associate an optional named field trial if the entry is of the format |
| 206 // "FeatureName<TrialName". | 216 // "FeatureName<TrialName". |
| 207 void RegisterOverridesFromCommandLine(const std::string& feature_list, | 217 void RegisterOverridesFromCommandLine(const std::string& feature_list, |
| 208 OverrideState overridden_state); | 218 OverrideState overridden_state); |
| 209 | 219 |
| 210 // Registers an override for feature |feature_name|. The override specifies | 220 // Registers an override for feature |feature_name|. The override specifies |
| 211 // whether the feature should be on or off (via |overridden_state|), which | 221 // whether the feature should be on or off (via |overridden_state|), which |
| 212 // will take precedence over the feature's default state. If |field_trial| is | 222 // will take precedence over the feature's default state. If |field_trial| is |
| (...skipping 28 matching lines...) Expand all Loading... |
| 241 | 251 |
| 242 // Whether this object has been initialized from command line. | 252 // Whether this object has been initialized from command line. |
| 243 bool initialized_from_command_line_; | 253 bool initialized_from_command_line_; |
| 244 | 254 |
| 245 DISALLOW_COPY_AND_ASSIGN(FeatureList); | 255 DISALLOW_COPY_AND_ASSIGN(FeatureList); |
| 246 }; | 256 }; |
| 247 | 257 |
| 248 } // namespace base | 258 } // namespace base |
| 249 | 259 |
| 250 #endif // BASE_FEATURE_LIST_H_ | 260 #endif // BASE_FEATURE_LIST_H_ |
| OLD | NEW |