Chromium Code Reviews| 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/omnibox/omnibox_field_trial.h" | 5 #include "chrome/browser/omnibox/omnibox_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/string_util.h" |
| 11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "chrome/common/metrics/metrics_util.h" | 13 #include "chrome/common/metrics/metrics_util.h" |
| 14 #include "chrome/common/metrics/variations/variation_ids.h" | 14 #include "chrome/common/metrics/variations/variation_ids.h" |
| 15 #include "chrome/common/metrics/variations/variations_util.h" | 15 #include "chrome/common/metrics/variations/variations_util.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 // Field trial names. | 19 // Field trial names. |
| 20 const char kDisallowInlineHQPFieldTrialName[] = "OmniboxDisallowInlineHQP"; | 20 const char kDisallowInlineHQPFieldTrialName[] = "OmniboxDisallowInlineHQP"; |
| 21 // Because we regularly change the name of the suggest field trial in | |
| 22 // order to shuffle users among groups, we use the date the current trial | |
| 23 // was created as part of the name. | |
| 24 const char kSuggestFieldTrialStarted2013Q1Name[] = | |
| 25 "OmniboxSearchSuggestTrialStarted2013Q1"; | |
| 26 const char kHQPNewScoringFieldTrialName[] = "OmniboxHQPNewScoringMax1400"; | 21 const char kHQPNewScoringFieldTrialName[] = "OmniboxHQPNewScoringMax1400"; |
| 27 const char kHUPCullRedirectsFieldTrialName[] = "OmniboxHUPCullRedirects"; | 22 const char kHUPCullRedirectsFieldTrialName[] = "OmniboxHUPCullRedirects"; |
| 28 const char kHUPCreateShorterMatchFieldTrialName[] = | 23 const char kHUPCreateShorterMatchFieldTrialName[] = |
| 29 "OmniboxHUPCreateShorterMatch"; | 24 "OmniboxHUPCreateShorterMatch"; |
| 30 const char kHQPReplaceHUPScoringFieldTrialName[] = | 25 const char kHQPReplaceHUPScoringFieldTrialName[] = |
| 31 "OmniboxHQPReplaceHUPProhibitTrumpingInlineableResult"; | 26 "OmniboxHQPReplaceHUPProhibitTrumpingInlineableResult"; |
| 32 | 27 |
| 33 // The autocomplete dynamic field trial name prefix. Each field trial is | 28 // The autocomplete dynamic field trial name prefix. Each field trial is |
| 34 // configured dynamically and is retrieved automatically by Chrome during | 29 // configured dynamically and is retrieved automatically by Chrome during |
| 35 // the startup. | 30 // the startup. |
| 36 const char kAutocompleteDynamicFieldTrialPrefix[] = "AutocompleteDynamicTrial_"; | 31 const char kAutocompleteDynamicFieldTrialPrefix[] = "AutocompleteDynamicTrial_"; |
| 37 // The maximum number of the autocomplete dynamic field trials (aka layers). | 32 // The maximum number of the autocomplete dynamic field trials (aka layers). |
| 38 const int kMaxAutocompleteDynamicFieldTrials = 5; | 33 const int kMaxAutocompleteDynamicFieldTrials = 5; |
| 39 | 34 |
| 40 // Field trial experiment probabilities. | 35 // Field trial experiment probabilities. |
| 41 | 36 |
| 42 // For inline History Quick Provider field trial, put 0% ( = 0/100 ) | 37 // For inline History Quick Provider field trial, put 0% ( = 0/100 ) |
| 43 // of the users in the disallow-inline experiment group. | 38 // of the users in the disallow-inline experiment group. |
| 44 const base::FieldTrial::Probability kDisallowInlineHQPFieldTrialDivisor = 100; | 39 const base::FieldTrial::Probability kDisallowInlineHQPFieldTrialDivisor = 100; |
| 45 const base::FieldTrial::Probability | 40 const base::FieldTrial::Probability |
| 46 kDisallowInlineHQPFieldTrialExperimentFraction = 0; | 41 kDisallowInlineHQPFieldTrialExperimentFraction = 0; |
| 47 | 42 |
| 48 // For the search suggestion field trial, divide the people in the | |
| 49 // trial into 20 equally-sized buckets. The suggest provider backend | |
| 50 // will decide what behavior (if any) to change based on the group. | |
| 51 const int kSuggestFieldTrialNumberOfGroups = 20; | |
| 52 | |
| 53 // For History Quick Provider new scoring field trial, put 0% ( = 0/100 ) | 43 // For History Quick Provider new scoring field trial, put 0% ( = 0/100 ) |
| 54 // of the users in the new scoring experiment group. | 44 // of the users in the new scoring experiment group. |
| 55 const base::FieldTrial::Probability kHQPNewScoringFieldTrialDivisor = 100; | 45 const base::FieldTrial::Probability kHQPNewScoringFieldTrialDivisor = 100; |
| 56 const base::FieldTrial::Probability | 46 const base::FieldTrial::Probability |
| 57 kHQPNewScoringFieldTrialExperimentFraction = 0; | 47 kHQPNewScoringFieldTrialExperimentFraction = 0; |
| 58 | 48 |
| 59 // For HistoryURL provider cull redirects field trial, put 0% ( = 0/100 ) | 49 // For HistoryURL provider cull redirects field trial, put 0% ( = 0/100 ) |
| 60 // of the users in the don't-cull-redirects experiment group. | 50 // of the users in the don't-cull-redirects experiment group. |
| 61 // TODO(mpearson): Remove this field trial and the code it uses once I'm | 51 // TODO(mpearson): Remove this field trial and the code it uses once I'm |
| 62 // sure it's no longer needed. | 52 // sure it's no longer needed. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 // get ingrained, users tend to learn that a particular suggestion is | 123 // get ingrained, users tend to learn that a particular suggestion is |
| 134 // at a particular spot in the drop-down--we're going to make these | 124 // at a particular spot in the drop-down--we're going to make these |
| 135 // field trials sticky. We want users to stay in them once assigned | 125 // field trials sticky. We want users to stay in them once assigned |
| 136 // so they have a better experience and also so we don't get weird | 126 // so they have a better experience and also so we don't get weird |
| 137 // effects as omnibox ranking keeps changing and users learn they can't | 127 // effects as omnibox ranking keeps changing and users learn they can't |
| 138 // trust the omnibox. | 128 // trust the omnibox. |
| 139 trial->UseOneTimeRandomization(); | 129 trial->UseOneTimeRandomization(); |
| 140 disallow_inline_hqp_experiment_group = trial->AppendGroup("DisallowInline", | 130 disallow_inline_hqp_experiment_group = trial->AppendGroup("DisallowInline", |
| 141 kDisallowInlineHQPFieldTrialExperimentFraction); | 131 kDisallowInlineHQPFieldTrialExperimentFraction); |
| 142 | 132 |
| 143 // Create the suggest field trial. | |
| 144 // Make it expire on September 1, 2013. | |
| 145 trial = base::FieldTrialList::FactoryGetFieldTrial( | |
| 146 kSuggestFieldTrialStarted2013Q1Name, kSuggestFieldTrialNumberOfGroups, | |
| 147 "0", 2013, 9, 1, NULL); | |
| 148 trial->UseOneTimeRandomization(); | |
| 149 | |
| 150 // Mark this group in suggest requests to Google. | |
| 151 chrome_variations::AssociateGoogleVariationID( | |
| 152 chrome_variations::GOOGLE_WEB_PROPERTIES, | |
| 153 kSuggestFieldTrialStarted2013Q1Name, "0", | |
| 154 chrome_variations::SUGGEST_TRIAL_STARTED_2013_Q1_ID_MIN); | |
| 155 DCHECK_EQ(kSuggestFieldTrialNumberOfGroups, | |
| 156 chrome_variations::SUGGEST_TRIAL_STARTED_2013_Q1_ID_MAX - | |
| 157 chrome_variations::SUGGEST_TRIAL_STARTED_2013_Q1_ID_MIN + 1); | |
| 158 | |
| 159 // We've already created one group; now just need to create | |
| 160 // kSuggestFieldTrialNumGroups - 1 more. Mark these groups in | |
| 161 // suggest requests to Google. | |
| 162 for (int i = 1; i < kSuggestFieldTrialNumberOfGroups; i++) { | |
| 163 const std::string group_name = base::IntToString(i); | |
| 164 trial->AppendGroup(group_name, 1); | |
| 165 chrome_variations::AssociateGoogleVariationID( | |
| 166 chrome_variations::GOOGLE_WEB_PROPERTIES, | |
| 167 kSuggestFieldTrialStarted2013Q1Name, group_name, | |
| 168 static_cast<chrome_variations::VariationID>( | |
| 169 chrome_variations::SUGGEST_TRIAL_STARTED_2013_Q1_ID_MIN + i)); | |
| 170 } | |
| 171 | |
| 172 // Make sure that we participate in the suggest experiment by calling group() | |
| 173 // on the newly created field trial. This is necessary to activate the field | |
| 174 // trial group as there are no more references to it within the Chrome code. | |
| 175 trial->group(); | |
| 176 | |
| 177 // Create inline History Quick Provider new scoring field trial. | 133 // Create inline History Quick Provider new scoring field trial. |
| 178 // Make it expire on April 14, 2013. | 134 // Make it expire on April 14, 2013. |
| 179 trial = base::FieldTrialList::FactoryGetFieldTrial( | 135 trial = base::FieldTrialList::FactoryGetFieldTrial( |
| 180 kHQPNewScoringFieldTrialName, kHQPNewScoringFieldTrialDivisor, | 136 kHQPNewScoringFieldTrialName, kHQPNewScoringFieldTrialDivisor, |
| 181 "Standard", 2013, 4, 14, NULL); | 137 "Standard", 2013, 4, 14, NULL); |
| 182 trial->UseOneTimeRandomization(); | 138 trial->UseOneTimeRandomization(); |
| 183 hqp_new_scoring_experiment_group = trial->AppendGroup("NewScoring", | 139 hqp_new_scoring_experiment_group = trial->AppendGroup("NewScoring", |
| 184 kHQPNewScoringFieldTrialExperimentFraction); | 140 kHQPNewScoringFieldTrialExperimentFraction); |
| 185 | 141 |
| 186 // Create the HistoryURL provider cull redirects field trial. | 142 // Create the HistoryURL provider cull redirects field trial. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 bool OmniboxFieldTrial::InDisallowInlineHQPFieldTrialExperimentGroup() { | 215 bool OmniboxFieldTrial::InDisallowInlineHQPFieldTrialExperimentGroup() { |
| 260 if (!base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName)) | 216 if (!base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName)) |
| 261 return false; | 217 return false; |
| 262 | 218 |
| 263 // Return true if we're in the experiment group. | 219 // Return true if we're in the experiment group. |
| 264 const int group = base::FieldTrialList::FindValue( | 220 const int group = base::FieldTrialList::FindValue( |
| 265 kDisallowInlineHQPFieldTrialName); | 221 kDisallowInlineHQPFieldTrialName); |
| 266 return group == disallow_inline_hqp_experiment_group; | 222 return group == disallow_inline_hqp_experiment_group; |
| 267 } | 223 } |
| 268 | 224 |
| 269 bool OmniboxFieldTrial::GetActiveSuggestFieldTrialHash( | 225 bool OmniboxFieldTrial::GetActiveSuggestFieldTrialHashes( |
| 270 uint32* field_trial_hash) { | 226 std::vector<uint32>* field_trial_hashes) { |
|
Mark P
2013/04/11 18:17:14
Please explicitly clear it first.
Bart N.
2013/04/11 19:35:07
Done.
| |
| 271 if (!base::FieldTrialList::TrialExists(kSuggestFieldTrialStarted2013Q1Name)) | 227 bool found = false; |
|
Mark P
2013/04/11 18:17:14
Rather having a found variable, consider returning
Bart N.
2013/04/11 19:35:07
Yes, much better now.
| |
| 272 return false; | 228 for (int i = 0; i < kMaxAutocompleteDynamicFieldTrials; ++i) { |
| 273 | 229 const std::string& trial_name = DynamicFieldTrialName(i); |
| 274 *field_trial_hash = metrics::HashName(kSuggestFieldTrialStarted2013Q1Name); | 230 if (base::FieldTrialList::TrialExists(trial_name)) { |
| 275 return true; | 231 field_trial_hashes->push_back(metrics::HashName(trial_name)); |
| 232 found = true; | |
| 233 } | |
| 234 } | |
| 235 return found; | |
| 276 } | 236 } |
| 277 | 237 |
| 278 bool OmniboxFieldTrial::InHQPNewScoringFieldTrial() { | 238 bool OmniboxFieldTrial::InHQPNewScoringFieldTrial() { |
| 279 return base::FieldTrialList::TrialExists(kHQPNewScoringFieldTrialName); | 239 return base::FieldTrialList::TrialExists(kHQPNewScoringFieldTrialName); |
| 280 } | 240 } |
| 281 | 241 |
| 282 bool OmniboxFieldTrial::InHQPNewScoringFieldTrialExperimentGroup() { | 242 bool OmniboxFieldTrial::InHQPNewScoringFieldTrialExperimentGroup() { |
| 283 if (!InHQPNewScoringFieldTrial()) | 243 if (!InHQPNewScoringFieldTrial()) |
| 284 return false; | 244 return false; |
| 285 | 245 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 | 284 |
| 325 bool OmniboxFieldTrial::InHQPReplaceHUPScoringFieldTrialExperimentGroup() { | 285 bool OmniboxFieldTrial::InHQPReplaceHUPScoringFieldTrialExperimentGroup() { |
| 326 if (!InHQPReplaceHUPScoringFieldTrial()) | 286 if (!InHQPReplaceHUPScoringFieldTrial()) |
| 327 return false; | 287 return false; |
| 328 | 288 |
| 329 // Return true if we're in the experiment group. | 289 // Return true if we're in the experiment group. |
| 330 const int group = base::FieldTrialList::FindValue( | 290 const int group = base::FieldTrialList::FindValue( |
| 331 kHQPReplaceHUPScoringFieldTrialName); | 291 kHQPReplaceHUPScoringFieldTrialName); |
| 332 return group == hqp_replace_hup_scoring_experiment_group; | 292 return group == hqp_replace_hup_scoring_experiment_group; |
| 333 } | 293 } |
| OLD | NEW |