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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_field_trial.cc

Issue 12220004: Introduce dynamic ablation of AutocompleteProviders using AC dynamic trials. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/autocomplete/autocomplete_field_trial.h" 5 #include "chrome/browser/autocomplete/autocomplete_field_trial.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // For the field trial that ignores all mid-term matches in HistoryQuick 89 // For the field trial that ignores all mid-term matches in HistoryQuick
90 // provider, put 0% ( = 0/100 ) of the users in the experiment group. 90 // provider, put 0% ( = 0/100 ) of the users in the experiment group.
91 const base::FieldTrial::Probability 91 const base::FieldTrial::Probability
92 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialDivisor = 100; 92 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialDivisor = 100;
93 const base::FieldTrial::Probability 93 const base::FieldTrial::Probability
94 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialExperimentFraction = 0; 94 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialExperimentFraction = 0;
95 95
96 96
97 // Field trial IDs. 97 // Field trial IDs.
98 // Though they are not literally "const", they are set only once, in 98 // Though they are not literally "const", they are set only once, in
99 // Activate() below. 99 // ActivateStaticTrials() below.
100 100
101 // Whether the static field trials have been initialized by 101 // Whether the static field trials have been initialized by
102 // ActivateStaticTrials method. 102 // ActivateStaticTrials() method.
103 bool static_field_trials_initialized = false; 103 bool static_field_trials_initialized = false;
104 104
105 // Whether the dynamic field trials have been initialized by
106 // ActivateDynamicTrials() method.
107 bool dynamic_field_trials_initialized = false;
108
105 // Field trial ID for the disallow-inline History Quick Provider 109 // Field trial ID for the disallow-inline History Quick Provider
106 // experiment group. 110 // experiment group.
107 int disallow_inline_hqp_experiment_group = 0; 111 int disallow_inline_hqp_experiment_group = 0;
108 112
109 // Field trial ID for the History Quick Provider new scoring experiment group. 113 // Field trial ID for the History Quick Provider new scoring experiment group.
110 int hqp_new_scoring_experiment_group = 0; 114 int hqp_new_scoring_experiment_group = 0;
111 115
112 // Field trial ID for the HistoryURL provider cull redirects experiment group. 116 // Field trial ID for the HistoryURL provider cull redirects experiment group.
113 int hup_dont_cull_redirects_experiment_group = 0; 117 int hup_dont_cull_redirects_experiment_group = 0;
114 118
115 // Field trial ID for the HistoryURL provider create shorter match 119 // Field trial ID for the HistoryURL provider create shorter match
116 // experiment group. 120 // experiment group.
117 int hup_dont_create_shorter_match_experiment_group = 0; 121 int hup_dont_create_shorter_match_experiment_group = 0;
118 122
119 // Field trial ID for the HistoryQuick provider replaces HistoryURL provider 123 // Field trial ID for the HistoryQuick provider replaces HistoryURL provider
120 // experiment group. 124 // experiment group.
121 int hqp_replace_hup_scoring_experiment_group = 0; 125 int hqp_replace_hup_scoring_experiment_group = 0;
122 126
123 // Field trial ID for the HistoryQuick provider only count matches at 127 // Field trial ID for the HistoryQuick provider only count matches at
124 // word boundaries experiment group. 128 // word boundaries experiment group.
125 int hqp_only_count_matches_at_word_boundaries_experiment_group = 0; 129 int hqp_only_count_matches_at_word_boundaries_experiment_group = 0;
126 130
131 std::string DynamicFieldTrialName(int id) {
Mark P 2013/02/11 21:13:34 please comment about expected use.
Bart N. 2013/02/11 21:42:12 Done.
132 return base::StringPrintf("%s%d", kAutocompleteDynamicFieldTrialPrefix, id);
127 } 133 }
128 134
135 } // namespace
136
129 137
130 void AutocompleteFieldTrial::ActivateStaticTrials() { 138 void AutocompleteFieldTrial::ActivateStaticTrials() {
131 DCHECK(!static_field_trials_initialized); 139 DCHECK(!static_field_trials_initialized);
132 140
133 // Create inline History Quick Provider field trial. 141 // Create inline History Quick Provider field trial.
134 // Make it expire on November 8, 2012. 142 // Make it expire on November 8, 2012.
135 scoped_refptr<base::FieldTrial> trial( 143 scoped_refptr<base::FieldTrial> trial(
136 base::FieldTrialList::FactoryGetFieldTrial( 144 base::FieldTrialList::FactoryGetFieldTrial(
137 kDisallowInlineHQPFieldTrialName, kDisallowInlineHQPFieldTrialDivisor, 145 kDisallowInlineHQPFieldTrialName, kDisallowInlineHQPFieldTrialDivisor,
138 "Standard", 2012, 11, 8, NULL)); 146 "Standard", 2012, 11, 8, NULL));
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 "Standard", 2013, 6, 23, NULL); 238 "Standard", 2013, 6, 23, NULL);
231 trial->UseOneTimeRandomization(); 239 trial->UseOneTimeRandomization();
232 hqp_only_count_matches_at_word_boundaries_experiment_group = 240 hqp_only_count_matches_at_word_boundaries_experiment_group =
233 trial->AppendGroup("HQPOnlyCountMatchesAtWordBoundaries", 241 trial->AppendGroup("HQPOnlyCountMatchesAtWordBoundaries",
234 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialExperimentFraction); 242 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialExperimentFraction);
235 243
236 static_field_trials_initialized = true; 244 static_field_trials_initialized = true;
237 } 245 }
238 246
239 void AutocompleteFieldTrial::ActivateDynamicTrials() { 247 void AutocompleteFieldTrial::ActivateDynamicTrials() {
240 // Initialize all autocomplete dynamic field trials. 248 // Initialize all autocomplete dynamic field trials. This method may be
249 // called multiple times.
250 for (int i = 0; i < kMaxAutocompleteDynamicFieldTrials; ++i)
251 base::FieldTrialList::FindValue(DynamicFieldTrialName(i));
252
253 dynamic_field_trials_initialized = true;
254 }
255
256 int AutocompleteFieldTrial::GetDisabledProviderTypes() {
257 DCHECK(dynamic_field_trials_initialized);
258
259 // We assume that each group may contain a substring
260 // "DisabledProviders_<mask>" where "mask" is a bitmap of disabled provider
261 // types (AutocompleteProvider::Type).
262 int provider_types = 0;
241 for (int i = 0; i < kMaxAutocompleteDynamicFieldTrials; ++i) { 263 for (int i = 0; i < kMaxAutocompleteDynamicFieldTrials; ++i) {
242 base::FieldTrialList::FindValue( 264 std::string group_name = base::FieldTrialList::FindFullName(
243 base::StringPrintf("%s%d", kAutocompleteDynamicFieldTrialPrefix, i)); 265 DynamicFieldTrialName(i));
266 if (!group_name.empty()) {
267 const char kDisabledProviders[] = "DisabledProviders_";
268 size_t pos = group_name.find(kDisabledProviders);
Mark P 2013/02/11 21:13:34 const
Bart N. 2013/02/11 21:42:12 Done.
269 if (pos == std::string::npos)
270 continue;
271 int types = 0;
Mark P 2013/02/11 21:13:34 do you expect pos to ever not be 0? perhaps dcheck
Bart N. 2013/02/11 21:42:12 I don't think it's a good idea to DCHECK against s
Mark P 2013/02/11 22:04:18 I don't see a warning message. Can you please add
Bart N. 2013/02/12 01:18:19 As discussed offline, I made now a stronger requir
272 base::StringToInt(base::StringPiece(
Mark P 2013/02/11 21:13:34 consider dchecking the return type of this
Bart N. 2013/02/11 21:42:12 Not really; clarified in the comment.
Mark P 2013/02/11 22:04:18 You really do want perfect conversions. Don't try
Bart N. 2013/02/12 01:18:19 As discussed offline, it was intended. However, I
273 group_name.substr(pos + strlen(kDisabledProviders))), &types);
274 provider_types |= types;
275 }
244 } 276 }
277 return provider_types;
245 } 278 }
246 279
247 bool AutocompleteFieldTrial::InDisallowInlineHQPFieldTrial() { 280 bool AutocompleteFieldTrial::InDisallowInlineHQPFieldTrial() {
248 return base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName); 281 return base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName);
249 } 282 }
250 283
251 bool AutocompleteFieldTrial::InDisallowInlineHQPFieldTrialExperimentGroup() { 284 bool AutocompleteFieldTrial::InDisallowInlineHQPFieldTrialExperimentGroup() {
252 if (!base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName)) 285 if (!base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName))
253 return false; 286 return false;
254 287
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 bool AutocompleteFieldTrial:: 366 bool AutocompleteFieldTrial::
334 InHQPOnlyCountMatchesAtWordBoundariesFieldTrialExperimentGroup() { 367 InHQPOnlyCountMatchesAtWordBoundariesFieldTrialExperimentGroup() {
335 if (!InHQPOnlyCountMatchesAtWordBoundariesFieldTrial()) 368 if (!InHQPOnlyCountMatchesAtWordBoundariesFieldTrial())
336 return false; 369 return false;
337 370
338 // Return true if we're in the experiment group. 371 // Return true if we're in the experiment group.
339 const int group = base::FieldTrialList::FindValue( 372 const int group = base::FieldTrialList::FindValue(
340 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialName); 373 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialName);
341 return group == hqp_only_count_matches_at_word_boundaries_experiment_group; 374 return group == hqp_only_count_matches_at_word_boundaries_experiment_group;
342 } 375 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698