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

Side by Side Diff: chrome/browser/instant/instant_field_trial.cc

Issue 9705074: Supporting command line argument to force field trials (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed some ooopss... Created 8 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 (c) 2012 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/instant/instant_field_trial.h" 5 #include "chrome/browser/instant/instant_field_trial.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "chrome/browser/metrics/metrics_service.h" 9 #include "chrome/browser/metrics/metrics_service.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
14 14
15 namespace { 15 namespace {
16 16
17 // Field trial IDs of the control and experiment groups. Though they are not 17 // Field trial IDs of the control and experiment groups. Though they are not
18 // literally "const", they are set only once, in Activate() below. See the .h 18 // literally "const", they are set only once, in Activate() below. See the .h
19 // file for what these groups represent. 19 // file for what these groups represent.
20 int g_inactive = -1;
20 int g_instant = 0; 21 int g_instant = 0;
21 int g_suggest = 0; 22 int g_suggest = 0;
22 int g_hidden = 0; 23 int g_hidden = 0;
23 int g_silent = 0; 24 int g_silent = 0;
24 int g_control = 0; 25 int g_control = 0;
25 26
26 } 27 }
27 28
28 // static 29 // static
29 void InstantFieldTrial::Activate() { 30 void InstantFieldTrial::Activate() {
30 scoped_refptr<base::FieldTrial> trial( 31 scoped_refptr<base::FieldTrial> trial(
31 new base::FieldTrial("Instant", 1000, "Inactive", 2013, 7, 1)); 32 base::FieldTrialList::FactoryGetFieldTrial(
33 "Instant", 1000, "Inactive", 2013, 7, 1, &g_inactive));
32 34
33 // Try to give the user a consistent experience, if possible. 35 // Try to give the user a consistent experience, if possible.
34 if (base::FieldTrialList::IsOneTimeRandomizationEnabled()) 36 if (base::FieldTrialList::IsOneTimeRandomizationEnabled())
35 trial->UseOneTimeRandomization(); 37 trial->UseOneTimeRandomization();
36 38
37 g_instant = trial->AppendGroup("Instant", 10); // 1% 39 g_instant = trial->AppendGroup("Instant", 10); // 1%
38 g_suggest = trial->AppendGroup("Suggest", 10); // 1% 40 g_suggest = trial->AppendGroup("Suggest", 10); // 1%
39 g_hidden = trial->AppendGroup("Hidden", 960); // 96% 41 g_hidden = trial->AppendGroup("Hidden", 960); // 96%
40 g_silent = trial->AppendGroup("Silent", 10); // 1% 42 g_silent = trial->AppendGroup("Silent", 10); // 1%
41 g_control = trial->AppendGroup("Control", 10); // 1% 43 g_control = trial->AppendGroup("Control", 10); // 1%
(...skipping 27 matching lines...) Expand all
69 group = HIDDEN; 71 group = HIDDEN;
70 else if (switch_value == switches::kInstantFieldTrialSilent) 72 else if (switch_value == switches::kInstantFieldTrialSilent)
71 group = SILENT; 73 group = SILENT;
72 else if (switch_value == switches::kInstantFieldTrialControl) 74 else if (switch_value == switches::kInstantFieldTrialControl)
73 group = CONTROL; 75 group = CONTROL;
74 UMA_HISTOGRAM_ENUMERATION("Instant.FieldTrial.Reason", 1, 10); 76 UMA_HISTOGRAM_ENUMERATION("Instant.FieldTrial.Reason", 1, 10);
75 return group; 77 return group;
76 } 78 }
77 79
78 const int group = base::FieldTrialList::FindValue("Instant"); 80 const int group = base::FieldTrialList::FindValue("Instant");
79 if (group == base::FieldTrial::kNotFinalized || 81 if (group == base::FieldTrial::kNotFinalized || group == g_inactive) {
80 group == base::FieldTrial::kDefaultGroupNumber) {
81 UMA_HISTOGRAM_ENUMERATION("Instant.FieldTrial.Reason", 2, 10); 82 UMA_HISTOGRAM_ENUMERATION("Instant.FieldTrial.Reason", 2, 10);
82 return INACTIVE; 83 return INACTIVE;
83 } 84 }
84 85
85 const PrefService* prefs = profile ? profile->GetPrefs() : NULL; 86 const PrefService* prefs = profile ? profile->GetPrefs() : NULL;
86 if (!prefs) { 87 if (!prefs) {
87 UMA_HISTOGRAM_ENUMERATION("Instant.FieldTrial.Reason", 3, 10); 88 UMA_HISTOGRAM_ENUMERATION("Instant.FieldTrial.Reason", 3, 10);
88 return INACTIVE; 89 return INACTIVE;
89 } 90 }
90 91
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 179
179 NOTREACHED(); 180 NOTREACHED();
180 return std::string(); 181 return std::string();
181 } 182 }
182 183
183 // static 184 // static
184 bool InstantFieldTrial::ShouldSetSuggestedText(Profile* profile) { 185 bool InstantFieldTrial::ShouldSetSuggestedText(Profile* profile) {
185 Group group = GetGroup(profile); 186 Group group = GetGroup(profile);
186 return group != HIDDEN && group != SILENT; 187 return group != HIDDEN && group != SILENT;
187 } 188 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698