OLD | NEW |
1 // Copyright 2013 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_mobile.h" | 5 #include "chrome/browser/chrome_browser_field_trials_mobile.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/chrome_version_info.h" | |
14 | 13 |
15 #if defined(OS_ANDROID) | 14 #if defined(OS_ANDROID) |
16 #include "chrome/browser/prerender/prerender_field_trial.h" | 15 #include "chrome/browser/prerender/prerender_field_trial.h" |
17 #endif | 16 #endif |
18 | 17 |
19 namespace chrome { | 18 namespace chrome { |
20 | 19 |
21 namespace { | |
22 | |
23 // Base function used by all data reduction proxy field trials. A trial is | |
24 // only conducted for installs that are in the "Enabled" group. They are always | |
25 // enabled on DEV and BETA channels, and for STABLE, a percentage will be | |
26 // controlled from the server. Until the percentage is learned from the server, | |
27 // a client-side configuration is used. | |
28 void DataCompressionProxyBaseFieldTrial( | |
29 const char* trial_name, | |
30 const base::FieldTrial::Probability enabled_group_probability, | |
31 const base::FieldTrial::Probability total_probability) { | |
32 const char kEnabled[] = "Enabled"; | |
33 const char kDisabled[] = "Disabled"; | |
34 | |
35 // Find out if this is a stable channel. | |
36 const bool kIsStableChannel = | |
37 chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_STABLE; | |
38 | |
39 // Experiment enabled until Jan 1, 2015. By default, disabled. | |
40 scoped_refptr<base::FieldTrial> trial( | |
41 base::FieldTrialList::FactoryGetFieldTrial( | |
42 trial_name, | |
43 total_probability, | |
44 kDisabled, 2015, 1, 1, base::FieldTrial::ONE_TIME_RANDOMIZED, NULL)); | |
45 | |
46 // Non-stable channels will run with probability 1. | |
47 const int kEnabledGroup = trial->AppendGroup( | |
48 kEnabled, | |
49 kIsStableChannel ? enabled_group_probability : total_probability); | |
50 | |
51 const int v = trial->group(); | |
52 VLOG(1) << trial_name << " enabled group id: " << kEnabledGroup | |
53 << ". Selected group id: " << v; | |
54 } | |
55 | |
56 void DataCompressionProxyFieldTrials() { | |
57 // Governs the rollout of the compression proxy for Chrome on mobile | |
58 // platforms. In all channels, the percentage will be controlled from the | |
59 // server, and is configured to be 100% = 1000 / 1000 until overridden by the | |
60 // server. | |
61 DataCompressionProxyBaseFieldTrial( | |
62 "DataCompressionProxyRollout", 1000, 1000); | |
63 | |
64 // Governs the rollout of the _promo_ for the compression proxy | |
65 // independently from the rollout of compression proxy. The enabled | |
66 // percentage is configured to be 10% = 100 / 1000 until overridden by the | |
67 // server. When this trial is "Enabled," users get a promo, whereas | |
68 // otherwise, compression is available without a promo. | |
69 DataCompressionProxyBaseFieldTrial( | |
70 "DataCompressionProxyPromoVisibility", 100, 1000); | |
71 } | |
72 | |
73 } // namespace | |
74 | |
75 void SetupMobileFieldTrials(const CommandLine& parsed_command_line) { | 20 void SetupMobileFieldTrials(const CommandLine& parsed_command_line) { |
76 DataCompressionProxyFieldTrials(); | |
77 #if defined(OS_ANDROID) | 21 #if defined(OS_ANDROID) |
78 prerender::ConfigurePrerender(parsed_command_line); | 22 prerender::ConfigurePrerender(parsed_command_line); |
79 #endif | 23 #endif |
80 } | 24 } |
81 | 25 |
82 } // namespace chrome | 26 } // namespace chrome |
OLD | NEW |