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
3 // found in the LICENSE file.
5 #include "chrome/browser/chrome_browser_field_trials_mobile.h"
9 #include "base/command_line.h"
10 #include "base/metrics/field_trial.h"
11 #include "base/prefs/pref_service.h"
12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/chrome_version_info.h"
19 // Base function used by all data reduction proxy field trials. A trial is
20 // only conducted for installs that are in the "Enabled" group. They are always
21 // enabled on DEV and BETA channels, and for STABLE, a percentage will be
22 // controlled from the server. Until the percentage is learned from the server,
23 // a client-side configuration is used.
24 void DataCompressionProxyBaseFieldTrial(
25 const char* trial_name
,
26 const base::FieldTrial::Probability enabled_group_probability
,
27 const base::FieldTrial::Probability total_probability
) {
28 const char kEnabled
[] = "Enabled";
29 const char kDisabled
[] = "Disabled";
31 // Find out if this is a stable channel.
32 const bool kIsStableChannel
=
33 chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_STABLE
;
35 // Experiment enabled until Jan 1, 2015. By default, disabled.
36 scoped_refptr
<base::FieldTrial
> trial(
37 base::FieldTrialList::FactoryGetFieldTrial(
40 kDisabled
, 2015, 1, 1, base::FieldTrial::ONE_TIME_RANDOMIZED
, NULL
));
42 // Non-stable channels will run with probability 1.
43 const int kEnabledGroup
= trial
->AppendGroup(
45 kIsStableChannel
? enabled_group_probability
: total_probability
);
47 const int v
= trial
->group();
48 VLOG(1) << trial_name
<< " enabled group id: " << kEnabledGroup
49 << ". Selected group id: " << v
;
52 void DataCompressionProxyFieldTrials() {
53 // Governs the rollout of the compression proxy for Chrome on mobile
54 // platforms. In all channels, the percentage will be controlled from the
55 // server, and is configured to be 100% = 1000 / 1000 until overridden by the
57 DataCompressionProxyBaseFieldTrial(
58 "DataCompressionProxyRollout", 1000, 1000);
60 // Governs the rollout of the _promo_ for the compression proxy
61 // independently from the rollout of compression proxy. The enabled
62 // percentage is configured to be 10% = 100 / 1000 until overridden by the
63 // server. When this trial is "Enabled," users get a promo, whereas
64 // otherwise, compression is available without a promo.
65 DataCompressionProxyBaseFieldTrial(
66 "DataCompressionProxyPromoVisibility", 100, 1000);
71 void SetupMobileFieldTrials(const CommandLine
& parsed_command_line
,
72 const base::Time
& install_time
,
73 PrefService
* local_state
) {
74 DataCompressionProxyFieldTrials();