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

Side by Side Diff: base/feature_list.h

Issue 1824753002: Plumb trial association without overriding a feature to subprocesses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | « no previous file | base/feature_list.cc » ('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 #ifndef BASE_FEATURE_LIST_H_ 5 #ifndef BASE_FEATURE_LIST_H_
6 #define BASE_FEATURE_LIST_H_ 6 #define BASE_FEATURE_LIST_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 class BASE_EXPORT FeatureList { 77 class BASE_EXPORT FeatureList {
78 public: 78 public:
79 FeatureList(); 79 FeatureList();
80 ~FeatureList(); 80 ~FeatureList();
81 81
82 // Initializes feature overrides via command-line flags |enable_features| and 82 // Initializes feature overrides via command-line flags |enable_features| and
83 // |disable_features|, each of which is a comma-separated list of features to 83 // |disable_features|, each of which is a comma-separated list of features to
84 // enable or disable, respectively. If a feature appears on both lists, then 84 // enable or disable, respectively. If a feature appears on both lists, then
85 // it will be disabled. If a list entry has the format "FeatureName<TrialName" 85 // it will be disabled. If a list entry has the format "FeatureName<TrialName"
86 // then this initialization will also associate the feature state override 86 // then this initialization will also associate the feature state override
87 // with the named field trial, if it exists. Must only be invoked during the 87 // with the named field trial, if it exists. If a feature name is prefixed
88 // initialization phase (before FinalizeInitialization() has been called). 88 // with the '*' character, it will be created with OVERRIDE_USE_DEFAULT -
89 // which is useful for associating with a trial while using the default state.
90 // Must only be invoked during the initialization phase (before
91 // FinalizeInitialization() has been called).
89 void InitializeFromCommandLine(const std::string& enable_features, 92 void InitializeFromCommandLine(const std::string& enable_features,
90 const std::string& disable_features); 93 const std::string& disable_features);
91 94
92 // Specifies whether a feature override enables or disables the feature. 95 // Specifies whether a feature override enables or disables the feature.
93 enum OverrideState { 96 enum OverrideState {
94 OVERRIDE_USE_DEFAULT, 97 OVERRIDE_USE_DEFAULT,
95 OVERRIDE_DISABLE_FEATURE, 98 OVERRIDE_DISABLE_FEATURE,
96 OVERRIDE_ENABLE_FEATURE, 99 OVERRIDE_ENABLE_FEATURE,
97 }; 100 };
98 101
(...skipping 20 matching lines...) Expand all
119 // called but before the instance is registered via SetInstance(). 122 // called but before the instance is registered via SetInstance().
120 void RegisterFieldTrialOverride(const std::string& feature_name, 123 void RegisterFieldTrialOverride(const std::string& feature_name,
121 OverrideState override_state, 124 OverrideState override_state,
122 FieldTrial* field_trial); 125 FieldTrial* field_trial);
123 126
124 // Returns comma-separated lists of feature names (in the same format that is 127 // Returns comma-separated lists of feature names (in the same format that is
125 // accepted by InitializeFromCommandLine()) corresponding to features that 128 // accepted by InitializeFromCommandLine()) corresponding to features that
126 // have been overridden - either through command-line or via FieldTrials. For 129 // have been overridden - either through command-line or via FieldTrials. For
127 // those features that have an associated FieldTrial, the output entry will be 130 // those features that have an associated FieldTrial, the output entry will be
128 // of the format "FeatureName<TrialName", where "TrialName" is the name of the 131 // of the format "FeatureName<TrialName", where "TrialName" is the name of the
129 // FieldTrial. Must be called only after the instance has been initialized and 132 // FieldTrial. Features that have overrides with OVERRIDE_USE_DEFAULT will be
130 // registered. 133 // added to |enable_overrides| with a '*' character prefix. Must be called
134 // only after the instance has been initialized and registered.
131 void GetFeatureOverrides(std::string* enable_overrides, 135 void GetFeatureOverrides(std::string* enable_overrides,
132 std::string* disable_overrides); 136 std::string* disable_overrides);
133 137
134 // Returns whether the given |feature| is enabled. Must only be called after 138 // Returns whether the given |feature| is enabled. Must only be called after
135 // the singleton instance has been registered via SetInstance(). Additionally, 139 // the singleton instance has been registered via SetInstance(). Additionally,
136 // a feature with a given name must only have a single corresponding Feature 140 // a feature with a given name must only have a single corresponding Feature
137 // struct, which is checked in builds with DCHECKs enabled. 141 // struct, which is checked in builds with DCHECKs enabled.
138 static bool IsEnabled(const Feature& feature); 142 static bool IsEnabled(const Feature& feature);
139 143
140 // Splits a comma-separated string containing feature names into a vector. 144 // Splits a comma-separated string containing feature names into a vector.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 // Whether this object has been fully initialized. This gets set to true as a 234 // Whether this object has been fully initialized. This gets set to true as a
231 // result of FinalizeInitialization(). 235 // result of FinalizeInitialization().
232 bool initialized_; 236 bool initialized_;
233 237
234 DISALLOW_COPY_AND_ASSIGN(FeatureList); 238 DISALLOW_COPY_AND_ASSIGN(FeatureList);
235 }; 239 };
236 240
237 } // namespace base 241 } // namespace base
238 242
239 #endif // BASE_FEATURE_LIST_H_ 243 #endif // BASE_FEATURE_LIST_H_
OLDNEW
« no previous file with comments | « no previous file | base/feature_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698