| OLD | NEW |
| 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" |
| 11 #include "chrome/common/metrics/variations/variation_ids.h" | 11 #include "chrome/common/metrics/variations/variation_ids.h" |
| 12 #include "chrome/common/metrics/variations/variations_util.h" | 12 #include "chrome/common/metrics/variations/variations_util.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 // Field trial names. | 16 // Field trial names. |
| 17 static const char kDisallowInlineHQPFieldTrialName[] = | 17 static const char kDisallowInlineHQPFieldTrialName[] = |
| 18 "OmniboxDisallowInlineHQP"; | 18 "OmniboxDisallowInlineHQP"; |
| 19 // Because we regularly change the name of the suggest field trial in | 19 // Because we regularly change the name of the suggest field trial in |
| 20 // order to shuffle users among groups, we use the date the current trial | 20 // order to shuffle users among groups, we use the date the current trial |
| 21 // was created as part of the name. | 21 // was created as part of the name. |
| 22 static const char kSuggestFieldTrialStarted2012Q4Name[] = | 22 static const char kSuggestFieldTrialStarted2012Q4Name[] = |
| 23 "OmniboxSearchSuggestTrialStarted2012Q4"; | 23 "OmniboxSearchSuggestTrialStarted2012Q4"; |
| 24 static const char kHQPNewScoringFieldTrialName[] = "OmniboxHQPNewScoring"; | 24 static const char kHQPNewScoringFieldTrialName[] = "OmniboxHQPNewScoring"; |
| 25 static const char kHUPCullRedirectsFieldTrialName[] = "OmniboxHUPCullRedirects"; | 25 static const char kHUPCullRedirectsFieldTrialName[] = "OmniboxHUPCullRedirects"; |
| 26 static const char kHUPCreateShorterMatchFieldTrialName[] = | 26 static const char kHUPCreateShorterMatchFieldTrialName[] = |
| 27 "OmniboxHUPCreateShorterMatch"; | 27 "OmniboxHUPCreateShorterMatch"; |
| 28 static const char kHQPReplaceHUPScoringFieldTrialName[] = | 28 static const char kHQPReplaceHUPScoringFieldTrialName[] = |
| 29 "OmniboxHQPReplaceHUPNumComponentsFix"; | 29 "OmniboxHQPReplaceHUPNumComponentsFix"; |
| 30 static const char kHQPOnlyCountMatchesAtWordBoundariesFieldTrialName[] = |
| 31 "OmniboxHQPOnlyCountMatchesAtWordBoundaries"; |
| 30 | 32 |
| 31 // Field trial experiment probabilities. | 33 // Field trial experiment probabilities. |
| 32 | 34 |
| 33 // For inline History Quick Provider field trial, put 0% ( = 0/100 ) | 35 // For inline History Quick Provider field trial, put 0% ( = 0/100 ) |
| 34 // of the users in the disallow-inline experiment group. | 36 // of the users in the disallow-inline experiment group. |
| 35 const base::FieldTrial::Probability kDisallowInlineHQPFieldTrialDivisor = 100; | 37 const base::FieldTrial::Probability kDisallowInlineHQPFieldTrialDivisor = 100; |
| 36 const base::FieldTrial::Probability | 38 const base::FieldTrial::Probability |
| 37 kDisallowInlineHQPFieldTrialExperimentFraction = 0; | 39 kDisallowInlineHQPFieldTrialExperimentFraction = 0; |
| 38 | 40 |
| 39 // For the search suggestion field trial, divide the people in the | 41 // For the search suggestion field trial, divide the people in the |
| (...skipping 27 matching lines...) Expand all Loading... |
| 67 | 69 |
| 68 // For the field trial that removes searching/scoring URLs from | 70 // For the field trial that removes searching/scoring URLs from |
| 69 // HistoryURL provider and adds a HistoryURL-provider-like scoring | 71 // HistoryURL provider and adds a HistoryURL-provider-like scoring |
| 70 // mode to HistoryQuick provider, put 25% ( = 25/100 ) of the users in | 72 // mode to HistoryQuick provider, put 25% ( = 25/100 ) of the users in |
| 71 // the experiment group. | 73 // the experiment group. |
| 72 const base::FieldTrial::Probability | 74 const base::FieldTrial::Probability |
| 73 kHQPReplaceHUPScoringFieldTrialDivisor = 100; | 75 kHQPReplaceHUPScoringFieldTrialDivisor = 100; |
| 74 const base::FieldTrial::Probability | 76 const base::FieldTrial::Probability |
| 75 kHQPReplaceHUPScoringFieldTrialExperimentFraction = 25; | 77 kHQPReplaceHUPScoringFieldTrialExperimentFraction = 25; |
| 76 | 78 |
| 79 // For the field trial that ignores all mid-term matches in HistoryQuick |
| 80 // provider, put 25% ( = 25/100 ) of the users in the experiment group. |
| 81 const base::FieldTrial::Probability |
| 82 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialDivisor = 100; |
| 83 const base::FieldTrial::Probability |
| 84 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialExperimentFraction = 25; |
| 85 |
| 77 | 86 |
| 78 // Field trial IDs. | 87 // Field trial IDs. |
| 79 // Though they are not literally "const", they are set only once, in | 88 // Though they are not literally "const", they are set only once, in |
| 80 // Activate() below. | 89 // Activate() below. |
| 81 | 90 |
| 82 // Field trial ID for the disallow-inline History Quick Provider | 91 // Field trial ID for the disallow-inline History Quick Provider |
| 83 // experiment group. | 92 // experiment group. |
| 84 int disallow_inline_hqp_experiment_group = 0; | 93 int disallow_inline_hqp_experiment_group = 0; |
| 85 | 94 |
| 86 // Field trial ID for the History Quick Provider new scoring experiment group. | 95 // Field trial ID for the History Quick Provider new scoring experiment group. |
| 87 int hqp_new_scoring_experiment_group = 0; | 96 int hqp_new_scoring_experiment_group = 0; |
| 88 | 97 |
| 89 // Field trial ID for the HistoryURL provider cull redirects experiment group. | 98 // Field trial ID for the HistoryURL provider cull redirects experiment group. |
| 90 int hup_dont_cull_redirects_experiment_group = 0; | 99 int hup_dont_cull_redirects_experiment_group = 0; |
| 91 | 100 |
| 92 // Field trial ID for the HistoryURL provider create shorter match | 101 // Field trial ID for the HistoryURL provider create shorter match |
| 93 // experiment group. | 102 // experiment group. |
| 94 int hup_dont_create_shorter_match_experiment_group = 0; | 103 int hup_dont_create_shorter_match_experiment_group = 0; |
| 95 | 104 |
| 96 // Field trial ID for the HistoryQuick provider replaces HistoryURL provider | 105 // Field trial ID for the HistoryQuick provider replaces HistoryURL provider |
| 97 // experiment group. | 106 // experiment group. |
| 98 int hqp_replace_hup_scoring_experiment_group = 0; | 107 int hqp_replace_hup_scoring_experiment_group = 0; |
| 99 | 108 |
| 109 // Field trial ID for the HistoryQuick provider only count matches at |
| 110 // word boundaries experiment group. |
| 111 int hqp_only_count_matches_at_word_boundaries_experiment_group = 0; |
| 112 |
| 100 } | 113 } |
| 101 | 114 |
| 102 | 115 |
| 103 void AutocompleteFieldTrial::Activate() { | 116 void AutocompleteFieldTrial::Activate() { |
| 104 // Create inline History Quick Provider field trial. | 117 // Create inline History Quick Provider field trial. |
| 105 // Make it expire on November 8, 2012. | 118 // Make it expire on November 8, 2012. |
| 106 scoped_refptr<base::FieldTrial> trial( | 119 scoped_refptr<base::FieldTrial> trial( |
| 107 base::FieldTrialList::FactoryGetFieldTrial( | 120 base::FieldTrialList::FactoryGetFieldTrial( |
| 108 kDisallowInlineHQPFieldTrialName, kDisallowInlineHQPFieldTrialDivisor, | 121 kDisallowInlineHQPFieldTrialName, kDisallowInlineHQPFieldTrialDivisor, |
| 109 "Standard", 2012, 11, 8, NULL)); | 122 "Standard", 2012, 11, 8, NULL)); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 // Create the field trial that makes HistoryQuick provider score | 197 // Create the field trial that makes HistoryQuick provider score |
| 185 // some results like HistoryURL provider and simultaneously disable | 198 // some results like HistoryURL provider and simultaneously disable |
| 186 // HistoryURL provider from searching the URL database. Make it | 199 // HistoryURL provider from searching the URL database. Make it |
| 187 // expire on June 23, 2013. | 200 // expire on June 23, 2013. |
| 188 trial = base::FieldTrialList::FactoryGetFieldTrial( | 201 trial = base::FieldTrialList::FactoryGetFieldTrial( |
| 189 kHQPReplaceHUPScoringFieldTrialName, kHQPReplaceHUPScoringFieldTrialDivisor, | 202 kHQPReplaceHUPScoringFieldTrialName, kHQPReplaceHUPScoringFieldTrialDivisor, |
| 190 "Standard", 2013, 6, 23, NULL); | 203 "Standard", 2013, 6, 23, NULL); |
| 191 trial->UseOneTimeRandomization(); | 204 trial->UseOneTimeRandomization(); |
| 192 hqp_replace_hup_scoring_experiment_group = trial->AppendGroup("HQPReplaceHUP", | 205 hqp_replace_hup_scoring_experiment_group = trial->AppendGroup("HQPReplaceHUP", |
| 193 kHQPReplaceHUPScoringFieldTrialExperimentFraction); | 206 kHQPReplaceHUPScoringFieldTrialExperimentFraction); |
| 207 |
| 208 // Create the field trial that makes HistoryQuick provider score |
| 209 // ignore all matches that happen in the middle of a word. Make it |
| 210 // expire on June 23, 2013. |
| 211 trial = base::FieldTrialList::FactoryGetFieldTrial( |
| 212 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialName, |
| 213 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialDivisor, |
| 214 "Standard", 2013, 6, 23, NULL); |
| 215 trial->UseOneTimeRandomization(); |
| 216 hqp_only_count_matches_at_word_boundaries_experiment_group = |
| 217 trial->AppendGroup("HQPOnlyCountMatchesAtWordBoundaries", |
| 218 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialExperimentFraction); |
| 194 } | 219 } |
| 195 | 220 |
| 196 bool AutocompleteFieldTrial::InDisallowInlineHQPFieldTrial() { | 221 bool AutocompleteFieldTrial::InDisallowInlineHQPFieldTrial() { |
| 197 return base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName); | 222 return base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName); |
| 198 } | 223 } |
| 199 | 224 |
| 200 bool AutocompleteFieldTrial::InDisallowInlineHQPFieldTrialExperimentGroup() { | 225 bool AutocompleteFieldTrial::InDisallowInlineHQPFieldTrialExperimentGroup() { |
| 201 if (!base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName)) | 226 if (!base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName)) |
| 202 return false; | 227 return false; |
| 203 | 228 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 282 |
| 258 bool AutocompleteFieldTrial::InHQPReplaceHUPScoringFieldTrialExperimentGroup() { | 283 bool AutocompleteFieldTrial::InHQPReplaceHUPScoringFieldTrialExperimentGroup() { |
| 259 if (!InHQPReplaceHUPScoringFieldTrial()) | 284 if (!InHQPReplaceHUPScoringFieldTrial()) |
| 260 return false; | 285 return false; |
| 261 | 286 |
| 262 // Return true if we're in the experiment group. | 287 // Return true if we're in the experiment group. |
| 263 const int group = base::FieldTrialList::FindValue( | 288 const int group = base::FieldTrialList::FindValue( |
| 264 kHQPReplaceHUPScoringFieldTrialName); | 289 kHQPReplaceHUPScoringFieldTrialName); |
| 265 return group == hqp_replace_hup_scoring_experiment_group; | 290 return group == hqp_replace_hup_scoring_experiment_group; |
| 266 } | 291 } |
| 292 |
| 293 bool AutocompleteFieldTrial::InHQPOnlyCountMatchesAtWordBoundariesFieldTrial() { |
| 294 return base::FieldTrialList::TrialExists( |
| 295 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialName); |
| 296 } |
| 297 |
| 298 bool AutocompleteFieldTrial:: |
| 299 InHQPOnlyCountMatchesAtWordBoundariesFieldTrialExperimentGroup() { |
| 300 if (!InHQPOnlyCountMatchesAtWordBoundariesFieldTrial()) |
| 301 return false; |
| 302 |
| 303 // Return true if we're in the experiment group. |
| 304 const int group = base::FieldTrialList::FindValue( |
| 305 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialName); |
| 306 return group == hqp_only_count_matches_at_word_boundaries_experiment_group; |
| 307 } |
| OLD | NEW |