Index: chrome/browser/instant/instant_field_trial.cc |
diff --git a/chrome/browser/instant/instant_field_trial.cc b/chrome/browser/instant/instant_field_trial.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bfa9eb8d4ac19986f2623f2256058b724a9fac77 |
--- /dev/null |
+++ b/chrome/browser/instant/instant_field_trial.cc |
@@ -0,0 +1,41 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/instant/instant_field_trial.h" |
+ |
+#include "chrome/browser/prefs/pref_service.h" |
+#include "chrome/browser/profiles/profile.h" |
+#include "chrome/common/pref_names.h" |
+ |
+// static |
+InstantFieldTrial::Group InstantFieldTrial::GetGroup(Profile* profile) { |
+ if (profile->IsOffTheRecord()) |
+ return INACTIVE; |
+ |
+ const PrefService* prefs = profile->GetPrefs(); |
+ if (!prefs || |
+ prefs->GetBoolean(prefs::kInstantEnabledOnce) || |
+ prefs->IsManagedPreference(prefs::kInstantEnabled)) { |
+ return INACTIVE; |
+ } |
+ |
+ 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.
|
+ return random < 0.45 ? CONTROL1 : // 45% |
+ random < 0.90 ? CONTROL2 : // 45% |
+ random < 0.95 ? EXPERIMENT1 // 5% |
+ : EXPERIMENT2; // 5% |
+} |
+ |
+// static |
+std::string InstantFieldTrial::GetGroupName(Profile* profile) { |
+ switch (GetGroup(profile)) { |
+ case INACTIVE: return "InstantInactive"; |
+ case CONTROL1: return "InstantControl1"; |
+ case CONTROL2: return "InstantControl2"; |
+ case EXPERIMENT1: return "InstantExperiment1"; |
+ case EXPERIMENT2: return "InstantExperiment2"; |
+ } |
+ NOTREACHED(); |
+ return "InstantUnknown"; |
+} |