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

Unified Diff: chrome/browser/instant/instant_field_trial.cc

Issue 7583012: Restrict Instant field trial to UMA opt-in users. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed @jar's comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/instant/instant_field_trial.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
index 90016ff3003085d050cc50efbc519781a21256b9..38ee088d11e03d1a6519d644b2eccdb447d3d3b6 100644
--- a/chrome/browser/instant/instant_field_trial.cc
+++ b/chrome/browser/instant/instant_field_trial.cc
@@ -4,24 +4,40 @@
#include "chrome/browser/instant/instant_field_trial.h"
+#include "base/metrics/field_trial.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
namespace {
-bool field_trial_active_ = false;
+
+// Field trial IDs of the control and experiment groups. Though they are not
+// literally "const", they are set only once, in Activate() below.
+int g_control_group_id_1 = 0;
+int g_control_group_id_2 = 0;
+int g_experiment_group_id_1 = 0;
+int g_experiment_group_id_2 = 0;
+
}
// static
void InstantFieldTrial::Activate() {
- field_trial_active_ = true;
+ scoped_refptr<base::FieldTrial> trial(
+ new base::FieldTrial("Instant", 1000, "InstantInactive", 2012, 1, 1));
+
+ // One-time randomization is disabled if the user hasn't opted-in to UMA.
+ if (!base::FieldTrialList::IsOneTimeRandomizationEnabled())
+ return;
+ trial->UseOneTimeRandomization();
+
+ g_control_group_id_1 = trial->AppendGroup("InstantControl1", 450); // 45%
+ g_control_group_id_2 = trial->AppendGroup("InstantControl2", 450); // 45%
+ g_experiment_group_id_1 = trial->AppendGroup("InstantExperiment1", 50); // 5%
+ g_experiment_group_id_2 = trial->AppendGroup("InstantExperiment2", 50); // 5%
}
// static
InstantFieldTrial::Group InstantFieldTrial::GetGroup(Profile* profile) {
- if (!field_trial_active_)
- return INACTIVE;
-
if (profile->IsOffTheRecord())
return INACTIVE;
@@ -33,11 +49,18 @@ InstantFieldTrial::Group InstantFieldTrial::GetGroup(Profile* profile) {
return INACTIVE;
}
- const int random = prefs->GetInteger(prefs::kInstantFieldTrialRandomDraw);
- return random < 4500 ? CONTROL1 : // 45%
- random < 9000 ? CONTROL2 : // 45%
- random < 9500 ? EXPERIMENT1 // 5%
- : EXPERIMENT2; // 5%
+ const int group = base::FieldTrialList::FindValue("Instant");
+
+ if (group == base::FieldTrial::kNotFinalized ||
+ group == base::FieldTrial::kDefaultGroupNumber) {
+ return INACTIVE;
+ }
+
+ return group == g_control_group_id_1 ? CONTROL1 :
+ group == g_control_group_id_2 ? CONTROL2 :
+ group == g_experiment_group_id_1 ? EXPERIMENT1 :
+ group == g_experiment_group_id_2 ? EXPERIMENT2
+ : INACTIVE;
}
// static
« no previous file with comments | « chrome/browser/instant/instant_field_trial.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698