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

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

Issue 7558014: Add a URL param to indicate group selection in Instant field trial. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Thread safe handling of Profiles Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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/metrics/field_trial.h" 7 #include "base/metrics/field_trial.h"
8 #include "chrome/browser/prefs/pref_service.h" 8 #include "chrome/browser/prefs/pref_service.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
(...skipping 20 matching lines...) Expand all
31 trial->UseOneTimeRandomization(); 31 trial->UseOneTimeRandomization();
32 32
33 g_control_group_id_1 = trial->AppendGroup("InstantControl1", 450); // 45% 33 g_control_group_id_1 = trial->AppendGroup("InstantControl1", 450); // 45%
34 g_control_group_id_2 = trial->AppendGroup("InstantControl2", 450); // 45% 34 g_control_group_id_2 = trial->AppendGroup("InstantControl2", 450); // 45%
35 g_experiment_group_id_1 = trial->AppendGroup("InstantExperiment1", 50); // 5% 35 g_experiment_group_id_1 = trial->AppendGroup("InstantExperiment1", 50); // 5%
36 g_experiment_group_id_2 = trial->AppendGroup("InstantExperiment2", 50); // 5% 36 g_experiment_group_id_2 = trial->AppendGroup("InstantExperiment2", 50); // 5%
37 } 37 }
38 38
39 // static 39 // static
40 InstantFieldTrial::Group InstantFieldTrial::GetGroup(Profile* profile) { 40 InstantFieldTrial::Group InstantFieldTrial::GetGroup(Profile* profile) {
41 if (profile->IsOffTheRecord()) 41 if (profile->IsOffTheRecord())
Peter Kasting 2011/08/10 20:54:06 Modify this to be: if (!profile || profile->IsO
42 return INACTIVE; 42 return INACTIVE;
43 43
44 const PrefService* prefs = profile->GetPrefs(); 44 const PrefService* prefs = profile->GetPrefs();
45 if (!prefs || 45 if (!prefs ||
46 !prefs->GetBoolean(prefs::kSearchSuggestEnabled) || 46 !prefs->GetBoolean(prefs::kSearchSuggestEnabled) ||
47 prefs->GetBoolean(prefs::kInstantEnabledOnce) || 47 prefs->GetBoolean(prefs::kInstantEnabledOnce) ||
48 prefs->IsManagedPreference(prefs::kInstantEnabled)) { 48 prefs->IsManagedPreference(prefs::kInstantEnabled)) {
49 return INACTIVE; 49 return INACTIVE;
50 } 50 }
51 51
(...skipping 22 matching lines...) Expand all
74 switch (GetGroup(profile)) { 74 switch (GetGroup(profile)) {
75 case INACTIVE: return "InstantInactive"; 75 case INACTIVE: return "InstantInactive";
76 case CONTROL1: return "InstantControl1"; 76 case CONTROL1: return "InstantControl1";
77 case CONTROL2: return "InstantControl2"; 77 case CONTROL2: return "InstantControl2";
78 case EXPERIMENT1: return "InstantExperiment1"; 78 case EXPERIMENT1: return "InstantExperiment1";
79 case EXPERIMENT2: return "InstantExperiment2"; 79 case EXPERIMENT2: return "InstantExperiment2";
80 } 80 }
81 NOTREACHED(); 81 NOTREACHED();
82 return "InstantUnknown"; 82 return "InstantUnknown";
83 } 83 }
84
85 // static
86 std::string InstantFieldTrial::GetGroupAsUrlParam(Profile* profile) {
87 switch (GetGroup(profile)) {
88 case INACTIVE: return "";
Peter Kasting 2011/08/10 20:54:06 Nit: Use std::string() instead of "" (2 places)
89 case CONTROL1: return "ix=c1&";
90 case CONTROL2: return "ix=c2&";
91 case EXPERIMENT1: return "ix=e1&";
92 case EXPERIMENT2: return "ix=e2&";
93 }
94 NOTREACHED();
95 return "";
96 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698