| 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/experiments_helper.h" | 11 #include "chrome/common/metrics/experiments_helper.h" |
| 12 #include "chrome/common/metrics/variation_ids.h" | 12 #include "chrome/common/metrics/variation_ids.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 static const char kSuggestFieldTrialName[] = "OmniboxSearchSuggest"; | 19 static const char kSuggestFieldTrialName[] = "OmniboxSearchSuggest"; |
| 20 static const char kHQPNewScoringFieldTrialName[] = "OmniboxHQPNewScoring"; |
| 20 | 21 |
| 21 // Field trial experiment probabilities. | 22 // Field trial experiment probabilities. |
| 22 | 23 |
| 23 // For inline History Quick Provider field trial, put 10% ( = 10/100 ) | 24 // For inline History Quick Provider field trial, put 10% ( = 10/100 ) |
| 24 // of the users in the disallow-inline experiment group. | 25 // of the users in the disallow-inline experiment group. |
| 25 const base::FieldTrial::Probability kDisallowInlineHQPFieldTrialDivisor = 100; | 26 const base::FieldTrial::Probability kDisallowInlineHQPFieldTrialDivisor = 100; |
| 26 const base::FieldTrial::Probability | 27 const base::FieldTrial::Probability |
| 27 kDisallowInlineHQPFieldTrialExperimentFraction = 10; | 28 kDisallowInlineHQPFieldTrialExperimentFraction = 10; |
| 28 | 29 |
| 29 // For the search suggestion field trial, divide the people in the | 30 // For the search suggestion field trial, divide the people in the |
| 30 // trial into 20 equally-sized buckets. The suggest provider backend | 31 // trial into 20 equally-sized buckets. The suggest provider backend |
| 31 // will decide what behavior (if any) to change based on the group. | 32 // will decide what behavior (if any) to change based on the group. |
| 32 const int kSuggestFieldTrialNumberOfGroups = 20; | 33 const int kSuggestFieldTrialNumberOfGroups = 20; |
| 33 | 34 |
| 35 // For History Quick Provider new scoring field trial, put 25% ( = 25/100 ) |
| 36 // of the users in the new scoring experiment group. |
| 37 const base::FieldTrial::Probability kHQPNewScoringFieldTrialDivisor = 100; |
| 38 const base::FieldTrial::Probability |
| 39 kHQPNewScoringFieldTrialExperimentFraction = 25; |
| 40 |
| 34 // Field trial IDs. | 41 // Field trial IDs. |
| 35 // Though they are not literally "const", they are set only once, in | 42 // Though they are not literally "const", they are set only once, in |
| 36 // Activate() below. | 43 // Activate() below. |
| 37 | 44 |
| 38 // Field trial ID for the disallow-inline History Quick Provider | 45 // Field trial ID for the disallow-inline History Quick Provider |
| 39 // experiment group. | 46 // experiment group. |
| 40 int disallow_inline_hqp_experiment_group = 0; | 47 int disallow_inline_hqp_experiment_group = 0; |
| 41 | 48 |
| 49 // Field trial ID for the History Quick Provider new scoring experiment group. |
| 50 int hqp_new_scoring_experiment_group = 0; |
| 51 |
| 42 } | 52 } |
| 43 | 53 |
| 44 | 54 |
| 45 void AutocompleteFieldTrial::Activate() { | 55 void AutocompleteFieldTrial::Activate() { |
| 46 // Because users tend to use omnibox without attention to it--habits | 56 // Because users tend to use omnibox without attention to it--habits |
| 47 // get ingrained, users tend to learn that a particular suggestion is | 57 // get ingrained, users tend to learn that a particular suggestion is |
| 48 // at a particular spot in the drop-down--we're going to make these | 58 // at a particular spot in the drop-down--we're going to make these |
| 49 // field trials sticky. We want users to stay in them once assigned | 59 // field trials sticky. We want users to stay in them once assigned |
| 50 // so they have a better experience and also so we don't get weird | 60 // so they have a better experience and also so we don't get weird |
| 51 // effects as omnibox ranking keeps changing and users learn they can't | 61 // effects as omnibox ranking keeps changing and users learn they can't |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // kSuggestFieldTrialNumGroups - 1 more. Mark these groups in | 93 // kSuggestFieldTrialNumGroups - 1 more. Mark these groups in |
| 84 // suggest requests to Google. | 94 // suggest requests to Google. |
| 85 for (int i = 1; i < kSuggestFieldTrialNumberOfGroups; i++) { | 95 for (int i = 1; i < kSuggestFieldTrialNumberOfGroups; i++) { |
| 86 const std::string group_name = base::IntToString(i); | 96 const std::string group_name = base::IntToString(i); |
| 87 trial->AppendGroup(group_name, 1); | 97 trial->AppendGroup(group_name, 1); |
| 88 experiments_helper::AssociateGoogleVariationID( | 98 experiments_helper::AssociateGoogleVariationID( |
| 89 kSuggestFieldTrialName, group_name, | 99 kSuggestFieldTrialName, group_name, |
| 90 static_cast<chrome_variations::ID>( | 100 static_cast<chrome_variations::ID>( |
| 91 chrome_variations::kSuggestIDMin + i)); | 101 chrome_variations::kSuggestIDMin + i)); |
| 92 } | 102 } |
| 103 |
| 104 // Create inline History Quick Provider new scoring field trial. |
| 105 // Make it expire on January 14, 2013. |
| 106 trial = base::FieldTrialList::FactoryGetFieldTrial( |
| 107 kHQPNewScoringFieldTrialName, kHQPNewScoringFieldTrialDivisor, |
| 108 "Standard", 2013, 1, 14, NULL); |
| 109 if (base::FieldTrialList::IsOneTimeRandomizationEnabled()) |
| 110 trial->UseOneTimeRandomization(); |
| 111 hqp_new_scoring_experiment_group = trial->AppendGroup("NewScoring", |
| 112 kHQPNewScoringFieldTrialExperimentFraction); |
| 93 } | 113 } |
| 94 | 114 |
| 95 bool AutocompleteFieldTrial::InDisallowInlineHQPFieldTrial() { | 115 bool AutocompleteFieldTrial::InDisallowInlineHQPFieldTrial() { |
| 96 return base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName); | 116 return base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName); |
| 97 } | 117 } |
| 98 | 118 |
| 99 bool AutocompleteFieldTrial::InDisallowInlineHQPFieldTrialExperimentGroup() { | 119 bool AutocompleteFieldTrial::InDisallowInlineHQPFieldTrialExperimentGroup() { |
| 100 if (!base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName)) | 120 if (!base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName)) |
| 101 return false; | 121 return false; |
| 102 | 122 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 123 // get numbers that we know are 0, 1, 2, ... | 143 // get numbers that we know are 0, 1, 2, ... |
| 124 int AutocompleteFieldTrial::GetSuggestGroupNameAsNumber() { | 144 int AutocompleteFieldTrial::GetSuggestGroupNameAsNumber() { |
| 125 int group_num; | 145 int group_num; |
| 126 base::StringToInt(GetSuggestGroupName(), &group_num); | 146 base::StringToInt(GetSuggestGroupName(), &group_num); |
| 127 return group_num; | 147 return group_num; |
| 128 } | 148 } |
| 129 | 149 |
| 130 int AutocompleteFieldTrial::GetSuggestNumberOfGroups() { | 150 int AutocompleteFieldTrial::GetSuggestNumberOfGroups() { |
| 131 return kSuggestFieldTrialNumberOfGroups; | 151 return kSuggestFieldTrialNumberOfGroups; |
| 132 } | 152 } |
| 153 |
| 154 bool AutocompleteFieldTrial::InHQPNewScoringFieldTrial() { |
| 155 return base::FieldTrialList::TrialExists(kHQPNewScoringFieldTrialName); |
| 156 } |
| 157 |
| 158 bool AutocompleteFieldTrial::InHQPNewScoringFieldTrialExperimentGroup() { |
| 159 if (!InHQPNewScoringFieldTrial()) |
| 160 return false; |
| 161 |
| 162 // Return true if we're in the experiment group. |
| 163 const int group = base::FieldTrialList::FindValue( |
| 164 kHQPNewScoringFieldTrialName); |
| 165 return group == hqp_new_scoring_experiment_group; |
| 166 } |
| OLD | NEW |