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

Side by Side Diff: chrome/browser/omnibox/omnibox_field_trial.cc

Issue 22354006: Omnibox: Convert Shortcuts Scoring Field Trial to Omnibox Bundled Field Trial (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months 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/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/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "chrome/browser/autocomplete/autocomplete_input.h"
Mark P 2013/08/09 23:27:15 This change doesn't need it, but this should've be
14 #include "chrome/common/metrics/metrics_util.h" 15 #include "chrome/common/metrics/metrics_util.h"
15 #include "chrome/common/metrics/variations/variation_ids.h" 16 #include "chrome/common/metrics/variations/variation_ids.h"
16 #include "chrome/common/metrics/variations/variations_util.h" 17 #include "chrome/common/metrics/variations/variations_util.h"
17 18
18 namespace { 19 namespace {
19 20
20 // Field trial names. 21 // Field trial names.
21 const char kHUPCullRedirectsFieldTrialName[] = "OmniboxHUPCullRedirects"; 22 const char kHUPCullRedirectsFieldTrialName[] = "OmniboxHUPCullRedirects";
22 const char kHUPCreateShorterMatchFieldTrialName[] = 23 const char kHUPCreateShorterMatchFieldTrialName[] =
23 "OmniboxHUPCreateShorterMatch"; 24 "OmniboxHUPCreateShorterMatch";
24 const char kStopTimerFieldTrialName[] = "OmniboxStopTimer"; 25 const char kStopTimerFieldTrialName[] = "OmniboxStopTimer";
25 const char kShortcutsScoringFieldTrialName[] = "OmniboxShortcutsScoring";
26 const char kBundledExperimentFieldTrialName[] = "OmniboxBundledExperimentV1"; 26 const char kBundledExperimentFieldTrialName[] = "OmniboxBundledExperimentV1";
27 27
28 // Rule names used by the bundled experiment. 28 // Rule names used by the bundled experiment.
29 const char kShortcutsScoringMaxRelevanceRule[] = "ShortcutsScoringMaxRelevance";
29 const char kSearchHistoryRule[] = "SearchHistory"; 30 const char kSearchHistoryRule[] = "SearchHistory";
30 const char kDemoteByTypeRule[] = "DemoteByType"; 31 const char kDemoteByTypeRule[] = "DemoteByType";
31 32
32 // The autocomplete dynamic field trial name prefix. Each field trial is 33 // The autocomplete dynamic field trial name prefix. Each field trial is
33 // configured dynamically and is retrieved automatically by Chrome during 34 // configured dynamically and is retrieved automatically by Chrome during
34 // the startup. 35 // the startup.
35 const char kAutocompleteDynamicFieldTrialPrefix[] = "AutocompleteDynamicTrial_"; 36 const char kAutocompleteDynamicFieldTrialPrefix[] = "AutocompleteDynamicTrial_";
36 // The maximum number of the autocomplete dynamic field trials (aka layers). 37 // The maximum number of the autocomplete dynamic field trials (aka layers).
37 const int kMaxAutocompleteDynamicFieldTrials = 5; 38 const int kMaxAutocompleteDynamicFieldTrials = 5;
38 39
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 for (int i = 0; i < kMaxAutocompleteDynamicFieldTrials; ++i) { 200 for (int i = 0; i < kMaxAutocompleteDynamicFieldTrials; ++i) {
200 const std::string& group_name = base::FieldTrialList::FindFullName( 201 const std::string& group_name = base::FieldTrialList::FindFullName(
201 DynamicFieldTrialName(i)); 202 DynamicFieldTrialName(i));
202 const char kEnableZeroSuggest[] = "EnableZeroSuggest"; 203 const char kEnableZeroSuggest[] = "EnableZeroSuggest";
203 if (StartsWithASCII(group_name, kEnableZeroSuggest, true)) 204 if (StartsWithASCII(group_name, kEnableZeroSuggest, true))
204 return true; 205 return true;
205 } 206 }
206 return false; 207 return false;
207 } 208 }
208 209
209 // If the active group name starts with "MaxRelevance_", extract the 210 bool OmniboxFieldTrial::ShortcutsScoringMaxRelevance(
210 // int that immediately following that, returning true on success. 211 AutocompleteInput::PageClassification current_page_classification,
211 bool OmniboxFieldTrial::ShortcutsScoringMaxRelevance(int* max_relevance) { 212 int* max_relevance) {
212 std::string group_name = 213 // The value of the rule is an integer displayed as a string that
Peter Kasting 2013/08/09 23:33:15 Nit: "...is a string that encodes an integer conta
Mark P 2013/08/10 00:11:56 Okay. That's less backwards than my sentence. Do
213 base::FieldTrialList::FindFullName(kShortcutsScoringFieldTrialName); 214 // contains the max relevance.
214 const char kMaxRelevanceGroupPrefix[] = "MaxRelevance_"; 215 const std::string& max_relevance_str =
215 if (!StartsWithASCII(group_name, kMaxRelevanceGroupPrefix, true)) 216 OmniboxFieldTrial::GetValueForRuleInContext(
217 kShortcutsScoringMaxRelevanceRule, current_page_classification);
218 if (max_relevance_str.empty())
216 return false; 219 return false;
217 if (!base::StringToInt(base::StringPiece( 220 if (!base::StringToInt(max_relevance_str, max_relevance)) {
218 group_name.substr(strlen(kMaxRelevanceGroupPrefix))), 221 LOG(WARNING) << "Malformed MaxRelevance string: " << max_relevance_str;
Peter Kasting 2013/08/09 23:33:15 While here, consider removing this LOG unless you
Mark P 2013/08/10 00:11:56 Good point. This warning is not useful. Removed.
219 max_relevance)) {
220 LOG(WARNING) << "Malformed MaxRelevance string: " << group_name;
221 return false; 222 return false;
222 } 223 }
223 return true; 224 return true;
224 } 225 }
225 226
226 bool OmniboxFieldTrial::SearchHistoryPreventInlining( 227 bool OmniboxFieldTrial::SearchHistoryPreventInlining(
227 AutocompleteInput::PageClassification current_page_classification) { 228 AutocompleteInput::PageClassification current_page_classification) {
228 return OmniboxFieldTrial::GetValueForRuleInContext( 229 return OmniboxFieldTrial::GetValueForRuleInContext(
229 kSearchHistoryRule, current_page_classification) == "PreventInlining"; 230 kSearchHistoryRule, current_page_classification) == "PreventInlining";
230 } 231 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // Look up rule in this exact context. 296 // Look up rule in this exact context.
296 std::map<std::string, std::string>::iterator it = 297 std::map<std::string, std::string>::iterator it =
297 params.find(rule + ":" + base::IntToString( 298 params.find(rule + ":" + base::IntToString(
298 static_cast<int>(page_classification))); 299 static_cast<int>(page_classification)));
299 if (it != params.end()) 300 if (it != params.end())
300 return it->second; 301 return it->second;
301 // Look up rule in the global context. 302 // Look up rule in the global context.
302 it = params.find(rule + ":*"); 303 it = params.find(rule + ":*");
303 return (it != params.end()) ? it->second : std::string(); 304 return (it != params.end()) ? it->second : std::string();
304 } 305 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698