| Index: base/feature_list.cc
|
| diff --git a/base/feature_list.cc b/base/feature_list.cc
|
| index 46732108dd6fcf0004e14b7ad6da06faf3561718..435165e10caa004c6485f569610427cdc1938be3 100644
|
| --- a/base/feature_list.cc
|
| +++ b/base/feature_list.cc
|
| @@ -23,6 +23,9 @@ namespace {
|
| // have more control over initialization timing. Leaky.
|
| FeatureList* g_instance = nullptr;
|
|
|
| +// Tracks whether the FeatureList instance was initialized via an accessor.
|
| +bool g_initialized_from_accessor = false;
|
| +
|
| // Some characters are not allowed to appear in feature names or the associated
|
| // field trial names, as they are used as special characters for command-line
|
| // serialization. This function checks that the strings are ASCII (since they
|
| @@ -35,10 +38,7 @@ bool IsValidFeatureOrFieldTrialName(const std::string& name) {
|
|
|
| } // namespace
|
|
|
| -FeatureList::FeatureList()
|
| - : initialized_(false),
|
| - initialized_from_command_line_(false) {
|
| -}
|
| +FeatureList::FeatureList() {}
|
|
|
| FeatureList::~FeatureList() {}
|
|
|
| @@ -133,7 +133,11 @@ void FeatureList::GetFeatureOverrides(std::string* enable_overrides,
|
|
|
| // static
|
| bool FeatureList::IsEnabled(const Feature& feature) {
|
| - return GetInstance()->IsFeatureEnabled(feature);
|
| + if (!g_instance) {
|
| + g_initialized_from_accessor = true;
|
| + return feature.default_state == FEATURE_ENABLED_BY_DEFAULT;
|
| + }
|
| + return g_instance->IsFeatureEnabled(feature);
|
| }
|
|
|
| // static
|
| @@ -158,6 +162,10 @@ bool FeatureList::InitializeInstance(const std::string& enable_features,
|
| // For example, we initialize an instance in chrome/browser/
|
| // chrome_browser_main.cc and do not override it in content/browser/
|
| // browser_main_loop.cc.
|
| + // If the singleton was previously initialized from within an accessor, we
|
| + // want to prevent callers from reinitializing the singleton and masking the
|
| + // accessor call(s) which likely returned incorrect information.
|
| + CHECK(!g_initialized_from_accessor);
|
| bool instance_existed_before = false;
|
| if (g_instance) {
|
| if (g_instance->initialized_from_command_line_)
|
| @@ -192,6 +200,7 @@ void FeatureList::SetInstance(std::unique_ptr<FeatureList> instance) {
|
| void FeatureList::ClearInstanceForTesting() {
|
| delete g_instance;
|
| g_instance = nullptr;
|
| + g_initialized_from_accessor = false;
|
| }
|
|
|
| void FeatureList::FinalizeInitialization() {
|
|
|