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 kSuggestFieldTrialStarted2013Q1Name[] = |
23 "OmniboxSearchSuggestTrialStarted2012Q4"; | 23 "OmniboxSearchSuggestTrialStarted2013Q1"; |
24 static const char kHQPNewScoringFieldTrialName[] = | 24 static const char kHQPNewScoringFieldTrialName[] = |
25 "OmniboxHQPNewScoringMax1400"; | 25 "OmniboxHQPNewScoringMax1400"; |
26 static const char kHUPCullRedirectsFieldTrialName[] = "OmniboxHUPCullRedirects"; | 26 static const char kHUPCullRedirectsFieldTrialName[] = "OmniboxHUPCullRedirects"; |
27 static const char kHUPCreateShorterMatchFieldTrialName[] = | 27 static const char kHUPCreateShorterMatchFieldTrialName[] = |
28 "OmniboxHUPCreateShorterMatch"; | 28 "OmniboxHUPCreateShorterMatch"; |
29 static const char kHQPReplaceHUPScoringFieldTrialName[] = | 29 static const char kHQPReplaceHUPScoringFieldTrialName[] = |
30 "OmniboxHQPReplaceHUPRearrangeNumComponents"; | 30 "OmniboxHQPReplaceHUPRearrangeNumComponents"; |
31 static const char kHQPOnlyCountMatchesAtWordBoundariesFieldTrialName[] = | 31 static const char kHQPOnlyCountMatchesAtWordBoundariesFieldTrialName[] = |
32 "OmniboxHQPOnlyCountMatchesAtWordBoundaries"; | 32 "OmniboxHQPOnlyCountMatchesAtWordBoundaries"; |
33 | 33 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // at a particular spot in the drop-down--we're going to make these | 126 // at a particular spot in the drop-down--we're going to make these |
127 // field trials sticky. We want users to stay in them once assigned | 127 // field trials sticky. We want users to stay in them once assigned |
128 // so they have a better experience and also so we don't get weird | 128 // so they have a better experience and also so we don't get weird |
129 // effects as omnibox ranking keeps changing and users learn they can't | 129 // effects as omnibox ranking keeps changing and users learn they can't |
130 // trust the omnibox. | 130 // trust the omnibox. |
131 trial->UseOneTimeRandomization(); | 131 trial->UseOneTimeRandomization(); |
132 disallow_inline_hqp_experiment_group = trial->AppendGroup("DisallowInline", | 132 disallow_inline_hqp_experiment_group = trial->AppendGroup("DisallowInline", |
133 kDisallowInlineHQPFieldTrialExperimentFraction); | 133 kDisallowInlineHQPFieldTrialExperimentFraction); |
134 | 134 |
135 // Create the suggest field trial. | 135 // Create the suggest field trial. |
136 // Make it expire on July 1, 2013. | 136 // Make it expire on September 1, 2013. |
137 trial = base::FieldTrialList::FactoryGetFieldTrial( | 137 trial = base::FieldTrialList::FactoryGetFieldTrial( |
138 kSuggestFieldTrialStarted2012Q4Name, kSuggestFieldTrialNumberOfGroups, | 138 kSuggestFieldTrialStarted2013Q1Name, kSuggestFieldTrialNumberOfGroups, |
139 "0", 2013, 7, 1, NULL); | 139 "0", 2013, 9, 1, NULL); |
140 trial->UseOneTimeRandomization(); | 140 trial->UseOneTimeRandomization(); |
141 | 141 |
142 // Mark this group in suggest requests to Google. | 142 // Mark this group in suggest requests to Google. |
143 chrome_variations::AssociateGoogleVariationID( | 143 chrome_variations::AssociateGoogleVariationID( |
144 chrome_variations::GOOGLE_WEB_PROPERTIES, | 144 chrome_variations::GOOGLE_WEB_PROPERTIES, |
145 kSuggestFieldTrialStarted2012Q4Name, "0", | 145 kSuggestFieldTrialStarted2013Q1Name, "0", |
146 chrome_variations::kSuggestTrialStarted2012Q4IDMin); | 146 chrome_variations::kSuggestTrialStarted2013Q1IDMin); |
147 DCHECK_EQ(kSuggestFieldTrialNumberOfGroups, | 147 DCHECK_EQ(kSuggestFieldTrialNumberOfGroups, |
148 chrome_variations::kSuggestTrialStarted2012Q4IDMax - | 148 chrome_variations::kSuggestTrialStarted2013Q1IDMax - |
149 chrome_variations::kSuggestTrialStarted2012Q4IDMin + 1); | 149 chrome_variations::kSuggestTrialStarted2013Q1IDMin + 1); |
150 | 150 |
151 // We've already created one group; now just need to create | 151 // We've already created one group; now just need to create |
152 // kSuggestFieldTrialNumGroups - 1 more. Mark these groups in | 152 // kSuggestFieldTrialNumGroups - 1 more. Mark these groups in |
153 // suggest requests to Google. | 153 // suggest requests to Google. |
154 for (int i = 1; i < kSuggestFieldTrialNumberOfGroups; i++) { | 154 for (int i = 1; i < kSuggestFieldTrialNumberOfGroups; i++) { |
155 const std::string group_name = base::IntToString(i); | 155 const std::string group_name = base::IntToString(i); |
156 trial->AppendGroup(group_name, 1); | 156 trial->AppendGroup(group_name, 1); |
157 chrome_variations::AssociateGoogleVariationID( | 157 chrome_variations::AssociateGoogleVariationID( |
158 chrome_variations::GOOGLE_WEB_PROPERTIES, | 158 chrome_variations::GOOGLE_WEB_PROPERTIES, |
159 kSuggestFieldTrialStarted2012Q4Name, group_name, | 159 kSuggestFieldTrialStarted2013Q1Name, group_name, |
160 static_cast<chrome_variations::VariationID>( | 160 static_cast<chrome_variations::VariationID>( |
161 chrome_variations::kSuggestTrialStarted2012Q4IDMin + i)); | 161 chrome_variations::kSuggestTrialStarted2013Q1IDMin + i)); |
162 } | 162 } |
163 | 163 |
164 // Make sure that we participate in the suggest experiment by calling group() | 164 // Make sure that we participate in the suggest experiment by calling group() |
165 // on the newly created field trial. This is necessary to activate the field | 165 // on the newly created field trial. This is necessary to activate the field |
166 // trial group as there are no more references to it within the Chrome code. | 166 // trial group as there are no more references to it within the Chrome code. |
167 trial->group(); | 167 trial->group(); |
168 | 168 |
169 // Create inline History Quick Provider new scoring field trial. | 169 // Create inline History Quick Provider new scoring field trial. |
170 // Make it expire on April 14, 2013. | 170 // Make it expire on April 14, 2013. |
171 trial = base::FieldTrialList::FactoryGetFieldTrial( | 171 trial = base::FieldTrialList::FactoryGetFieldTrial( |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 bool AutocompleteFieldTrial:: | 299 bool AutocompleteFieldTrial:: |
300 InHQPOnlyCountMatchesAtWordBoundariesFieldTrialExperimentGroup() { | 300 InHQPOnlyCountMatchesAtWordBoundariesFieldTrialExperimentGroup() { |
301 if (!InHQPOnlyCountMatchesAtWordBoundariesFieldTrial()) | 301 if (!InHQPOnlyCountMatchesAtWordBoundariesFieldTrial()) |
302 return false; | 302 return false; |
303 | 303 |
304 // Return true if we're in the experiment group. | 304 // Return true if we're in the experiment group. |
305 const int group = base::FieldTrialList::FindValue( | 305 const int group = base::FieldTrialList::FindValue( |
306 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialName); | 306 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialName); |
307 return group == hqp_only_count_matches_at_word_boundaries_experiment_group; | 307 return group == hqp_only_count_matches_at_word_boundaries_experiment_group; |
308 } | 308 } |
OLD | NEW |