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

Side by Side Diff: base/feature_list.cc

Issue 1848523002: Changes to support using base/feature_list.h from gin/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « base/feature_list.h ('k') | base/test/test_suite.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "base/feature_list.h" 5 #include "base/feature_list.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 return GetInstance()->IsFeatureEnabled(feature); 136 return GetInstance()->IsFeatureEnabled(feature);
137 } 137 }
138 138
139 // static 139 // static
140 std::vector<std::string> FeatureList::SplitFeatureListString( 140 std::vector<std::string> FeatureList::SplitFeatureListString(
141 const std::string& input) { 141 const std::string& input) {
142 return SplitString(input, ",", TRIM_WHITESPACE, SPLIT_WANT_NONEMPTY); 142 return SplitString(input, ",", TRIM_WHITESPACE, SPLIT_WANT_NONEMPTY);
143 } 143 }
144 144
145 // static 145 // static
146 void FeatureList::InitializeInstance(const std::string& enable_features, 146 bool FeatureList::InitializeInstance(const std::string& enable_features,
147 const std::string& disable_features) { 147 const std::string& disable_features) {
148 // We want to initialize a new instance here to support command-line features 148 // We want to initialize a new instance here to support command-line features
149 // in testing better. For example, we initialize a dummy instance in 149 // in testing better. For example, we initialize a dummy instance in
150 // base/test/test_suite.cc, and override it in content/browser/ 150 // base/test/test_suite.cc, and override it in content/browser/
151 // browser_main_loop.cc. 151 // browser_main_loop.cc.
152 // On the other hand, we want to avoid re-initialization from command line. 152 // On the other hand, we want to avoid re-initialization from command line.
153 // For example, we initialize an instance in chrome/browser/ 153 // For example, we initialize an instance in chrome/browser/
154 // chrome_browser_main.cc and do not override it in content/browser/ 154 // chrome_browser_main.cc and do not override it in content/browser/
155 // browser_main_loop.cc. 155 // browser_main_loop.cc.
156 bool instance_existed_before = false;
156 if (g_instance) { 157 if (g_instance) {
157 if (g_instance->initialized_from_command_line_) 158 if (g_instance->initialized_from_command_line_)
158 return; 159 return false;
159 160
160 delete g_instance; 161 delete g_instance;
161 g_instance = nullptr; 162 g_instance = nullptr;
163 instance_existed_before = true;
162 } 164 }
163 165
164 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); 166 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
165 feature_list->InitializeFromCommandLine(enable_features, disable_features); 167 feature_list->InitializeFromCommandLine(enable_features, disable_features);
166 base::FeatureList::SetInstance(std::move(feature_list)); 168 base::FeatureList::SetInstance(std::move(feature_list));
169 return !instance_existed_before;
167 } 170 }
168 171
169 // static 172 // static
170 FeatureList* FeatureList::GetInstance() { 173 FeatureList* FeatureList::GetInstance() {
171 return g_instance; 174 return g_instance;
172 } 175 }
173 176
174 // static 177 // static
175 void FeatureList::SetInstance(std::unique_ptr<FeatureList> instance) { 178 void FeatureList::SetInstance(std::unique_ptr<FeatureList> instance) {
176 DCHECK(!g_instance); 179 DCHECK(!g_instance);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 return it->second == &feature; 269 return it->second == &feature;
267 } 270 }
268 271
269 FeatureList::OverrideEntry::OverrideEntry(OverrideState overridden_state, 272 FeatureList::OverrideEntry::OverrideEntry(OverrideState overridden_state,
270 FieldTrial* field_trial) 273 FieldTrial* field_trial)
271 : overridden_state(overridden_state), 274 : overridden_state(overridden_state),
272 field_trial(field_trial), 275 field_trial(field_trial),
273 overridden_by_field_trial(field_trial != nullptr) {} 276 overridden_by_field_trial(field_trial != nullptr) {}
274 277
275 } // namespace base 278 } // namespace base
OLDNEW
« no previous file with comments | « base/feature_list.h ('k') | base/test/test_suite.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698