Chromium Code Reviews| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 const std::string& disable_features); | 158 const std::string& disable_features); |
| 159 | 159 |
| 160 // Returns the singleton instance of FeatureList. Will return null until an | 160 // Returns the singleton instance of FeatureList. Will return null until an |
| 161 // instance is registered via SetInstance(). | 161 // instance is registered via SetInstance(). |
| 162 static FeatureList* GetInstance(); | 162 static FeatureList* GetInstance(); |
| 163 | 163 |
| 164 // Registers the given |instance| to be the singleton feature list for this | 164 // Registers the given |instance| to be the singleton feature list for this |
| 165 // process. This should only be called once and |instance| must not be null. | 165 // process. This should only be called once and |instance| must not be null. |
| 166 static void SetInstance(std::unique_ptr<FeatureList> instance); | 166 static void SetInstance(std::unique_ptr<FeatureList> instance); |
| 167 | 167 |
| 168 // Clears the previously-registered singleton instance for tests. | 168 // Clears the previously-registered singleton instance for tests and returns |
| 169 static void ClearInstanceForTesting(); | 169 // the old instance. |
| 170 // Note: Most tests should never call this directly, instead consider using | |
|
Ilya Sherman
2016/08/09 01:06:57
nit: s/directly, instead/directly. Instead
Alexei Svitkine (slow)
2016/08/09 01:26:16
Done.
| |
| 171 // base::test::ScopedFeatureList. | |
| 172 static std::unique_ptr<FeatureList> ClearInstanceForTesting(); | |
| 173 | |
| 174 // Sets an existing (initialized) |instance| to be the singleton feature | |
| 175 // list, for testing. Existing instance must be null. This is primarily | |
|
Ilya Sherman
2016/08/09 01:06:57
nit: You use the word "existing" in two different
Alexei Svitkine (slow)
2016/08/09 01:26:16
Done.
| |
| 176 // intended to support base::test::ScopedFeatureList helper class. | |
| 177 static void RestoreInstanceForTesting(std::unique_ptr<FeatureList> instance); | |
| 170 | 178 |
| 171 private: | 179 private: |
| 172 FRIEND_TEST_ALL_PREFIXES(FeatureListTest, CheckFeatureIdentity); | 180 FRIEND_TEST_ALL_PREFIXES(FeatureListTest, CheckFeatureIdentity); |
| 173 | 181 |
| 174 struct OverrideEntry { | 182 struct OverrideEntry { |
| 175 // The overridden enable (on/off) state of the feature. | 183 // The overridden enable (on/off) state of the feature. |
| 176 const OverrideState overridden_state; | 184 const OverrideState overridden_state; |
| 177 | 185 |
| 178 // An optional associated field trial, which will be activated when the | 186 // An optional associated field trial, which will be activated when the |
| 179 // state of the feature is queried for the first time. Weak pointer to the | 187 // state of the feature is queried for the first time. Weak pointer to the |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 | 259 |
| 252 // Whether this object has been initialized from command line. | 260 // Whether this object has been initialized from command line. |
| 253 bool initialized_from_command_line_ = false; | 261 bool initialized_from_command_line_ = false; |
| 254 | 262 |
| 255 DISALLOW_COPY_AND_ASSIGN(FeatureList); | 263 DISALLOW_COPY_AND_ASSIGN(FeatureList); |
| 256 }; | 264 }; |
| 257 | 265 |
| 258 } // namespace base | 266 } // namespace base |
| 259 | 267 |
| 260 #endif // BASE_FEATURE_LIST_H_ | 268 #endif // BASE_FEATURE_LIST_H_ |
| OLD | NEW |