Chromium Code Reviews| Index: base/feature_list.cc |
| diff --git a/base/feature_list.cc b/base/feature_list.cc |
| index 853fc4d84e6df24f8c195b0e59c44aad8bc6e721..15b16c53b7592c9b7f4f30875b847f57b4218b8d 100644 |
| --- a/base/feature_list.cc |
| +++ b/base/feature_list.cc |
| @@ -35,7 +35,10 @@ bool IsValidFeatureOrFieldTrialName(const std::string& name) { |
| } // namespace |
| -FeatureList::FeatureList() : initialized_(false) {} |
| +FeatureList::FeatureList() |
| + : initialized_(false), |
| + initialized_from_command_line_(false) { |
| +} |
| FeatureList::~FeatureList() {} |
| @@ -48,6 +51,8 @@ void FeatureList::InitializeFromCommandLine( |
| // enabled ones (since RegisterOverride() uses insert()). |
| RegisterOverridesFromCommandLine(disable_features, OVERRIDE_DISABLE_FEATURE); |
| RegisterOverridesFromCommandLine(enable_features, OVERRIDE_ENABLE_FEATURE); |
| + |
| + initialized_from_command_line_ = true; |
| } |
| bool FeatureList::IsFeatureOverriddenFromCommandLine( |
| @@ -138,10 +143,20 @@ std::vector<std::string> FeatureList::SplitFeatureListString( |
| } |
| // static |
| -void FeatureList::InitializeInstance() { |
| - if (g_instance) |
| - return; |
| - SetInstance(make_scoped_ptr(new FeatureList)); |
| +void FeatureList::InitializeInstance(const std::string& enable_features, |
| + const std::string& disable_features) { |
| + if (g_instance) { |
| + if (g_instance->initialized_from_command_line_) { |
|
Alexei Svitkine (slow)
2016/03/30 16:44:32
Are you sure this bit of logic is necessary?
My u
Alexei Svitkine (slow)
2016/03/30 17:12:25
We chatted more offline. This check is needed to s
Changwan Ryu
2016/03/30 17:53:31
Added some comment.
|
| + return; |
| + } else { |
|
Alexei Svitkine (slow)
2016/03/30 17:12:25
Nit: No need for else if there's a return above.
Changwan Ryu
2016/03/30 17:53:31
Done.
|
| + delete g_instance; |
| + g_instance = nullptr; |
| + } |
| + } |
| + |
| + scoped_ptr<base::FeatureList> feature_list(new base::FeatureList); |
| + feature_list->InitializeFromCommandLine(enable_features, disable_features); |
| + base::FeatureList::SetInstance(std::move(feature_list)); |
| } |
| // static |