Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(783)

Unified Diff: base/feature_list.cc

Issue 2887523002: Avoid changing enabled features while the browser is already running.
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/feature_list.cc
diff --git a/base/feature_list.cc b/base/feature_list.cc
index 61043ceb731fa7bf2c6891c67c95882121d5afa7..96b5af0e7568311ee04dc71c24f784836e6f68c7 100644
--- a/base/feature_list.cc
+++ b/base/feature_list.cc
@@ -25,6 +25,8 @@ namespace {
// have more control over initialization timing. Leaky.
FeatureList* g_instance = nullptr;
+bool g_block_overriding_instances_for_testing = false;
+
// Tracks whether the FeatureList instance was initialized via an accessor.
bool g_initialized_from_accessor = false;
@@ -280,6 +282,7 @@ void FeatureList::SetInstance(std::unique_ptr<FeatureList> instance) {
// static
std::unique_ptr<FeatureList> FeatureList::ClearInstanceForTesting() {
+ DCHECK(!g_block_overriding_instances_for_testing);
FeatureList* old_instance = g_instance;
g_instance = nullptr;
g_initialized_from_accessor = false;
@@ -289,11 +292,17 @@ std::unique_ptr<FeatureList> FeatureList::ClearInstanceForTesting() {
// static
void FeatureList::RestoreInstanceForTesting(
std::unique_ptr<FeatureList> instance) {
+ DCHECK(!g_block_overriding_instances_for_testing);
DCHECK(!g_instance);
// Note: Intentional leak of global singleton.
g_instance = instance.release();
}
+// static
+void FeatureList::BlockOverridingInstanceForTesting(bool block) {
+ g_block_overriding_instances_for_testing = block;
+}
+
void FeatureList::FinalizeInitialization() {
DCHECK(!initialized_);
initialized_ = true;
« no previous file with comments | « base/feature_list.h ('k') | chrome/browser/task_manager/providers/web_contents/subframe_task_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698