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

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: Remove unused variable. 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_util.h"
10 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
11 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
12 #include "chrome/common/metrics/metrics_util.h" 13 #include "chrome/common/metrics/metrics_util.h"
13 #include "chrome/common/metrics/variations/variation_ids.h" 14 #include "chrome/common/metrics/variations/variation_ids.h"
14 #include "chrome/common/metrics/variations/variations_util.h" 15 #include "chrome/common/metrics/variations/variations_util.h"
15 16
16 namespace { 17 namespace {
17 18
18 // Field trial names. 19 // Field trial names.
19 static const char kDisallowInlineHQPFieldTrialName[] = 20 static const char kDisallowInlineHQPFieldTrialName[] =
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // For the field trial that allows HistoryQuick provider to use the 99 // For the field trial that allows HistoryQuick provider to use the
99 // cursor position, put 25% ( = 25/100 ) of the users in the experiment group. 100 // cursor position, put 25% ( = 25/100 ) of the users in the experiment group.
100 const base::FieldTrial::Probability 101 const base::FieldTrial::Probability
101 kHQPUseCursorPositionFieldTrialDivisor = 100; 102 kHQPUseCursorPositionFieldTrialDivisor = 100;
102 const base::FieldTrial::Probability 103 const base::FieldTrial::Probability
103 kHQPUseCursorPositionFieldTrialExperimentFraction = 25; 104 kHQPUseCursorPositionFieldTrialExperimentFraction = 25;
104 105
105 106
106 // Field trial IDs. 107 // Field trial IDs.
107 // Though they are not literally "const", they are set only once, in 108 // Though they are not literally "const", they are set only once, in
108 // Activate() below. 109 // ActivateStaticTrials() below.
109 110
110 // Whether the static field trials have been initialized by 111 // Whether the static field trials have been initialized by
111 // ActivateStaticTrials method. 112 // ActivateStaticTrials() method.
112 bool static_field_trials_initialized = false; 113 bool static_field_trials_initialized = false;
113 114
114 // Field trial ID for the disallow-inline History Quick Provider 115 // Field trial ID for the disallow-inline History Quick Provider
115 // experiment group. 116 // experiment group.
116 int disallow_inline_hqp_experiment_group = 0; 117 int disallow_inline_hqp_experiment_group = 0;
117 118
118 // Field trial ID for the History Quick Provider new scoring experiment group. 119 // Field trial ID for the History Quick Provider new scoring experiment group.
119 int hqp_new_scoring_experiment_group = 0; 120 int hqp_new_scoring_experiment_group = 0;
120 121
121 // Field trial ID for the HistoryURL provider cull redirects experiment group. 122 // Field trial ID for the HistoryURL provider cull redirects experiment group.
122 int hup_dont_cull_redirects_experiment_group = 0; 123 int hup_dont_cull_redirects_experiment_group = 0;
123 124
124 // Field trial ID for the HistoryURL provider create shorter match 125 // Field trial ID for the HistoryURL provider create shorter match
125 // experiment group. 126 // experiment group.
126 int hup_dont_create_shorter_match_experiment_group = 0; 127 int hup_dont_create_shorter_match_experiment_group = 0;
127 128
128 // Field trial ID for the HistoryQuick provider replaces HistoryURL provider 129 // Field trial ID for the HistoryQuick provider replaces HistoryURL provider
129 // experiment group. 130 // experiment group.
130 int hqp_replace_hup_scoring_experiment_group = 0; 131 int hqp_replace_hup_scoring_experiment_group = 0;
131 132
132 // Field trial ID for the HistoryQuick provider only count matches at 133 // Field trial ID for the HistoryQuick provider only count matches at
133 // word boundaries experiment group. 134 // word boundaries experiment group.
134 int hqp_only_count_matches_at_word_boundaries_experiment_group = 0; 135 int hqp_only_count_matches_at_word_boundaries_experiment_group = 0;
135 136
136 // Field trial ID for the HistoryQuick provider use cursor position 137 // Field trial ID for the HistoryQuick provider use cursor position
137 // experiment group. 138 // experiment group.
138 int hqp_use_cursor_position_experiment_group = 0; 139 int hqp_use_cursor_position_experiment_group = 0;
139 140
141 // Concatenates the autocomplete dynamic field trial prefix with a field trial
142 // ID to form a complete autocomplete field trial name.
143 std::string DynamicFieldTrialName(int id) {
144 return base::StringPrintf("%s%d", kAutocompleteDynamicFieldTrialPrefix, id);
140 } 145 }
141 146
147 } // namespace
148
142 149
143 void AutocompleteFieldTrial::ActivateStaticTrials() { 150 void AutocompleteFieldTrial::ActivateStaticTrials() {
144 DCHECK(!static_field_trials_initialized); 151 DCHECK(!static_field_trials_initialized);
145 152
146 // Create inline History Quick Provider field trial. 153 // Create inline History Quick Provider field trial.
147 // Make it expire on November 8, 2012. 154 // Make it expire on November 8, 2012.
148 scoped_refptr<base::FieldTrial> trial( 155 scoped_refptr<base::FieldTrial> trial(
149 base::FieldTrialList::FactoryGetFieldTrial( 156 base::FieldTrialList::FactoryGetFieldTrial(
150 kDisallowInlineHQPFieldTrialName, kDisallowInlineHQPFieldTrialDivisor, 157 kDisallowInlineHQPFieldTrialName, kDisallowInlineHQPFieldTrialDivisor,
151 "Standard", 2012, 11, 8, NULL)); 158 "Standard", 2012, 11, 8, NULL));
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 "Standard", 2013, 8, 23, NULL); 261 "Standard", 2013, 8, 23, NULL);
255 trial->UseOneTimeRandomization(); 262 trial->UseOneTimeRandomization();
256 hqp_use_cursor_position_experiment_group = 263 hqp_use_cursor_position_experiment_group =
257 trial->AppendGroup("HQPUseCursorPosition", 264 trial->AppendGroup("HQPUseCursorPosition",
258 kHQPUseCursorPositionFieldTrialExperimentFraction); 265 kHQPUseCursorPositionFieldTrialExperimentFraction);
259 266
260 static_field_trials_initialized = true; 267 static_field_trials_initialized = true;
261 } 268 }
262 269
263 void AutocompleteFieldTrial::ActivateDynamicTrials() { 270 void AutocompleteFieldTrial::ActivateDynamicTrials() {
264 // Initialize all autocomplete dynamic field trials. 271 // Initialize all autocomplete dynamic field trials. This method may be
272 // called multiple times.
273 for (int i = 0; i < kMaxAutocompleteDynamicFieldTrials; ++i)
274 base::FieldTrialList::FindValue(DynamicFieldTrialName(i));
275 }
276
277 int AutocompleteFieldTrial::GetDisabledProviderTypes() {
278 // Make sure that Autocomplete dynamic field trials are activated. It's OK to
279 // call this method multiple times.
280 ActivateDynamicTrials();
281
282 // Look for group names in form of "DisabledProviders_<mask>" where "mask"
283 // is a bitmap of disabled provider types (AutocompleteProvider::Type).
284 int provider_types = 0;
265 for (int i = 0; i < kMaxAutocompleteDynamicFieldTrials; ++i) { 285 for (int i = 0; i < kMaxAutocompleteDynamicFieldTrials; ++i) {
266 base::FieldTrialList::FindValue( 286 std::string group_name = base::FieldTrialList::FindFullName(
267 base::StringPrintf("%s%d", kAutocompleteDynamicFieldTrialPrefix, i)); 287 DynamicFieldTrialName(i));
288 const char kDisabledProviders[] = "DisabledProviders_";
289 if (!StartsWithASCII(group_name, kDisabledProviders, true))
290 continue;
291 int types = 0;
292 if (!base::StringToInt(base::StringPiece(
293 group_name.substr(strlen(kDisabledProviders))), &types)) {
294 LOG(WARNING) << "Malformed DisabledProviders string: " << group_name;
295 continue;
296 }
297 if (types == 0)
298 LOG(WARNING) << "Expecting a non-zero bitmap; group = " << group_name;
299 else
300 provider_types |= types;
268 } 301 }
302 return provider_types;
269 } 303 }
270 304
271 bool AutocompleteFieldTrial::InDisallowInlineHQPFieldTrial() { 305 bool AutocompleteFieldTrial::InDisallowInlineHQPFieldTrial() {
272 return base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName); 306 return base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName);
273 } 307 }
274 308
275 bool AutocompleteFieldTrial::InDisallowInlineHQPFieldTrialExperimentGroup() { 309 bool AutocompleteFieldTrial::InDisallowInlineHQPFieldTrialExperimentGroup() {
276 if (!base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName)) 310 if (!base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName))
277 return false; 311 return false;
278 312
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 bool AutocompleteFieldTrial:: 406 bool AutocompleteFieldTrial::
373 InHQPUseCursorPositionFieldTrialExperimentGroup() { 407 InHQPUseCursorPositionFieldTrialExperimentGroup() {
374 if (!InHQPUseCursorPositionFieldTrial()) 408 if (!InHQPUseCursorPositionFieldTrial())
375 return false; 409 return false;
376 410
377 // Return true if we're in the experiment group. 411 // Return true if we're in the experiment group.
378 const int group = base::FieldTrialList::FindValue( 412 const int group = base::FieldTrialList::FindValue(
379 kHQPUseCursorPositionFieldTrialName); 413 kHQPUseCursorPositionFieldTrialName);
380 return group == hqp_use_cursor_position_experiment_group; 414 return group == hqp_use_cursor_position_experiment_group;
381 } 415 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698