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

Side by Side Diff: chrome/browser/prerender/prerender_field_trial.cc

Issue 8600004: Adding a fourth omnibox prerender experiment. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/prerender/prerender_field_trial.h" 5 #include "chrome/browser/prerender/prerender_field_trial.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "chrome/browser/metrics/metrics_service.h" 11 #include "chrome/browser/metrics/metrics_service.h"
12 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/browser/prerender/prerender_manager.h" 13 #include "chrome/browser/prerender/prerender_manager.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/chrome_version_info.h" 16 #include "chrome/common/chrome_version_info.h"
17 #include "content/browser/renderer_host/resource_dispatcher_host.h" 17 #include "content/browser/renderer_host/resource_dispatcher_host.h"
18 18
19 namespace prerender { 19 namespace prerender {
20 20
21 namespace { 21 namespace {
22 22
23 int omnibox_original_group_id = 0; 23 int omnibox_original_group_id = 0;
24 int omnibox_conservative_group_id = 0; 24 int omnibox_conservative_group_id = 0;
25 int omnibox_exact_group_id = 0; 25 int omnibox_exact_group_id = 0;
26 int omnibox_exact_full_group_id = 0;
26 27
27 const char* kOmniboxHeuristicNames[] = { 28 const char* kOmniboxHeuristicNames[] = {
28 "Original", 29 "Original",
29 "Conservative", 30 "Conservative",
30 "Exact" 31 "Exact",
32 "Exact_Full"
31 }; 33 };
32 COMPILE_ASSERT(arraysize(kOmniboxHeuristicNames) == OMNIBOX_HEURISTIC_MAX, 34 COMPILE_ASSERT(arraysize(kOmniboxHeuristicNames) == OMNIBOX_HEURISTIC_MAX,
33 OmniboxHeuristic_name_count_mismatch); 35 OmniboxHeuristic_name_count_mismatch);
34 36
35 const char* NameFromOmniboxHeuristic(OmniboxHeuristic heuristic) { 37 const char* NameFromOmniboxHeuristic(OmniboxHeuristic heuristic) {
36 DCHECK_LT(static_cast<unsigned int>(heuristic), 38 DCHECK_LT(static_cast<unsigned int>(heuristic),
37 arraysize(kOmniboxHeuristicNames)); 39 arraysize(kOmniboxHeuristicNames));
38 return kOmniboxHeuristicNames[heuristic]; 40 return kOmniboxHeuristicNames[heuristic];
39 } 41 }
40 42
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // Field trial to see if we're enabled. 167 // Field trial to see if we're enabled.
166 const base::FieldTrial::Probability kDivisor = 100; 168 const base::FieldTrial::Probability kDivisor = 100;
167 169
168 const base::FieldTrial::Probability kEnabledProbability = 40; 170 const base::FieldTrial::Probability kEnabledProbability = 40;
169 scoped_refptr<base::FieldTrial> enabled_trial( 171 scoped_refptr<base::FieldTrial> enabled_trial(
170 new base::FieldTrial("PrerenderFromOmnibox", kDivisor, 172 new base::FieldTrial("PrerenderFromOmnibox", kDivisor,
171 "OmniboxPrerenderDisabled", 2012, 8, 30)); 173 "OmniboxPrerenderDisabled", 2012, 8, 30));
172 enabled_trial->AppendGroup("OmniboxPrerenderEnabled", kEnabledProbability); 174 enabled_trial->AppendGroup("OmniboxPrerenderEnabled", kEnabledProbability);
173 175
174 // Field trial to see which heuristic to use. 176 // Field trial to see which heuristic to use.
175 const base::FieldTrial::Probability kConservativeProbability = 33; 177 const base::FieldTrial::Probability kConservativeProbability = 25;
176 const base::FieldTrial::Probability kExactProbability = 33; 178 const base::FieldTrial::Probability kExactProbability = 25;
179 const base::FieldTrial::Probability kExactFullProbability = 25;
177 scoped_refptr<base::FieldTrial> heuristic_trial( 180 scoped_refptr<base::FieldTrial> heuristic_trial(
178 new base::FieldTrial("PrerenderFromOmniboxHeuristic", kDivisor, 181 new base::FieldTrial("PrerenderFromOmniboxHeuristic", kDivisor,
179 "OriginalAlgorithm", 2012, 8, 30)); 182 "OriginalAlgorithm", 2012, 8, 30));
180 omnibox_original_group_id = base::FieldTrial::kDefaultGroupNumber; 183 omnibox_original_group_id = base::FieldTrial::kDefaultGroupNumber;
181 omnibox_conservative_group_id = 184 omnibox_conservative_group_id =
182 heuristic_trial->AppendGroup("ConservativeAlgorithm", 185 heuristic_trial->AppendGroup("ConservativeAlgorithm",
183 kConservativeProbability); 186 kConservativeProbability);
184 omnibox_exact_group_id = 187 omnibox_exact_group_id =
185 heuristic_trial->AppendGroup("ExactAlgorithm", kExactProbability); 188 heuristic_trial->AppendGroup("ExactAlgorithm", kExactProbability);
189 omnibox_exact_full_group_id =
190 heuristic_trial->AppendGroup("ExactFullAlgorithm", kExactFullProbability);
186 } 191 }
187 192
188 bool IsOmniboxEnabled(Profile* profile) { 193 bool IsOmniboxEnabled(Profile* profile) {
189 if (!profile || profile->IsOffTheRecord()) 194 if (!profile || profile->IsOffTheRecord())
190 return false; 195 return false;
191 196
192 if (!PrerenderManager::IsPrerenderingPossible()) 197 if (!PrerenderManager::IsPrerenderingPossible())
193 return false; 198 return false;
194 199
195 // Override any field trial groups if the user has set a command line flag. 200 // Override any field trial groups if the user has set a command line flag.
(...skipping 15 matching lines...) Expand all
211 if (!MetricsServiceHelper::IsMetricsReportingEnabled()) 216 if (!MetricsServiceHelper::IsMetricsReportingEnabled())
212 return false; 217 return false;
213 218
214 const int group = base::FieldTrialList::FindValue("PrerenderFromOmnibox"); 219 const int group = base::FieldTrialList::FindValue("PrerenderFromOmnibox");
215 return group != base::FieldTrial::kNotFinalized && 220 return group != base::FieldTrial::kNotFinalized &&
216 group != base::FieldTrial::kDefaultGroupNumber; 221 group != base::FieldTrial::kDefaultGroupNumber;
217 } 222 }
218 223
219 OmniboxHeuristic GetOmniboxHeuristicToUse() { 224 OmniboxHeuristic GetOmniboxHeuristicToUse() {
220 const int group = 225 const int group =
221 base::FieldTrialList::FindValue("PrerenderFromOmniboxHeuristic"); 226 base::FieldTrialList::FindValue("PrerenderFromOmniboxHeuristic");
cbentzel 2011/11/18 21:24:06 This and "PrerenderFromOmnibox" should probably mo
dominich 2011/11/18 23:05:51 Done.
222 if (group == omnibox_original_group_id) 227 if (group == omnibox_original_group_id)
223 return OMNIBOX_HEURISTIC_ORIGINAL; 228 return OMNIBOX_HEURISTIC_ORIGINAL;
224 if (group == omnibox_conservative_group_id) 229 if (group == omnibox_conservative_group_id)
225 return OMNIBOX_HEURISTIC_CONSERVATIVE; 230 return OMNIBOX_HEURISTIC_CONSERVATIVE;
226 if (group == omnibox_exact_group_id) 231 if (group == omnibox_exact_group_id)
227 return OMNIBOX_HEURISTIC_EXACT; 232 return OMNIBOX_HEURISTIC_EXACT;
233 if (group == omnibox_exact_full_group_id)
234 return OMNIBOX_HEURISTIC_EXACT_FULL;
228 235
229 // If we don't have a group just return the original heuristic. 236 // If we don't have a group just return the original heuristic.
230 return OMNIBOX_HEURISTIC_ORIGINAL; 237 return OMNIBOX_HEURISTIC_ORIGINAL;
231 } 238 }
232 239
233 std::string GetOmniboxHistogramSuffix() { 240 std::string GetOmniboxHistogramSuffix() {
234 return NameFromOmniboxHeuristic(prerender::GetOmniboxHeuristicToUse()); 241 return NameFromOmniboxHeuristic(prerender::GetOmniboxHeuristicToUse());
235 } 242 }
236 243
237 } // namespace prerender 244 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698