Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: chrome/browser/chrome_browser_field_trials_desktop.cc

Issue 14247021: Split the field trial setup code into desktop and mobile files. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Review. Created 7 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/chrome_browser_field_trials.h" 5 #include "chrome/browser/chrome_browser_field_trials_desktop.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "apps/field_trial_names.h" 9 #include "apps/field_trial_names.h"
10 #include "apps/pref_names.h" 10 #include "apps/pref_names.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/stringprintf.h"
16 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/sys_string_conversions.h"
18 #include "base/utf_string_conversions.h"
19 #include "chrome/browser/auto_launch_trial.h" 15 #include "chrome/browser/auto_launch_trial.h"
20 #include "chrome/browser/google/google_util.h" 16 #include "chrome/browser/google/google_util.h"
21 #include "chrome/browser/gpu/chrome_gpu_util.h" 17 #include "chrome/browser/gpu/chrome_gpu_util.h"
22 #include "chrome/browser/omnibox/omnibox_field_trial.h" 18 #include "chrome/browser/omnibox/omnibox_field_trial.h"
23 #include "chrome/browser/prerender/prerender_field_trial.h" 19 #include "chrome/browser/prerender/prerender_field_trial.h"
24 #include "chrome/browser/profiles/profile_manager.h" 20 #include "chrome/browser/profiles/profile_manager.h"
25 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" 21 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
26 #include "chrome/browser/ui/sync/one_click_signin_helper.h" 22 #include "chrome/browser/ui/sync/one_click_signin_helper.h"
27 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
28 #include "chrome/common/chrome_version_info.h" 24 #include "chrome/common/chrome_version_info.h"
29 #include "chrome/common/metrics/variations/uniformity_field_trials.h"
30 #include "chrome/common/metrics/variations/variations_util.h" 25 #include "chrome/common/metrics/variations/variations_util.h"
31 #include "chrome/common/pref_names.h"
32 #include "net/spdy/spdy_session.h" 26 #include "net/spdy/spdy_session.h"
33 #include "ui/base/layout.h" 27 #include "ui/base/layout.h"
34 28
35 #if defined(OS_WIN) 29 #if defined(OS_WIN)
36 #include "net/socket/tcp_client_socket_win.h" 30 #include "net/socket/tcp_client_socket_win.h"
37 #endif // defined(OS_WIN) 31 #endif // defined(OS_WIN)
38 32
39 ChromeBrowserFieldTrials::ChromeBrowserFieldTrials( 33 namespace chrome {
40 const CommandLine& parsed_command_line)
41 : parsed_command_line_(parsed_command_line) {
42 }
43 34
44 ChromeBrowserFieldTrials::~ChromeBrowserFieldTrials() { 35 namespace {
45 }
46 36
47 void ChromeBrowserFieldTrials::SetupFieldTrials(PrefService* local_state) { 37 void SetupAppLauncherFieldTrial(PrefService* local_state) {
48 const base::Time install_time = base::Time::FromTimeT(
49 local_state->GetInt64(prefs::kInstallDate));
50 DCHECK(!install_time.is_null());
51 chrome_variations::SetupUniformityFieldTrials(install_time);
52 SetUpSimpleCacheFieldTrial();
53 #if !defined(OS_ANDROID) && !defined(OS_IOS)
54 SetupDesktopFieldTrials(local_state);
55 #endif // defined(OS_ANDROID)
56
57 #if defined(OS_ANDROID) || defined(OS_IOS)
58 SetupMobileFieldTrials();
59 #endif // defined(OS_ANDROID) || defined(OS_IOS)
60 }
61
62
63 #if defined(OS_ANDROID) || defined(OS_IOS)
64 void ChromeBrowserFieldTrials::SetupMobileFieldTrials() {
65 DataCompressionProxyFieldTrial();
66 }
67
68 // Governs the rollout of the compression proxy for Chrome on mobile platforms.
69 // Always enabled in DEV and BETA versions.
70 // Stable percentage will be controlled from server.
71 void ChromeBrowserFieldTrials::DataCompressionProxyFieldTrial() {
72 const char kDataCompressionProxyFieldTrialName[] =
73 "DataCompressionProxyRollout";
74 const base::FieldTrial::Probability kDataCompressionProxyDivisor = 1000;
75
76 // 10/1000 = 1% for starters.
77 const base::FieldTrial::Probability kDataCompressionProxyStable = 10;
78 const char kEnabled[] = "Enabled";
79 const char kDisabled[] = "Disabled";
80
81 // Find out if this is a stable channel.
82 const bool kIsStableChannel =
83 chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_STABLE;
84
85 // Experiment enabled until Jan 1, 2015. By default, disabled.
86 scoped_refptr<base::FieldTrial> trial(
87 base::FieldTrialList::FactoryGetFieldTrial(
88 kDataCompressionProxyFieldTrialName, kDataCompressionProxyDivisor,
89 kDisabled, 2015, 1, 1, NULL));
90
91 // We want our trial results to be persistent.
92 trial->UseOneTimeRandomization();
93 // Non-stable channels will run with probability 1.
94 const int kEnabledGroup = trial->AppendGroup(
95 kEnabled,
96 kIsStableChannel ?
97 kDataCompressionProxyStable : kDataCompressionProxyDivisor);
98
99 const int v = trial->group();
100 VLOG(1) << "DataCompression proxy enabled group id: " << kEnabledGroup
101 << ". Selected group id: " << v;
102 }
103 #endif // defined(OS_ANDROID) || defined(OS_IOS)
104
105 void ChromeBrowserFieldTrials::SetupDesktopFieldTrials(
106 PrefService* local_state) {
107 prerender::ConfigurePrefetchAndPrerender(parsed_command_line_);
108 SpdyFieldTrial();
109 AutoLaunchChromeFieldTrial();
110 gpu_util::InitializeCompositingFieldTrial();
111 OmniboxFieldTrial::ActivateStaticTrials();
112 SetUpInfiniteCacheFieldTrial();
113 SetUpCacheSensitivityAnalysisFieldTrial();
114 DisableShowProfileSwitcherTrialIfNecessary();
115 WindowsOverlappedTCPReadsFieldTrial();
116 #if defined(ENABLE_ONE_CLICK_SIGNIN)
117 OneClickSigninHelper::InitializeFieldTrial();
118 #endif
119 InstantiateDynamicTrials();
120 SetupAppLauncherFieldTrial(local_state);
121 }
122
123 void ChromeBrowserFieldTrials::SetupAppLauncherFieldTrial(
124 PrefService* local_state) {
125 if (base::FieldTrialList::FindFullName(apps::kLauncherPromoTrialName) == 38 if (base::FieldTrialList::FindFullName(apps::kLauncherPromoTrialName) ==
126 apps::kResetShowLauncherPromoPrefGroupName) { 39 apps::kResetShowLauncherPromoPrefGroupName) {
127 local_state->SetBoolean(apps::prefs::kShowAppLauncherPromo, true); 40 local_state->SetBoolean(apps::prefs::kShowAppLauncherPromo, true);
128 } 41 }
129 } 42 }
130 43
131 // When --use-spdy not set, users will be in A/B test for spdy. 44 // When --use-spdy not set, users will be in A/B test for spdy.
132 // group A (npn_with_spdy): this means npn and spdy are enabled. In case server 45 // group A (npn_with_spdy): this means npn and spdy are enabled. In case server
133 // supports spdy, browser will use spdy. 46 // supports spdy, browser will use spdy.
134 // group B (npn_with_http): this means npn is enabled but spdy won't be used. 47 // group B (npn_with_http): this means npn is enabled but spdy won't be used.
135 // Http is still used for all requests. 48 // Http is still used for all requests.
136 // default group: no npn or spdy is involved. The "old" non-spdy 49 // default group: no npn or spdy is involved. The "old" non-spdy
137 // chrome behavior. 50 // chrome behavior.
138 void ChromeBrowserFieldTrials::SpdyFieldTrial() { 51 void SpdyFieldTrial() {
139 // Setup SPDY CWND Field trial. 52 // Setup SPDY CWND Field trial.
140 const base::FieldTrial::Probability kSpdyCwndDivisor = 100; 53 const base::FieldTrial::Probability kSpdyCwndDivisor = 100;
141 const base::FieldTrial::Probability kSpdyCwnd16 = 20; // fixed at 16 54 const base::FieldTrial::Probability kSpdyCwnd16 = 20; // fixed at 16
142 const base::FieldTrial::Probability kSpdyCwnd10 = 20; // fixed at 10 55 const base::FieldTrial::Probability kSpdyCwnd10 = 20; // fixed at 10
143 const base::FieldTrial::Probability kSpdyCwndMin16 = 20; // no less than 16 56 const base::FieldTrial::Probability kSpdyCwndMin16 = 20; // no less than 16
144 const base::FieldTrial::Probability kSpdyCwndMin10 = 20; // no less than 10 57 const base::FieldTrial::Probability kSpdyCwndMin10 = 20; // no less than 10
145 58
146 // After June 30, 2013 builds, it will always be in default group 59 // After June 30, 2013 builds, it will always be in default group
147 // (cwndDynamic). 60 // (cwndDynamic).
148 scoped_refptr<base::FieldTrial> trial( 61 scoped_refptr<base::FieldTrial> trial(
149 base::FieldTrialList::FactoryGetFieldTrial( 62 base::FieldTrialList::FactoryGetFieldTrial(
150 "SpdyCwnd", kSpdyCwndDivisor, "cwndDynamic", 2013, 6, 30, NULL)); 63 "SpdyCwnd", kSpdyCwndDivisor, "cwndDynamic", 2013, 6, 30, NULL));
151 64
152 trial->AppendGroup("cwnd10", kSpdyCwnd10); 65 trial->AppendGroup("cwnd10", kSpdyCwnd10);
153 trial->AppendGroup("cwnd16", kSpdyCwnd16); 66 trial->AppendGroup("cwnd16", kSpdyCwnd16);
154 trial->AppendGroup("cwndMin16", kSpdyCwndMin16); 67 trial->AppendGroup("cwndMin16", kSpdyCwndMin16);
155 trial->AppendGroup("cwndMin10", kSpdyCwndMin10); 68 trial->AppendGroup("cwndMin10", kSpdyCwndMin10);
156 } 69 }
157 70
158 void ChromeBrowserFieldTrials::AutoLaunchChromeFieldTrial() { 71 void AutoLaunchChromeFieldTrial() {
159 std::string brand; 72 std::string brand;
160 google_util::GetBrand(&brand); 73 google_util::GetBrand(&brand);
161 74
162 // Create a 100% field trial based on the brand code. 75 // Create a 100% field trial based on the brand code.
163 if (auto_launch_trial::IsInExperimentGroup(brand)) { 76 if (auto_launch_trial::IsInExperimentGroup(brand)) {
164 base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName, 77 base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName,
165 kAutoLaunchTrialAutoLaunchGroup); 78 kAutoLaunchTrialAutoLaunchGroup);
166 } else if (auto_launch_trial::IsInControlGroup(brand)) { 79 } else if (auto_launch_trial::IsInControlGroup(brand)) {
167 base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName, 80 base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName,
168 kAutoLaunchTrialControlGroup); 81 kAutoLaunchTrialControlGroup);
169 } 82 }
170 } 83 }
171 84
172 void ChromeBrowserFieldTrials::SetUpInfiniteCacheFieldTrial() { 85 void SetUpInfiniteCacheFieldTrial() {
173 const base::FieldTrial::Probability kDivisor = 100; 86 const base::FieldTrial::Probability kDivisor = 100;
174 87
175 base::FieldTrial::Probability infinite_cache_probability = 0; 88 base::FieldTrial::Probability infinite_cache_probability = 0;
176 89
177 scoped_refptr<base::FieldTrial> trial( 90 scoped_refptr<base::FieldTrial> trial(
178 base::FieldTrialList::FactoryGetFieldTrial("InfiniteCache", kDivisor, 91 base::FieldTrialList::FactoryGetFieldTrial("InfiniteCache", kDivisor,
179 "No", 2013, 12, 31, NULL)); 92 "No", 2013, 12, 31, NULL));
180 trial->UseOneTimeRandomization(); 93 trial->UseOneTimeRandomization();
181 trial->AppendGroup("Yes", infinite_cache_probability); 94 trial->AppendGroup("Yes", infinite_cache_probability);
182 trial->AppendGroup("Control", infinite_cache_probability); 95 trial->AppendGroup("Control", infinite_cache_probability);
183 } 96 }
184 97
185 void ChromeBrowserFieldTrials::DisableShowProfileSwitcherTrialIfNecessary() { 98 void DisableShowProfileSwitcherTrialIfNecessary() {
186 // This trial is created by the VariationsService, but it needs to be disabled 99 // This trial is created by the VariationsService, but it needs to be disabled
187 // if multi-profiles isn't enabled or if browser frame avatar menu is 100 // if multi-profiles isn't enabled or if browser frame avatar menu is
188 // always hidden (Chrome OS). 101 // always hidden (Chrome OS).
189 bool avatar_menu_always_hidden = false; 102 bool avatar_menu_always_hidden = false;
190 #if defined(OS_CHROMEOS) 103 #if defined(OS_CHROMEOS)
191 avatar_menu_always_hidden = true; 104 avatar_menu_always_hidden = true;
192 #endif 105 #endif
193 base::FieldTrial* trial = base::FieldTrialList::Find("ShowProfileSwitcher"); 106 base::FieldTrial* trial = base::FieldTrialList::Find("ShowProfileSwitcher");
194 if (trial && (!ProfileManager::IsMultipleProfilesEnabled() || 107 if (trial && (!ProfileManager::IsMultipleProfilesEnabled() ||
195 avatar_menu_always_hidden)) { 108 avatar_menu_always_hidden)) {
196 trial->Disable(); 109 trial->Disable();
197 } 110 }
198 } 111 }
199 112
200 // Sets up the experiment. The actual cache backend choice is made in the net/ 113 void SetUpCacheSensitivityAnalysisFieldTrial() {
201 // internals by looking at the experiment state.
202 void ChromeBrowserFieldTrials::SetUpSimpleCacheFieldTrial() {
203 if (parsed_command_line_.HasSwitch(switches::kUseSimpleCacheBackend)) {
204 const std::string opt_value = parsed_command_line_.GetSwitchValueASCII(
205 switches::kUseSimpleCacheBackend);
206 const base::FieldTrial::Probability kDivisor = 100;
207 scoped_refptr<base::FieldTrial> trial(
208 base::FieldTrialList::FactoryGetFieldTrial("SimpleCacheTrial", kDivisor,
209 "ExperimentNo", 2013, 12, 31,
210 NULL));
211 trial->UseOneTimeRandomization();
212 if (LowerCaseEqualsASCII(opt_value, "off")) {
213 trial->AppendGroup("ExplicitNo", kDivisor);
214 return;
215 }
216 if (LowerCaseEqualsASCII(opt_value, "on")) {
217 trial->AppendGroup("ExplicitYes", kDivisor);
218 return;
219 }
220 #if defined(OS_ANDROID)
221 if (LowerCaseEqualsASCII(opt_value, "experiment")) {
222 // TODO(pasko): Make this the default on Android when the simple cache
223 // adds a few more necessary features. Also adjust the probability.
224 const base::FieldTrial::Probability kSimpleCacheProbability = 1;
225 trial->AppendGroup("ExperimentYes", kSimpleCacheProbability);
226 trial->AppendGroup("ExperimentControl", kSimpleCacheProbability);
227 trial->group();
228 }
229 #endif
230 }
231 }
232
233 void ChromeBrowserFieldTrials::SetUpCacheSensitivityAnalysisFieldTrial() {
234 const base::FieldTrial::Probability kDivisor = 100; 114 const base::FieldTrial::Probability kDivisor = 100;
235 115
236 base::FieldTrial::Probability sensitivity_analysis_probability = 0; 116 base::FieldTrial::Probability sensitivity_analysis_probability = 0;
237 117
238 #if defined(OS_ANDROID) 118 #if defined(OS_ANDROID)
239 switch (chrome::VersionInfo::GetChannel()) { 119 switch (chrome::VersionInfo::GetChannel()) {
240 case chrome::VersionInfo::CHANNEL_DEV: 120 case chrome::VersionInfo::CHANNEL_DEV:
241 sensitivity_analysis_probability = 10; 121 sensitivity_analysis_probability = 10;
242 break; 122 break;
243 case chrome::VersionInfo::CHANNEL_BETA: 123 case chrome::VersionInfo::CHANNEL_BETA:
(...skipping 13 matching lines...) Expand all
257 2013, 06, 15, NULL)); 137 2013, 06, 15, NULL));
258 trial->AppendGroup("ControlA", sensitivity_analysis_probability); 138 trial->AppendGroup("ControlA", sensitivity_analysis_probability);
259 trial->AppendGroup("ControlB", sensitivity_analysis_probability); 139 trial->AppendGroup("ControlB", sensitivity_analysis_probability);
260 trial->AppendGroup("100A", sensitivity_analysis_probability); 140 trial->AppendGroup("100A", sensitivity_analysis_probability);
261 trial->AppendGroup("100B", sensitivity_analysis_probability); 141 trial->AppendGroup("100B", sensitivity_analysis_probability);
262 trial->AppendGroup("200A", sensitivity_analysis_probability); 142 trial->AppendGroup("200A", sensitivity_analysis_probability);
263 trial->AppendGroup("200B", sensitivity_analysis_probability); 143 trial->AppendGroup("200B", sensitivity_analysis_probability);
264 // TODO(gavinp,rvargas): Re-add 400 group to field trial if results justify. 144 // TODO(gavinp,rvargas): Re-add 400 group to field trial if results justify.
265 } 145 }
266 146
267 void ChromeBrowserFieldTrials::WindowsOverlappedTCPReadsFieldTrial() { 147 void WindowsOverlappedTCPReadsFieldTrial(
148 const CommandLine& parsed_command_line) {
268 #if defined(OS_WIN) 149 #if defined(OS_WIN)
269 if (parsed_command_line_.HasSwitch(switches::kOverlappedRead)) { 150 if (parsed_command_line.HasSwitch(switches::kOverlappedRead)) {
270 std::string option = 151 std::string option =
271 parsed_command_line_.GetSwitchValueASCII(switches::kOverlappedRead); 152 parsed_command_line.GetSwitchValueASCII(switches::kOverlappedRead);
272 if (LowerCaseEqualsASCII(option, "off")) 153 if (LowerCaseEqualsASCII(option, "off"))
273 net::TCPClientSocketWin::DisableOverlappedReads(); 154 net::TCPClientSocketWin::DisableOverlappedReads();
274 } else { 155 } else {
275 const base::FieldTrial::Probability kDivisor = 2; // 1 in 2 chance 156 const base::FieldTrial::Probability kDivisor = 2; // 1 in 2 chance
276 const base::FieldTrial::Probability kOverlappedReadProbability = 1; 157 const base::FieldTrial::Probability kOverlappedReadProbability = 1;
277 scoped_refptr<base::FieldTrial> overlapped_reads_trial( 158 scoped_refptr<base::FieldTrial> overlapped_reads_trial(
278 base::FieldTrialList::FactoryGetFieldTrial("OverlappedReadImpact", 159 base::FieldTrialList::FactoryGetFieldTrial("OverlappedReadImpact",
279 kDivisor, "OverlappedReadEnabled", 2013, 6, 1, NULL)); 160 kDivisor, "OverlappedReadEnabled", 2013, 6, 1, NULL));
280 int overlapped_reads_disabled_group = 161 int overlapped_reads_disabled_group =
281 overlapped_reads_trial->AppendGroup("OverlappedReadDisabled", 162 overlapped_reads_trial->AppendGroup("OverlappedReadDisabled",
282 kOverlappedReadProbability); 163 kOverlappedReadProbability);
283 int assigned_group = overlapped_reads_trial->group(); 164 int assigned_group = overlapped_reads_trial->group();
284 if (assigned_group == overlapped_reads_disabled_group) 165 if (assigned_group == overlapped_reads_disabled_group)
285 net::TCPClientSocketWin::DisableOverlappedReads(); 166 net::TCPClientSocketWin::DisableOverlappedReads();
286 } 167 }
287 #endif 168 #endif
288 } 169 }
289 170
290 void ChromeBrowserFieldTrials::InstantiateDynamicTrials() { 171 void InstantiateDynamicTrials() {
291 // Call |FindValue()| on the trials below, which may come from the server, to 172 // Call |FindValue()| on the trials below, which may come from the server, to
292 // ensure they get marked as "used" for the purposes of data reporting. 173 // ensure they get marked as "used" for the purposes of data reporting.
293 base::FieldTrialList::FindValue("UMA-Dynamic-Binary-Uniformity-Trial"); 174 base::FieldTrialList::FindValue("UMA-Dynamic-Binary-Uniformity-Trial");
294 base::FieldTrialList::FindValue("UMA-Dynamic-Uniformity-Trial"); 175 base::FieldTrialList::FindValue("UMA-Dynamic-Uniformity-Trial");
Alexei Svitkine (slow) 2013/04/19 15:32:44 We want this on mobile too. The two UMA-* trials
295 base::FieldTrialList::FindValue("InstantDummy"); 176 base::FieldTrialList::FindValue("InstantDummy");
296 base::FieldTrialList::FindValue("InstantChannel"); 177 base::FieldTrialList::FindValue("InstantChannel");
297 base::FieldTrialList::FindValue("Test0PercentDefault"); 178 base::FieldTrialList::FindValue("Test0PercentDefault");
298 // Activate the autocomplete dynamic field trials. 179 // Activate the autocomplete dynamic field trials.
299 OmniboxFieldTrial::ActivateDynamicTrials(); 180 OmniboxFieldTrial::ActivateDynamicTrials();
300 } 181 }
182
183 } // namespace
184
185 void SetupDesktopFieldTrials(const CommandLine& parsed_command_line,
186 const base::Time& install_time,
187 PrefService* local_state) {
188 prerender::ConfigurePrefetchAndPrerender(parsed_command_line);
189 SpdyFieldTrial();
190 AutoLaunchChromeFieldTrial();
191 gpu_util::InitializeCompositingFieldTrial();
192 OmniboxFieldTrial::ActivateStaticTrials();
193 SetUpInfiniteCacheFieldTrial();
194 SetUpCacheSensitivityAnalysisFieldTrial();
195 DisableShowProfileSwitcherTrialIfNecessary();
196 WindowsOverlappedTCPReadsFieldTrial(parsed_command_line);
197 #if defined(ENABLE_ONE_CLICK_SIGNIN)
198 OneClickSigninHelper::InitializeFieldTrial();
199 #endif
200 InstantiateDynamicTrials();
201 SetupAppLauncherFieldTrial(local_state);
202 }
203
204 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_field_trials_desktop.h ('k') | chrome/browser/chrome_browser_field_trials_mobile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698