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

Side by Side Diff: components/ntp_tiles/field_trial.cc

Issue 2484233002: Hard coded finch config for Popular site (Closed)
Patch Set: Rebase. Created 4 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
« no previous file with comments | « components/ntp_tiles/field_trial.h ('k') | components/ntp_tiles/most_visited_sites.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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.
4
5 #include "base/metrics/field_trial.h"
6
7 #if defined(OS_ANDROID)
8 #include <jni.h>
9 #endif
10
11 #include "base/command_line.h"
12 #include "base/metrics/field_trial.h"
13 #include "base/strings/string_util.h"
14 #include "components/ntp_tiles/constants.h"
15 #include "components/ntp_tiles/field_trial.h"
16 #include "components/ntp_tiles/switches.h"
17
18 #if defined(OS_ANDROID)
19 #include "base/android/jni_android.h"
20 #include "jni/MostVisitedSites_jni.h"
21 #endif
22
23 const char kPopularSiteDefaultGroup[] = "Default";
Alexei Svitkine (slow) 2016/11/16 00:52:53 Nit: Put in anon namespace.
noyau (Ping after 24h) 2016/11/16 12:28:02 Done.
24 const char kPopularSiteControlGroup[] = "Control";
25 const char kPopularSiteEnabledGroup[] = "Enabled";
26 const char kPopularSiteEnabledCommandLineSwitchGroup[] =
27 "EnabledWithCommandLineSwitch";
28 const char kPopularSiteDisabledCommandLineSwitchGroup[] =
29 "DisabledWithCommandLineSwitch";
30
31 // On iOS it is not technically possible to prep the field trials on first
32 // launch, the configuration file is downloaded too late. In order to run some
33 // experiments that need to be active on first launch to be meaningful these
34 // are hardcoded, but can be superceeded by a server side config on subsequent
35 // launches.
36 void ntp_tiles::SetUpFirstLaunchFieldTrial(bool is_stable_channel) {
Alexei Svitkine (slow) 2016/11/16 00:52:53 Nit: Specifying namespace like this is not usually
noyau (Ping after 24h) 2016/11/16 12:28:02 Done.
37 // Check first if a server side config superceeded this experiment.
38 if (base::FieldTrialList::TrialExists(kPopularSitesFieldTrialName))
39 return;
40
41 // Stable channels will run with 10% probability.
42 // Non-stable channels will run with 50% probability.
43 const base::FieldTrial::Probability kTotalProbability = 100;
44 const base::FieldTrial::Probability kEnabledAndControlProbability =
45 is_stable_channel ? 10 : 50;
46
47 // Experiment enabled until March 15, 2017. By default, disabled.
48 scoped_refptr<base::FieldTrial> trial(
49 base::FieldTrialList::FactoryGetFieldTrial(
50 kPopularSitesFieldTrialName, kTotalProbability,
51 kPopularSiteDefaultGroup, 2017, 3, 15, // Mar 15, 2017
52 base::FieldTrial::ONE_TIME_RANDOMIZED, NULL));
Alexei Svitkine (slow) 2016/11/16 00:52:53 nullptr
noyau (Ping after 24h) 2016/11/16 12:28:02 Done.
53
54 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
55 if (command_line->HasSwitch(ntp_tiles::switches::kEnableNTPPopularSites)) {
56 trial->AppendGroup(kPopularSiteEnabledCommandLineSwitchGroup,
57 kTotalProbability);
58 } else if (command_line->HasSwitch(
59 ntp_tiles::switches::kDisableNTPPopularSites)) {
60 trial->AppendGroup(kPopularSiteDisabledCommandLineSwitchGroup,
61 kTotalProbability);
62 } else {
63 trial->AppendGroup(kPopularSiteControlGroup, kEnabledAndControlProbability);
64 trial->AppendGroup(kPopularSiteEnabledGroup, kEnabledAndControlProbability);
65 }
66 trial->group();
Alexei Svitkine (slow) 2016/11/16 00:52:53 Suggest leaving this out. This way, the trial wil
noyau (Ping after 24h) 2016/11/16 12:28:02 Done.
67 }
68
69 bool ntp_tiles::ShouldShowPopularSites() {
70 // Note: It's important to query the field trial state first, to ensure that
71 // UMA reports the correct group.
72 const std::string group_name =
73 base::FieldTrialList::FindFullName(kPopularSitesFieldTrialName);
74
75 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
76 if (cmd_line->HasSwitch(switches::kDisableNTPPopularSites))
77 return false;
78
79 if (cmd_line->HasSwitch(switches::kEnableNTPPopularSites))
80 return true;
81
82 #if defined(OS_ANDROID)
83 if (Java_MostVisitedSites_isPopularSitesForceEnabled(
84 base::android::AttachCurrentThread())) {
85 return true;
86 }
87 #endif
88
89 return base::StartsWith(group_name, "Enabled",
90 base::CompareCase::INSENSITIVE_ASCII);
91 }
OLDNEW
« no previous file with comments | « components/ntp_tiles/field_trial.h ('k') | components/ntp_tiles/most_visited_sites.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698