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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 // the old instance. | 183 // the old instance. |
184 // Note: Most tests should never call this directly. Instead consider using | 184 // Note: Most tests should never call this directly. Instead consider using |
185 // base::test::ScopedFeatureList. | 185 // base::test::ScopedFeatureList. |
186 static std::unique_ptr<FeatureList> ClearInstanceForTesting(); | 186 static std::unique_ptr<FeatureList> ClearInstanceForTesting(); |
187 | 187 |
188 // Sets a given (initialized) |instance| to be the singleton feature list, | 188 // Sets a given (initialized) |instance| to be the singleton feature list, |
189 // for testing. Existing instance must be null. This is primarily intended | 189 // for testing. Existing instance must be null. This is primarily intended |
190 // to support base::test::ScopedFeatureList helper class. | 190 // to support base::test::ScopedFeatureList helper class. |
191 static void RestoreInstanceForTesting(std::unique_ptr<FeatureList> instance); | 191 static void RestoreInstanceForTesting(std::unique_ptr<FeatureList> instance); |
192 | 192 |
| 193 // Test harnesses should disallow calls to ClearInstanceForTesting and |
| 194 // RestoreInstanceForTesting from test code, while the test code is running in |
| 195 // presence of other threads that make use of base::FeatureList (because such |
| 196 // calls are inherently racey). |
| 197 static void BlockOverridingInstanceForTesting(bool block); |
| 198 |
193 private: | 199 private: |
194 FRIEND_TEST_ALL_PREFIXES(FeatureListTest, CheckFeatureIdentity); | 200 FRIEND_TEST_ALL_PREFIXES(FeatureListTest, CheckFeatureIdentity); |
195 FRIEND_TEST_ALL_PREFIXES(FeatureListTest, | 201 FRIEND_TEST_ALL_PREFIXES(FeatureListTest, |
196 StoreAndRetrieveFeaturesFromSharedMemory); | 202 StoreAndRetrieveFeaturesFromSharedMemory); |
197 FRIEND_TEST_ALL_PREFIXES(FeatureListTest, | 203 FRIEND_TEST_ALL_PREFIXES(FeatureListTest, |
198 StoreAndRetrieveAssociatedFeaturesFromSharedMemory); | 204 StoreAndRetrieveAssociatedFeaturesFromSharedMemory); |
199 | 205 |
200 struct OverrideEntry { | 206 struct OverrideEntry { |
201 // The overridden enable (on/off) state of the feature. | 207 // The overridden enable (on/off) state of the feature. |
202 const OverrideState overridden_state; | 208 const OverrideState overridden_state; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 283 |
278 // Whether this object has been initialized from command line. | 284 // Whether this object has been initialized from command line. |
279 bool initialized_from_command_line_ = false; | 285 bool initialized_from_command_line_ = false; |
280 | 286 |
281 DISALLOW_COPY_AND_ASSIGN(FeatureList); | 287 DISALLOW_COPY_AND_ASSIGN(FeatureList); |
282 }; | 288 }; |
283 | 289 |
284 } // namespace base | 290 } // namespace base |
285 | 291 |
286 #endif // BASE_FEATURE_LIST_H_ | 292 #endif // BASE_FEATURE_LIST_H_ |
OLD | NEW |