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

Side by Side Diff: chrome/browser/ui/webui/sync_promo_trial.cc

Issue 8689006: Create a field test for sync sign in promo strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Init Created 9 years 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 "chrome/browser/ui/webui/sync_promo_trial.h"
6
7 #include "base/metrics/field_trial.h"
8 #include "chrome/browser/metrics/metrics_service.h"
9 #include "chrome/browser/prefs/pref_service.h"
10
11 namespace {
12
13 // Field trial IDs of the control and experiment groups. Though they are not
14 // literally "const", they are set only once, in Activate() below. See the .h
15 // file for what these groups represent.
16 int g_sync_promo_experiment_a = 0;
17 int g_sync_promo_experiment_b = 0;
18 int g_sync_promo_experiment_c = 0;
19 int g_sync_promo_experiment_d = 0;
20
21 const char* kSyncPromoMsgTrialName = "SyncPromoMsg";
22
23 }
24
25 // static
26 void SyncPromoTrial::Activate() {
27 // TODO(stevet): Verify with jeffreyc that this date (March 12, 2012) is
28 // approx 2 weeks into M17 stable.
29 scoped_refptr<base::FieldTrial> trial(
30 new base::FieldTrial(kSyncPromoMsgTrialName, 1000, "MsgA", 2012, 3, 12));
31 g_sync_promo_experiment_a = base::FieldTrial::kDefaultGroupNumber;
32
33 // Try to give the user a consistent experience, if possible.
34 if (base::FieldTrialList::IsOneTimeRandomizationEnabled())
35 trial->UseOneTimeRandomization();
36
37 // Each group has probability 0.5%, leaving the control with 98.5%.
38 g_sync_promo_experiment_b = trial->AppendGroup("MsgB", 5);
39 g_sync_promo_experiment_c = trial->AppendGroup("MsgC", 5);
40 g_sync_promo_experiment_d = trial->AppendGroup("MsgD", 5);
41 }
42
43 // static
44 bool SyncPromoTrial::IsExperimentActive() {
45 return base::FieldTrialList::FindValue(kSyncPromoMsgTrialName) !=
46 base::FieldTrial::kNotFinalized;
47 }
48
49 // static
50 SyncPromoTrial::Group SyncPromoTrial::GetGroup() {
51 // Promo message A is also the default value, so display it if there is no
52 // active experiment.
53 if (!IsExperimentActive())
54 return PROMO_MSG_A;
55
56 const int group = base::FieldTrialList::FindValue(kSyncPromoMsgTrialName);
57 if (group == g_sync_promo_experiment_a)
58 return PROMO_MSG_A;
59 else if (group == g_sync_promo_experiment_b)
60 return PROMO_MSG_B;
61 else if (group == g_sync_promo_experiment_c)
62 return PROMO_MSG_C;
63 else if (group == g_sync_promo_experiment_d)
64 return PROMO_MSG_D;
65
66 NOTREACHED();
67 return PROMO_MSG_A;
68 }
69
70 // static
71 void SyncPromoTrial::RecordUserSawMessage() {
72 DCHECK(IsExperimentActive());
73 UMA_HISTOGRAM_ENUMERATION("SyncPromo.MessageDisplayed",
74 GetGroup(),
75 PROMO_MSG_MAX);
76 }
77
78 // static
79 void SyncPromoTrial::RecordUserSignedIn() {
80 DCHECK(IsExperimentActive());
81 UMA_HISTOGRAM_ENUMERATION("SyncPromo.MessageOnSignIn",
82 GetGroup(),
83 PROMO_MSG_MAX);
84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698