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

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: fix clang 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
37 const char kPrerenderFromOmniboxTrialName[] = "PrerenderFromOmnibox";
38 const char kPrerenderFromOmniboxHeuristicTrialName[] =
39 "PrerenderFromOmniboxHeuristic";
40
35 const char* NameFromOmniboxHeuristic(OmniboxHeuristic heuristic) { 41 const char* NameFromOmniboxHeuristic(OmniboxHeuristic heuristic) {
36 DCHECK_LT(static_cast<unsigned int>(heuristic), 42 DCHECK_LT(static_cast<unsigned int>(heuristic),
37 arraysize(kOmniboxHeuristicNames)); 43 arraysize(kOmniboxHeuristicNames));
38 return kOmniboxHeuristicNames[heuristic]; 44 return kOmniboxHeuristicNames[heuristic];
39 } 45 }
40 46
41 } // end namespace 47 } // end namespace
42 48
43 void ConfigurePrerenderFromOmnibox(); 49 void ConfigurePrerenderFromOmnibox();
44 50
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 166
161 ConfigurePrerenderFromOmnibox(); 167 ConfigurePrerenderFromOmnibox();
162 } 168 }
163 169
164 void ConfigurePrerenderFromOmnibox() { 170 void ConfigurePrerenderFromOmnibox() {
165 // Field trial to see if we're enabled. 171 // Field trial to see if we're enabled.
166 const base::FieldTrial::Probability kDivisor = 100; 172 const base::FieldTrial::Probability kDivisor = 100;
167 173
168 const base::FieldTrial::Probability kEnabledProbability = 40; 174 const base::FieldTrial::Probability kEnabledProbability = 40;
169 scoped_refptr<base::FieldTrial> enabled_trial( 175 scoped_refptr<base::FieldTrial> enabled_trial(
170 new base::FieldTrial("PrerenderFromOmnibox", kDivisor, 176 new base::FieldTrial(kPrerenderFromOmniboxTrialName, kDivisor,
171 "OmniboxPrerenderDisabled", 2012, 8, 30)); 177 "OmniboxPrerenderDisabled", 2012, 8, 30));
172 enabled_trial->AppendGroup("OmniboxPrerenderEnabled", kEnabledProbability); 178 enabled_trial->AppendGroup("OmniboxPrerenderEnabled", kEnabledProbability);
173 179
174 // Field trial to see which heuristic to use. 180 // Field trial to see which heuristic to use.
175 const base::FieldTrial::Probability kConservativeProbability = 33; 181 const base::FieldTrial::Probability kConservativeProbability = 25;
176 const base::FieldTrial::Probability kExactProbability = 33; 182 const base::FieldTrial::Probability kExactProbability = 25;
183 const base::FieldTrial::Probability kExactFullProbability = 25;
177 scoped_refptr<base::FieldTrial> heuristic_trial( 184 scoped_refptr<base::FieldTrial> heuristic_trial(
178 new base::FieldTrial("PrerenderFromOmniboxHeuristic", kDivisor, 185 new base::FieldTrial(kPrerenderFromOmniboxHeuristicTrialName, kDivisor,
179 "OriginalAlgorithm", 2012, 8, 30)); 186 "OriginalAlgorithm", 2012, 8, 30));
180 omnibox_original_group_id = base::FieldTrial::kDefaultGroupNumber; 187 omnibox_original_group_id = base::FieldTrial::kDefaultGroupNumber;
181 omnibox_conservative_group_id = 188 omnibox_conservative_group_id =
182 heuristic_trial->AppendGroup("ConservativeAlgorithm", 189 heuristic_trial->AppendGroup("ConservativeAlgorithm",
183 kConservativeProbability); 190 kConservativeProbability);
184 omnibox_exact_group_id = 191 omnibox_exact_group_id =
185 heuristic_trial->AppendGroup("ExactAlgorithm", kExactProbability); 192 heuristic_trial->AppendGroup("ExactAlgorithm", kExactProbability);
193 omnibox_exact_full_group_id =
194 heuristic_trial->AppendGroup("ExactFullAlgorithm", kExactFullProbability);
186 } 195 }
187 196
188 bool IsOmniboxEnabled(Profile* profile) { 197 bool IsOmniboxEnabled(Profile* profile) {
189 if (!profile || profile->IsOffTheRecord()) 198 if (!profile || profile->IsOffTheRecord())
190 return false; 199 return false;
191 200
192 if (!PrerenderManager::IsPrerenderingPossible()) 201 if (!PrerenderManager::IsPrerenderingPossible())
193 return false; 202 return false;
194 203
195 // Override any field trial groups if the user has set a command line flag. 204 // Override any field trial groups if the user has set a command line flag.
196 if (CommandLine::ForCurrentProcess()->HasSwitch( 205 if (CommandLine::ForCurrentProcess()->HasSwitch(
197 switches::kPrerenderFromOmnibox)) { 206 switches::kPrerenderFromOmnibox)) {
198 const std::string switch_value = 207 const std::string switch_value =
199 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 208 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
200 switches::kPrerenderFromOmnibox); 209 switches::kPrerenderFromOmnibox);
201 210
202 if (switch_value == switches::kPrerenderFromOmniboxSwitchValueEnabled) 211 if (switch_value == switches::kPrerenderFromOmniboxSwitchValueEnabled)
203 return true; 212 return true;
204 213
205 if (switch_value == switches::kPrerenderFromOmniboxSwitchValueDisabled) 214 if (switch_value == switches::kPrerenderFromOmniboxSwitchValueDisabled)
206 return false; 215 return false;
207 216
208 DCHECK(switch_value == switches::kPrerenderFromOmniboxSwitchValueAuto); 217 DCHECK(switch_value == switches::kPrerenderFromOmniboxSwitchValueAuto);
209 } 218 }
210 219
211 if (!MetricsServiceHelper::IsMetricsReportingEnabled()) 220 if (!MetricsServiceHelper::IsMetricsReportingEnabled())
212 return false; 221 return false;
213 222
214 const int group = base::FieldTrialList::FindValue("PrerenderFromOmnibox"); 223 const int group =
224 base::FieldTrialList::FindValue(kPrerenderFromOmniboxTrialName);
215 return group != base::FieldTrial::kNotFinalized && 225 return group != base::FieldTrial::kNotFinalized &&
216 group != base::FieldTrial::kDefaultGroupNumber; 226 group != base::FieldTrial::kDefaultGroupNumber;
217 } 227 }
218 228
219 OmniboxHeuristic GetOmniboxHeuristicToUse() { 229 OmniboxHeuristic GetOmniboxHeuristicToUse() {
220 const int group = 230 const int group =
221 base::FieldTrialList::FindValue("PrerenderFromOmniboxHeuristic"); 231 base::FieldTrialList::FindValue(kPrerenderFromOmniboxHeuristicTrialName);
222 if (group == omnibox_original_group_id) 232 if (group == omnibox_original_group_id)
223 return OMNIBOX_HEURISTIC_ORIGINAL; 233 return OMNIBOX_HEURISTIC_ORIGINAL;
224 if (group == omnibox_conservative_group_id) 234 if (group == omnibox_conservative_group_id)
225 return OMNIBOX_HEURISTIC_CONSERVATIVE; 235 return OMNIBOX_HEURISTIC_CONSERVATIVE;
226 if (group == omnibox_exact_group_id) 236 if (group == omnibox_exact_group_id)
227 return OMNIBOX_HEURISTIC_EXACT; 237 return OMNIBOX_HEURISTIC_EXACT;
238 if (group == omnibox_exact_full_group_id)
239 return OMNIBOX_HEURISTIC_EXACT_FULL;
228 240
229 // If we don't have a group just return the original heuristic. 241 // If we don't have a group just return the original heuristic.
230 return OMNIBOX_HEURISTIC_ORIGINAL; 242 return OMNIBOX_HEURISTIC_ORIGINAL;
231 } 243 }
232 244
233 std::string GetOmniboxHistogramSuffix() { 245 std::string GetOmniboxHistogramSuffix() {
234 return NameFromOmniboxHeuristic(prerender::GetOmniboxHeuristicToUse()); 246 return NameFromOmniboxHeuristic(prerender::GetOmniboxHeuristicToUse());
235 } 247 }
236 248
237 } // namespace prerender 249 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_field_trial.h ('k') | chrome/browser/prerender/prerender_histograms.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698