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

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

Issue 11757004: Omnibox: Add Mid-Input Matching to HistoryQuick Provider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo in comment 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 14 matching lines...) Expand all
25 "OmniboxSearchSuggestTrialStarted2013Q1"; 25 "OmniboxSearchSuggestTrialStarted2013Q1";
26 static const char kHQPNewScoringFieldTrialName[] = 26 static const char kHQPNewScoringFieldTrialName[] =
27 "OmniboxHQPNewScoringMax1400"; 27 "OmniboxHQPNewScoringMax1400";
28 static const char kHUPCullRedirectsFieldTrialName[] = "OmniboxHUPCullRedirects"; 28 static const char kHUPCullRedirectsFieldTrialName[] = "OmniboxHUPCullRedirects";
29 static const char kHUPCreateShorterMatchFieldTrialName[] = 29 static const char kHUPCreateShorterMatchFieldTrialName[] =
30 "OmniboxHUPCreateShorterMatch"; 30 "OmniboxHUPCreateShorterMatch";
31 static const char kHQPReplaceHUPScoringFieldTrialName[] = 31 static const char kHQPReplaceHUPScoringFieldTrialName[] =
32 "OmniboxHQPReplaceHUPHostFix"; 32 "OmniboxHQPReplaceHUPHostFix";
33 static const char kHQPOnlyCountMatchesAtWordBoundariesFieldTrialName[] = 33 static const char kHQPOnlyCountMatchesAtWordBoundariesFieldTrialName[] =
34 "OmniboxHQPOnlyCountMatchesAtWordBoundaries"; 34 "OmniboxHQPOnlyCountMatchesAtWordBoundaries";
35 static const char kHQPUseCursorPositionFieldTrialName[] =
36 "OmniboxHQPUseCursorPosition";
35 37
36 // The autocomplete dynamic field trial name prefix. Each field trial is 38 // The autocomplete dynamic field trial name prefix. Each field trial is
37 // configured dynamically and is retrieved automatically by Chrome during 39 // configured dynamically and is retrieved automatically by Chrome during
38 // the startup. 40 // the startup.
39 const char kAutocompleteDynamicFieldTrialPrefix[] = "AutocompleteDynamicTrial_"; 41 const char kAutocompleteDynamicFieldTrialPrefix[] = "AutocompleteDynamicTrial_";
40 // The maximum number of the autocomplete dynamic field trials (aka layers). 42 // The maximum number of the autocomplete dynamic field trials (aka layers).
41 const int kMaxAutocompleteDynamicFieldTrials = 5; 43 const int kMaxAutocompleteDynamicFieldTrials = 5;
42 44
43 // Field trial experiment probabilities. 45 // Field trial experiment probabilities.
44 46
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 const base::FieldTrial::Probability 88 const base::FieldTrial::Probability
87 kHQPReplaceHUPScoringFieldTrialExperimentFraction = 25; 89 kHQPReplaceHUPScoringFieldTrialExperimentFraction = 25;
88 90
89 // For the field trial that ignores all mid-term matches in HistoryQuick 91 // 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. 92 // provider, put 0% ( = 0/100 ) of the users in the experiment group.
91 const base::FieldTrial::Probability 93 const base::FieldTrial::Probability
92 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialDivisor = 100; 94 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialDivisor = 100;
93 const base::FieldTrial::Probability 95 const base::FieldTrial::Probability
94 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialExperimentFraction = 0; 96 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialExperimentFraction = 0;
95 97
98 // 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 const base::FieldTrial::Probability
101 kHQPUseCursorPositionFieldTrialDivisor = 100;
102 const base::FieldTrial::Probability
103 kHQPUseCursorPositionFieldTrialExperimentFraction = 25;
104
96 105
97 // Field trial IDs. 106 // Field trial IDs.
98 // Though they are not literally "const", they are set only once, in 107 // Though they are not literally "const", they are set only once, in
99 // Activate() below. 108 // Activate() below.
100 109
101 // Whether the static field trials have been initialized by 110 // Whether the static field trials have been initialized by
102 // ActivateStaticTrials method. 111 // ActivateStaticTrials method.
103 bool static_field_trials_initialized = false; 112 bool static_field_trials_initialized = false;
104 113
105 // Field trial ID for the disallow-inline History Quick Provider 114 // Field trial ID for the disallow-inline History Quick Provider
(...skipping 11 matching lines...) Expand all
117 int hup_dont_create_shorter_match_experiment_group = 0; 126 int hup_dont_create_shorter_match_experiment_group = 0;
118 127
119 // Field trial ID for the HistoryQuick provider replaces HistoryURL provider 128 // Field trial ID for the HistoryQuick provider replaces HistoryURL provider
120 // experiment group. 129 // experiment group.
121 int hqp_replace_hup_scoring_experiment_group = 0; 130 int hqp_replace_hup_scoring_experiment_group = 0;
122 131
123 // Field trial ID for the HistoryQuick provider only count matches at 132 // Field trial ID for the HistoryQuick provider only count matches at
124 // word boundaries experiment group. 133 // word boundaries experiment group.
125 int hqp_only_count_matches_at_word_boundaries_experiment_group = 0; 134 int hqp_only_count_matches_at_word_boundaries_experiment_group = 0;
126 135
136 // Field trial ID for the HistoryQuick provider use cursor position
137 // experiment group.
138 int hqp_use_cursor_position_experiment_group = 0;
139
127 } 140 }
128 141
129 142
130 void AutocompleteFieldTrial::ActivateStaticTrials() { 143 void AutocompleteFieldTrial::ActivateStaticTrials() {
131 DCHECK(!static_field_trials_initialized); 144 DCHECK(!static_field_trials_initialized);
132 145
133 // Create inline History Quick Provider field trial. 146 // Create inline History Quick Provider field trial.
134 // Make it expire on November 8, 2012. 147 // Make it expire on November 8, 2012.
135 scoped_refptr<base::FieldTrial> trial( 148 scoped_refptr<base::FieldTrial> trial(
136 base::FieldTrialList::FactoryGetFieldTrial( 149 base::FieldTrialList::FactoryGetFieldTrial(
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 // expire on June 23, 2013. 239 // expire on June 23, 2013.
227 trial = base::FieldTrialList::FactoryGetFieldTrial( 240 trial = base::FieldTrialList::FactoryGetFieldTrial(
228 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialName, 241 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialName,
229 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialDivisor, 242 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialDivisor,
230 "Standard", 2013, 6, 23, NULL); 243 "Standard", 2013, 6, 23, NULL);
231 trial->UseOneTimeRandomization(); 244 trial->UseOneTimeRandomization();
232 hqp_only_count_matches_at_word_boundaries_experiment_group = 245 hqp_only_count_matches_at_word_boundaries_experiment_group =
233 trial->AppendGroup("HQPOnlyCountMatchesAtWordBoundaries", 246 trial->AppendGroup("HQPOnlyCountMatchesAtWordBoundaries",
234 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialExperimentFraction); 247 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialExperimentFraction);
235 248
249 // Create the field trial that allows HistoryQuick provider to break
250 // omnibox inputs at the cursor position. Make it expire on August 23, 2013.
251 trial = base::FieldTrialList::FactoryGetFieldTrial(
252 kHQPUseCursorPositionFieldTrialName,
253 kHQPUseCursorPositionFieldTrialDivisor,
254 "Standard", 2013, 8, 23, NULL);
255 trial->UseOneTimeRandomization();
256 hqp_use_cursor_position_experiment_group =
257 trial->AppendGroup("HQPUseCursorPosition",
258 kHQPUseCursorPositionFieldTrialExperimentFraction);
259
236 static_field_trials_initialized = true; 260 static_field_trials_initialized = true;
237 } 261 }
238 262
239 void AutocompleteFieldTrial::ActivateDynamicTrials() { 263 void AutocompleteFieldTrial::ActivateDynamicTrials() {
240 // Initialize all autocomplete dynamic field trials. 264 // Initialize all autocomplete dynamic field trials.
241 for (int i = 0; i < kMaxAutocompleteDynamicFieldTrials; ++i) { 265 for (int i = 0; i < kMaxAutocompleteDynamicFieldTrials; ++i) {
242 base::FieldTrialList::FindValue( 266 base::FieldTrialList::FindValue(
243 base::StringPrintf("%s%d", kAutocompleteDynamicFieldTrialPrefix, i)); 267 base::StringPrintf("%s%d", kAutocompleteDynamicFieldTrialPrefix, i));
244 } 268 }
245 } 269 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 bool AutocompleteFieldTrial:: 357 bool AutocompleteFieldTrial::
334 InHQPOnlyCountMatchesAtWordBoundariesFieldTrialExperimentGroup() { 358 InHQPOnlyCountMatchesAtWordBoundariesFieldTrialExperimentGroup() {
335 if (!InHQPOnlyCountMatchesAtWordBoundariesFieldTrial()) 359 if (!InHQPOnlyCountMatchesAtWordBoundariesFieldTrial())
336 return false; 360 return false;
337 361
338 // Return true if we're in the experiment group. 362 // Return true if we're in the experiment group.
339 const int group = base::FieldTrialList::FindValue( 363 const int group = base::FieldTrialList::FindValue(
340 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialName); 364 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialName);
341 return group == hqp_only_count_matches_at_word_boundaries_experiment_group; 365 return group == hqp_only_count_matches_at_word_boundaries_experiment_group;
342 } 366 }
367
368 bool AutocompleteFieldTrial::InHQPUseCursorPositionFieldTrial() {
369 return base::FieldTrialList::TrialExists(kHQPUseCursorPositionFieldTrialName);
370 }
371
372 bool AutocompleteFieldTrial::
373 InHQPUseCursorPositionFieldTrialExperimentGroup() {
374 if (!InHQPUseCursorPositionFieldTrial())
375 return false;
376
377 // Return true if we're in the experiment group.
378 const int group = base::FieldTrialList::FindValue(
379 kHQPUseCursorPositionFieldTrialName);
380 return group == hqp_use_cursor_position_experiment_group;
381 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_field_trial.h ('k') | chrome/browser/autocomplete/history_quick_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698