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

Side by Side Diff: base/feature_list.cc

Issue 1408783002: Support base::Feature entries in chrome://flags. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 years, 2 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') | chrome/browser/about_flags.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 <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/field_trial.h" 11 #include "base/metrics/field_trial.h"
12 #include "base/strings/string_split.h" 12 #include "base/strings/string_split.h"
13 13
14 namespace base { 14 namespace base {
15 15
16 namespace { 16 namespace {
17 17
18 // Pointer to the FeatureList instance singleton that was set via 18 // Pointer to the FeatureList instance singleton that was set via
19 // FeatureList::SetInstance(). Does not use base/memory/singleton.h in order to 19 // FeatureList::SetInstance(). Does not use base/memory/singleton.h in order to
20 // have more control over initialization timing. Leaky. 20 // have more control over initialization timing. Leaky.
21 FeatureList* g_instance = nullptr; 21 FeatureList* g_instance = nullptr;
22 22
23 // Splits a comma-separated string containing feature names into a vector.
24 std::vector<std::string> SplitFeatureListString(const std::string& input) {
25 return SplitString(input, ",", TRIM_WHITESPACE, SPLIT_WANT_NONEMPTY);
26 }
27
28 } // namespace 23 } // namespace
29 24
30 FeatureList::FeatureList() : initialized_(false) {} 25 FeatureList::FeatureList() : initialized_(false) {}
31 26
32 FeatureList::~FeatureList() {} 27 FeatureList::~FeatureList() {}
33 28
34 void FeatureList::InitializeFromCommandLine( 29 void FeatureList::InitializeFromCommandLine(
35 const std::string& enable_features, 30 const std::string& enable_features,
36 const std::string& disable_features) { 31 const std::string& disable_features) {
37 DCHECK(!initialized_); 32 DCHECK(!initialized_);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 82
88 entry->field_trial = field_trial; 83 entry->field_trial = field_trial;
89 } 84 }
90 85
91 // static 86 // static
92 bool FeatureList::IsEnabled(const Feature& feature) { 87 bool FeatureList::IsEnabled(const Feature& feature) {
93 return GetInstance()->IsFeatureEnabled(feature); 88 return GetInstance()->IsFeatureEnabled(feature);
94 } 89 }
95 90
96 // static 91 // static
92 std::vector<std::string> FeatureList::SplitFeatureListString(
93 const std::string& input) {
94 return SplitString(input, ",", TRIM_WHITESPACE, SPLIT_WANT_NONEMPTY);
95 }
96
97 // static
97 FeatureList* FeatureList::GetInstance() { 98 FeatureList* FeatureList::GetInstance() {
98 return g_instance; 99 return g_instance;
99 } 100 }
100 101
101 // static 102 // static
102 void FeatureList::SetInstance(scoped_ptr<FeatureList> instance) { 103 void FeatureList::SetInstance(scoped_ptr<FeatureList> instance) {
103 DCHECK(!g_instance); 104 DCHECK(!g_instance);
104 instance->FinalizeInitialization(); 105 instance->FinalizeInitialization();
105 106
106 // Note: Intentional leak of global singleton. 107 // Note: Intentional leak of global singleton.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 return it->second == &feature; 162 return it->second == &feature;
162 } 163 }
163 164
164 FeatureList::OverrideEntry::OverrideEntry(OverrideState overridden_state, 165 FeatureList::OverrideEntry::OverrideEntry(OverrideState overridden_state,
165 FieldTrial* field_trial) 166 FieldTrial* field_trial)
166 : overridden_state(overridden_state), 167 : overridden_state(overridden_state),
167 field_trial(field_trial), 168 field_trial(field_trial),
168 overridden_by_field_trial(field_trial != nullptr) {} 169 overridden_by_field_trial(field_trial != nullptr) {}
169 170
170 } // namespace base 171 } // namespace base
OLDNEW
« no previous file with comments | « base/feature_list.h ('k') | chrome/browser/about_flags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698