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

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

Issue 606003003: Fix PrerenderFromOmnibox field trial by removing the hard-coded percentages, (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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"
(...skipping 15 matching lines...) Expand all
26 using base::FieldTrial; 26 using base::FieldTrial;
27 using base::FieldTrialList; 27 using base::FieldTrialList;
28 using base::StringToInt; 28 using base::StringToInt;
29 using std::string; 29 using std::string;
30 using std::vector; 30 using std::vector;
31 31
32 namespace prerender { 32 namespace prerender {
33 33
34 namespace { 34 namespace {
35 35
36 const char kOmniboxTrialName[] = "PrerenderFromOmnibox";
37 int g_omnibox_trial_default_group_number = kint32min;
38
39 const char kDisabledGroup[] = "Disabled"; 36 const char kDisabledGroup[] = "Disabled";
40 const char kEnabledGroup[] = "Enabled"; 37 const char kEnabledGroup[] = "Enabled";
41 38
42 const char kLocalPredictorSpecTrialName[] = "PrerenderLocalPredictorSpec"; 39 const char kLocalPredictorSpecTrialName[] = "PrerenderLocalPredictorSpec";
43 const char kLocalPredictorKeyName[] = "LocalPredictor"; 40 const char kLocalPredictorKeyName[] = "LocalPredictor";
44 const char kLocalPredictorUnencryptedSyncOnlyKeyName[] = 41 const char kLocalPredictorUnencryptedSyncOnlyKeyName[] =
45 "LocalPredictorUnencryptedSyncOnly"; 42 "LocalPredictorUnencryptedSyncOnly";
46 const char kLocalPredictorNetworkPredictionEnabledOnly[] = 43 const char kLocalPredictorNetworkPredictionEnabledOnly[] =
47 "LocalPredictorNetworkPredictionEnabledOnly"; 44 "LocalPredictorNetworkPredictionEnabledOnly";
48 const char kLocalPredictorOnCellularOnly[] = "LocalPredictorOnCellularOnly"; 45 const char kLocalPredictorOnCellularOnly[] = "LocalPredictorOnCellularOnly";
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } else if (trial_group == experiment_match_complete_group) { 191 } else if (trial_group == experiment_match_complete_group) {
195 PrerenderManager::SetMode( 192 PrerenderManager::SetMode(
196 PrerenderManager::PRERENDER_MODE_EXPERIMENT_MATCH_COMPLETE_GROUP); 193 PrerenderManager::PRERENDER_MODE_EXPERIMENT_MATCH_COMPLETE_GROUP);
197 } else { 194 } else {
198 NOTREACHED(); 195 NOTREACHED();
199 } 196 }
200 } 197 }
201 198
202 } // end namespace 199 } // end namespace
203 200
204 void ConfigureOmniboxPrerender();
205
206 void ConfigurePrerender(const CommandLine& command_line) { 201 void ConfigurePrerender(const CommandLine& command_line) {
207 enum PrerenderOption { 202 enum PrerenderOption {
208 PRERENDER_OPTION_AUTO, 203 PRERENDER_OPTION_AUTO,
209 PRERENDER_OPTION_DISABLED, 204 PRERENDER_OPTION_DISABLED,
210 PRERENDER_OPTION_ENABLED, 205 PRERENDER_OPTION_ENABLED,
211 }; 206 };
212 207
213 PrerenderOption prerender_option = PRERENDER_OPTION_AUTO; 208 PrerenderOption prerender_option = PRERENDER_OPTION_AUTO;
214 if (command_line.HasSwitch(switches::kPrerenderMode)) { 209 if (command_line.HasSwitch(switches::kPrerenderMode)) {
215 const string switch_value = 210 const string switch_value =
(...skipping 22 matching lines...) Expand all
238 break; 233 break;
239 case PRERENDER_OPTION_DISABLED: 234 case PRERENDER_OPTION_DISABLED:
240 PrerenderManager::SetMode(PrerenderManager::PRERENDER_MODE_DISABLED); 235 PrerenderManager::SetMode(PrerenderManager::PRERENDER_MODE_DISABLED);
241 break; 236 break;
242 case PRERENDER_OPTION_ENABLED: 237 case PRERENDER_OPTION_ENABLED:
243 PrerenderManager::SetMode(PrerenderManager::PRERENDER_MODE_ENABLED); 238 PrerenderManager::SetMode(PrerenderManager::PRERENDER_MODE_ENABLED);
244 break; 239 break;
245 default: 240 default:
246 NOTREACHED(); 241 NOTREACHED();
247 } 242 }
248
249 ConfigureOmniboxPrerender();
250 }
251
252 void ConfigureOmniboxPrerender() {
253 // Field trial to see if we're enabled.
254 const FieldTrial::Probability kDivisor = 100;
255
256 FieldTrial::Probability kDisabledProbability = 10;
257 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
258 if (channel == chrome::VersionInfo::CHANNEL_STABLE ||
259 channel == chrome::VersionInfo::CHANNEL_BETA) {
260 kDisabledProbability = 1;
261 }
262 scoped_refptr<FieldTrial> omnibox_prerender_trial(
263 FieldTrialList::FactoryGetFieldTrial(
264 kOmniboxTrialName, kDivisor, "OmniboxPrerenderEnabled",
265 2014, 12, 31, FieldTrial::SESSION_RANDOMIZED,
266 &g_omnibox_trial_default_group_number));
267 omnibox_prerender_trial->AppendGroup("OmniboxPrerenderDisabled",
268 kDisabledProbability);
269 } 243 }
270 244
271 bool IsOmniboxEnabled(Profile* profile) { 245 bool IsOmniboxEnabled(Profile* profile) {
272 if (!profile) 246 if (!profile)
273 return false; 247 return false;
274 248
275 if (!PrerenderManager::IsPrerenderingPossible()) 249 if (!PrerenderManager::IsPrerenderingPossible())
276 return false; 250 return false;
277 251
278 // Override any field trial groups if the user has set a command line flag. 252 // Override any field trial groups if the user has set a command line flag.
279 if (CommandLine::ForCurrentProcess()->HasSwitch( 253 if (CommandLine::ForCurrentProcess()->HasSwitch(
280 switches::kPrerenderFromOmnibox)) { 254 switches::kPrerenderFromOmnibox)) {
281 const string switch_value = 255 const string switch_value =
282 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 256 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
283 switches::kPrerenderFromOmnibox); 257 switches::kPrerenderFromOmnibox);
284 258
285 if (switch_value == switches::kPrerenderFromOmniboxSwitchValueEnabled) 259 if (switch_value == switches::kPrerenderFromOmniboxSwitchValueEnabled)
286 return true; 260 return true;
287 261
288 if (switch_value == switches::kPrerenderFromOmniboxSwitchValueDisabled) 262 if (switch_value == switches::kPrerenderFromOmniboxSwitchValueDisabled)
289 return false; 263 return false;
290 264
291 DCHECK_EQ(switches::kPrerenderFromOmniboxSwitchValueAuto, switch_value); 265 DCHECK_EQ(switches::kPrerenderFromOmniboxSwitchValueAuto, switch_value);
292 } 266 }
293 267
294 const int group = FieldTrialList::FindValue(kOmniboxTrialName); 268 return (FieldTrialList::FindFullName("PrerenderFromOmnibox") !=
cbentzel 2014/09/29 11:19:17 Do you anticipate ever having multiple Disabled gr
tburkard 2014/09/29 11:22:11 I think we don't have a need for this at this poin
295 return group == FieldTrial::kNotFinalized || 269 "OmniboxPrerenderDisabled");
296 group == g_omnibox_trial_default_group_number;
297 } 270 }
298 271
299 /* 272 /*
300 PrerenderLocalPredictorSpec is a field trial, and its value must have the 273 PrerenderLocalPredictorSpec is a field trial, and its value must have the
301 following format: 274 following format:
302 key1=value1:key2=value2:key3=value3 275 key1=value1:key2=value2:key3=value3
303 eg "LocalPredictor=Enabled:SideEffectFreeWhitelist=Enabled" 276 eg "LocalPredictor=Enabled:SideEffectFreeWhitelist=Enabled"
304 The function below extracts the value corresponding to a key provided from the 277 The function below extracts the value corresponding to a key provided from the
305 LocalPredictorSpec. 278 LocalPredictorSpec.
306 */ 279 */
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 return GetLocalPredictorSpecValue(kDisableSessionStorageNamespaceMerging) != 486 return GetLocalPredictorSpecValue(kDisableSessionStorageNamespaceMerging) !=
514 kDisabledGroup; 487 kDisabledGroup;
515 } 488 }
516 489
517 bool IsPrerenderCookieStoreEnabled() { 490 bool IsPrerenderCookieStoreEnabled() {
518 return GetLocalPredictorSpecValue(kPrerenderCookieStore) != kDisabledGroup && 491 return GetLocalPredictorSpecValue(kPrerenderCookieStore) != kDisabledGroup &&
519 FieldTrialList::FindFullName(kPrerenderCookieStore) != kDisabledGroup; 492 FieldTrialList::FindFullName(kPrerenderCookieStore) != kDisabledGroup;
520 } 493 }
521 494
522 } // namespace prerender 495 } // namespace prerender
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698