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

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

Issue 11522009: X-Chrome-Variations logic refactoring (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Merged with head. Created 8 years 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"
11 #include "chrome/common/metrics/metrics_util.h" 11 #include "chrome/common/metrics/metrics_util.h"
12 #include "chrome/common/metrics/variations/variation_ids.h" 12 #include "chrome/common/metrics/variations/variation_ids.h"
13 #include "chrome/common/metrics/variations/variations_util.h" 13 #include "chrome/common/metrics/variations/variations_util.h"
14 14
15 namespace { 15 namespace {
16 16
17 // Field trial names. 17 // Field trial names.
18 static const char kDisallowInlineHQPFieldTrialName[] = 18 static const char kDisallowInlineHQPFieldTrialName[] =
19 "OmniboxDisallowInlineHQP"; 19 "OmniboxDisallowInlineHQP";
20 // Because we regularly change the name of the suggest field trial in 20 // Because we regularly change the name of the suggest field trial in
21 // order to shuffle users among groups, we use the date the current trial 21 // order to shuffle users among groups, we use the date the current trial
22 // was created as part of the name. 22 // was created as part of the name.
23 static const char kSuggestFieldTrialStarted2012Q4Name[] = 23 static const char kSuggestFieldTrialStarted2013Q1Name[] =
24 "OmniboxSearchSuggestTrialStarted2012Q4"; 24 "OmniboxSearchSuggestTrialStarted2013Q1";
25 static const char kHQPNewScoringFieldTrialName[] = 25 static const char kHQPNewScoringFieldTrialName[] =
26 "OmniboxHQPNewScoringMax1400"; 26 "OmniboxHQPNewScoringMax1400";
27 static const char kHUPCullRedirectsFieldTrialName[] = "OmniboxHUPCullRedirects"; 27 static const char kHUPCullRedirectsFieldTrialName[] = "OmniboxHUPCullRedirects";
28 static const char kHUPCreateShorterMatchFieldTrialName[] = 28 static const char kHUPCreateShorterMatchFieldTrialName[] =
29 "OmniboxHUPCreateShorterMatch"; 29 "OmniboxHUPCreateShorterMatch";
30 static const char kHQPReplaceHUPScoringFieldTrialName[] = 30 static const char kHQPReplaceHUPScoringFieldTrialName[] =
31 "OmniboxHQPReplaceHUPRearrangeNumComponents"; 31 "OmniboxHQPReplaceHUPRearrangeNumComponents";
32 static const char kHQPOnlyCountMatchesAtWordBoundariesFieldTrialName[] = 32 static const char kHQPOnlyCountMatchesAtWordBoundariesFieldTrialName[] =
33 "OmniboxHQPOnlyCountMatchesAtWordBoundaries"; 33 "OmniboxHQPOnlyCountMatchesAtWordBoundaries";
34 34
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // at a particular spot in the drop-down--we're going to make these 127 // at a particular spot in the drop-down--we're going to make these
128 // field trials sticky. We want users to stay in them once assigned 128 // field trials sticky. We want users to stay in them once assigned
129 // so they have a better experience and also so we don't get weird 129 // so they have a better experience and also so we don't get weird
130 // effects as omnibox ranking keeps changing and users learn they can't 130 // effects as omnibox ranking keeps changing and users learn they can't
131 // trust the omnibox. 131 // trust the omnibox.
132 trial->UseOneTimeRandomization(); 132 trial->UseOneTimeRandomization();
133 disallow_inline_hqp_experiment_group = trial->AppendGroup("DisallowInline", 133 disallow_inline_hqp_experiment_group = trial->AppendGroup("DisallowInline",
134 kDisallowInlineHQPFieldTrialExperimentFraction); 134 kDisallowInlineHQPFieldTrialExperimentFraction);
135 135
136 // Create the suggest field trial. 136 // Create the suggest field trial.
137 // Make it expire on July 1, 2013. 137 // Make it expire on September 1, 2013.
138 trial = base::FieldTrialList::FactoryGetFieldTrial( 138 trial = base::FieldTrialList::FactoryGetFieldTrial(
139 kSuggestFieldTrialStarted2012Q4Name, kSuggestFieldTrialNumberOfGroups, 139 kSuggestFieldTrialStarted2013Q1Name, kSuggestFieldTrialNumberOfGroups,
140 "0", 2013, 7, 1, NULL); 140 "0", 2013, 9, 1, NULL);
141 trial->UseOneTimeRandomization(); 141 trial->UseOneTimeRandomization();
142 142
143 // Mark this group in suggest requests to Google. 143 // Mark this group in suggest requests to Google.
144 chrome_variations::AssociateGoogleVariationID( 144 chrome_variations::AssociateGoogleVariationID(
145 chrome_variations::GOOGLE_WEB_PROPERTIES, 145 chrome_variations::GOOGLE_WEB_PROPERTIES,
146 kSuggestFieldTrialStarted2012Q4Name, "0", 146 kSuggestFieldTrialStarted2013Q1Name, "0",
147 chrome_variations::kSuggestTrialStarted2012Q4IDMin); 147 chrome_variations::kSuggestTrialStarted2013Q1IDMin);
148 DCHECK_EQ(kSuggestFieldTrialNumberOfGroups, 148 DCHECK_EQ(kSuggestFieldTrialNumberOfGroups,
149 chrome_variations::kSuggestTrialStarted2012Q4IDMax - 149 chrome_variations::kSuggestTrialStarted2013Q1IDMax -
150 chrome_variations::kSuggestTrialStarted2012Q4IDMin + 1); 150 chrome_variations::kSuggestTrialStarted2013Q1IDMin + 1);
151 151
152 // We've already created one group; now just need to create 152 // We've already created one group; now just need to create
153 // kSuggestFieldTrialNumGroups - 1 more. Mark these groups in 153 // kSuggestFieldTrialNumGroups - 1 more. Mark these groups in
154 // suggest requests to Google. 154 // suggest requests to Google.
155 for (int i = 1; i < kSuggestFieldTrialNumberOfGroups; i++) { 155 for (int i = 1; i < kSuggestFieldTrialNumberOfGroups; i++) {
156 const std::string group_name = base::IntToString(i); 156 const std::string group_name = base::IntToString(i);
157 trial->AppendGroup(group_name, 1); 157 trial->AppendGroup(group_name, 1);
158 chrome_variations::AssociateGoogleVariationID( 158 chrome_variations::AssociateGoogleVariationID(
159 chrome_variations::GOOGLE_WEB_PROPERTIES, 159 chrome_variations::GOOGLE_WEB_PROPERTIES,
160 kSuggestFieldTrialStarted2012Q4Name, group_name, 160 kSuggestFieldTrialStarted2013Q1Name, group_name,
161 static_cast<chrome_variations::VariationID>( 161 static_cast<chrome_variations::VariationID>(
162 chrome_variations::kSuggestTrialStarted2012Q4IDMin + i)); 162 chrome_variations::kSuggestTrialStarted2013Q1IDMin + i));
163 } 163 }
164 164
165 // Make sure that we participate in the suggest experiment by calling group() 165 // Make sure that we participate in the suggest experiment by calling group()
166 // on the newly created field trial. This is necessary to activate the field 166 // on the newly created field trial. This is necessary to activate the field
167 // trial group as there are no more references to it within the Chrome code. 167 // trial group as there are no more references to it within the Chrome code.
168 trial->group(); 168 trial->group();
169 169
170 // Create inline History Quick Provider new scoring field trial. 170 // Create inline History Quick Provider new scoring field trial.
171 // Make it expire on April 14, 2013. 171 // Make it expire on April 14, 2013.
172 trial = base::FieldTrialList::FactoryGetFieldTrial( 172 trial = base::FieldTrialList::FactoryGetFieldTrial(
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 return false; 229 return false;
230 230
231 // Return true if we're in the experiment group. 231 // Return true if we're in the experiment group.
232 const int group = base::FieldTrialList::FindValue( 232 const int group = base::FieldTrialList::FindValue(
233 kDisallowInlineHQPFieldTrialName); 233 kDisallowInlineHQPFieldTrialName);
234 return group == disallow_inline_hqp_experiment_group; 234 return group == disallow_inline_hqp_experiment_group;
235 } 235 }
236 236
237 bool AutocompleteFieldTrial::GetActiveSuggestFieldTrialHash( 237 bool AutocompleteFieldTrial::GetActiveSuggestFieldTrialHash(
238 uint32* field_trial_hash) { 238 uint32* field_trial_hash) {
239 if (!base::FieldTrialList::TrialExists(kSuggestFieldTrialStarted2012Q4Name)) 239 if (!base::FieldTrialList::TrialExists(kSuggestFieldTrialStarted2013Q1Name))
240 return false; 240 return false;
241 241
242 *field_trial_hash = metrics::HashName(kSuggestFieldTrialStarted2012Q4Name); 242 *field_trial_hash = metrics::HashName(kSuggestFieldTrialStarted2013Q1Name);
243 return true; 243 return true;
244 } 244 }
245 245
246 bool AutocompleteFieldTrial::InHQPNewScoringFieldTrial() { 246 bool AutocompleteFieldTrial::InHQPNewScoringFieldTrial() {
247 return base::FieldTrialList::TrialExists(kHQPNewScoringFieldTrialName); 247 return base::FieldTrialList::TrialExists(kHQPNewScoringFieldTrialName);
248 } 248 }
249 249
250 bool AutocompleteFieldTrial::InHQPNewScoringFieldTrialExperimentGroup() { 250 bool AutocompleteFieldTrial::InHQPNewScoringFieldTrialExperimentGroup() {
251 if (!InHQPNewScoringFieldTrial()) 251 if (!InHQPNewScoringFieldTrial())
252 return false; 252 return false;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 bool AutocompleteFieldTrial:: 309 bool AutocompleteFieldTrial::
310 InHQPOnlyCountMatchesAtWordBoundariesFieldTrialExperimentGroup() { 310 InHQPOnlyCountMatchesAtWordBoundariesFieldTrialExperimentGroup() {
311 if (!InHQPOnlyCountMatchesAtWordBoundariesFieldTrial()) 311 if (!InHQPOnlyCountMatchesAtWordBoundariesFieldTrial())
312 return false; 312 return false;
313 313
314 // Return true if we're in the experiment group. 314 // Return true if we're in the experiment group.
315 const int group = base::FieldTrialList::FindValue( 315 const int group = base::FieldTrialList::FindValue(
316 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialName); 316 kHQPOnlyCountMatchesAtWordBoundariesFieldTrialName);
317 return group == hqp_only_count_matches_at_word_boundaries_experiment_group; 317 return group == hqp_only_count_matches_at_word_boundaries_experiment_group;
318 } 318 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autocomplete/search_provider.cc » ('j') | chrome/browser/chrome_metrics_helper.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698