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 <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // Returns whether the given |feature| is enabled. Must only be called after | 120 // Returns whether the given |feature| is enabled. Must only be called after |
121 // the singleton instance has been registered via SetInstance(). Additionally, | 121 // the singleton instance has been registered via SetInstance(). Additionally, |
122 // a feature with a given name must only have a single corresponding Feature | 122 // a feature with a given name must only have a single corresponding Feature |
123 // struct, which is checked in builds with DCHECKs enabled. | 123 // struct, which is checked in builds with DCHECKs enabled. |
124 static bool IsEnabled(const Feature& feature); | 124 static bool IsEnabled(const Feature& feature); |
125 | 125 |
126 // Splits a comma-separated string containing feature names into a vector. | 126 // Splits a comma-separated string containing feature names into a vector. |
127 static std::vector<std::string> SplitFeatureListString( | 127 static std::vector<std::string> SplitFeatureListString( |
128 const std::string& input); | 128 const std::string& input); |
129 | 129 |
| 130 // Initializes and sets a default instance of FeatureList if one has not yet |
| 131 // already been set. No-op otherwise. |
| 132 static void InitializeInstance(); |
| 133 |
130 // Returns the singleton instance of FeatureList. Will return null until an | 134 // Returns the singleton instance of FeatureList. Will return null until an |
131 // instance is registered via SetInstance(). | 135 // instance is registered via SetInstance(). |
132 static FeatureList* GetInstance(); | 136 static FeatureList* GetInstance(); |
133 | 137 |
134 // Registers the given |instance| to be the singleton feature list for this | 138 // Registers the given |instance| to be the singleton feature list for this |
135 // process. This should only be called once and |instance| must not be null. | 139 // process. This should only be called once and |instance| must not be null. |
136 static void SetInstance(scoped_ptr<FeatureList> instance); | 140 static void SetInstance(scoped_ptr<FeatureList> instance); |
137 | 141 |
138 // Clears the previously-registered singleton instance for tests. | 142 // Clears the previously-registered singleton instance for tests. |
139 static void ClearInstanceForTesting(); | 143 static void ClearInstanceForTesting(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 // Whether this object has been fully initialized. This gets set to true as a | 209 // Whether this object has been fully initialized. This gets set to true as a |
206 // result of FinalizeInitialization(). | 210 // result of FinalizeInitialization(). |
207 bool initialized_; | 211 bool initialized_; |
208 | 212 |
209 DISALLOW_COPY_AND_ASSIGN(FeatureList); | 213 DISALLOW_COPY_AND_ASSIGN(FeatureList); |
210 }; | 214 }; |
211 | 215 |
212 } // namespace base | 216 } // namespace base |
213 | 217 |
214 #endif // BASE_FEATURE_LIST_H_ | 218 #endif // BASE_FEATURE_LIST_H_ |
OLD | NEW |