OLD | NEW |
---|---|
(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/instant/instant_field_trial.h" | |
6 | |
7 #include "chrome/browser/prefs/pref_service.h" | |
8 #include "chrome/browser/profiles/profile.h" | |
9 #include "chrome/common/pref_names.h" | |
10 | |
11 // static | |
12 InstantFieldTrial::Group InstantFieldTrial::GetGroup(Profile* profile) { | |
13 if (profile->IsOffTheRecord()) | |
14 return INACTIVE; | |
15 | |
16 const PrefService* prefs = profile->GetPrefs(); | |
17 if (!prefs || | |
18 prefs->GetBoolean(prefs::kInstantEnabledOnce) || | |
19 prefs->IsManagedPreference(prefs::kInstantEnabled)) { | |
20 return INACTIVE; | |
21 } | |
22 | |
23 const double random = prefs->GetDouble(prefs::kInstantFieldTrialRandomDraw); | |
jar (doing other things)
2011/07/22 01:42:17
IMO, you should use persistent prefs, and (as you
sreeram
2011/07/22 14:31:16
Addressed by quantizing the random number.
| |
24 return random < 0.45 ? CONTROL1 : // 45% | |
25 random < 0.90 ? CONTROL2 : // 45% | |
26 random < 0.95 ? EXPERIMENT1 // 5% | |
27 : EXPERIMENT2; // 5% | |
28 } | |
29 | |
30 // static | |
31 std::string InstantFieldTrial::GetGroupName(Profile* profile) { | |
32 switch (GetGroup(profile)) { | |
33 case INACTIVE: return "InstantInactive"; | |
34 case CONTROL1: return "InstantControl1"; | |
35 case CONTROL2: return "InstantControl2"; | |
36 case EXPERIMENT1: return "InstantExperiment1"; | |
37 case EXPERIMENT2: return "InstantExperiment2"; | |
38 } | |
39 NOTREACHED(); | |
40 return "InstantUnknown"; | |
41 } | |
OLD | NEW |