summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsreeram@chromium.org <sreeram@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-09 20:40:08 +0000
committersreeram@chromium.org <sreeram@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-09 20:40:08 +0000
commitd6773feb98254f837edcad81ad122959322fcb1b (patch)
tree6eba6d3030be837903ad3292a9b55c39dad99f6d /chrome
parent6c2999b35364b8882f8b9d10275ce46caa7d3a7c (diff)
downloadchromium_src-d6773feb98254f837edcad81ad122959322fcb1b.zip
chromium_src-d6773feb98254f837edcad81ad122959322fcb1b.tar.gz
chromium_src-d6773feb98254f837edcad81ad122959322fcb1b.tar.bz2
Restrict Instant field trial to UMA opt-in users.
Note that if the Instant experiment has already been enabled, and *then* the user opts out of UMA, this won't disable the experiment immediately (since the global field trial state doesn't change). Instead, it will be disabled at browser restart. I think this is acceptable since, if the user is fiddling with preferences after Instant has been enabled, they can already click the Instant checkbox to turn it off. In addition: + Fix a typo in the "Omnibox.QueryTime.*" histogram. + Update the comment in the .h file so it flows better. BUG=91820 TEST=Disable UMA reporting (as is default in a Chromium build), and verify that the Instant experiment doesn't get enabled. Review URL: http://codereview.chromium.org/7583012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96057 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autocomplete/autocomplete.cc2
-rw-r--r--chrome/browser/instant/instant_controller.cc3
-rw-r--r--chrome/browser/instant/instant_field_trial.cc43
-rw-r--r--chrome/browser/instant/instant_field_trial.h17
-rw-r--r--chrome/common/pref_names.cc4
-rw-r--r--chrome/common/pref_names.h1
6 files changed, 42 insertions, 28 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc
index b56c1bf..d728924 100644
--- a/chrome/browser/autocomplete/autocomplete.cc
+++ b/chrome/browser/autocomplete/autocomplete.cc
@@ -869,7 +869,7 @@ void AutocompleteController::Start(
(text.length() < 6)) {
base::TimeTicks end_time = base::TimeTicks::Now();
std::string name = "Omnibox.QueryTime." +
- InstantFieldTrial::GetGroupName(profile_) +
+ InstantFieldTrial::GetGroupName(profile_) + "." +
base::IntToString(text.length());
base::Histogram* counter = base::Histogram::FactoryGet(
name, 1, 1000, 50, base::Histogram::kUmaTargetedHistogramFlag);
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc
index 2c5a59c..63d2ca4 100644
--- a/chrome/browser/instant/instant_controller.cc
+++ b/chrome/browser/instant/instant_controller.cc
@@ -76,9 +76,6 @@ void InstantController::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterInt64Pref(prefs::kInstantEnabledTime,
false,
PrefService::UNSYNCABLE_PREF);
- prefs->RegisterIntegerPref(prefs::kInstantFieldTrialRandomDraw,
- base::RandInt(0, 9999),
- PrefService::UNSYNCABLE_PREF);
PromoCounter::RegisterUserPrefs(prefs, prefs::kInstantPromo);
}
diff --git a/chrome/browser/instant/instant_field_trial.cc b/chrome/browser/instant/instant_field_trial.cc
index 90016ff..38ee088 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
diff --git a/chrome/browser/instant/instant_field_trial.h b/chrome/browser/instant/instant_field_trial.h
index fd808f6..8c92039 100644
--- a/chrome/browser/instant/instant_field_trial.h
+++ b/chrome/browser/instant/instant_field_trial.h
@@ -12,7 +12,13 @@
class Profile;
// This class manages the Instant field trial. Each user is in exactly one of
-// two field trial groups: Control or Experiment.
+// three field trial groups: Inactive, Control or Experiment.
+// - Inactive users are those who have played with the Instant option in the
+// Preferences page, or those for whom group policy provides an override, or
+// those with an incognito profile, etc. The field trial is inactive for such
+// users, so their Instant preference setting is respected. The field trial is
+// also initially inactive (until activated in BrowserMain), so testing is not
+// affected by the field trial.
// - Control and Experiment are all the other users, i.e., those who have never
// touched the Preferences option. Some percentage of these users are chosen
// into the Experiment group and get Instant enabled automatically. The rest
@@ -20,13 +26,6 @@ class Profile;
// - Control and Experiment are further split into two subgroups each, in order
// to detect bias between them (when analyzing metrics). The subgroups are
// treated identically for all other purposes.
-//
-// There is a possibility that the field trial is not active.
-// - Inactive users are those who have played with the Instant option in the
-// Preferences page, or those for whom group policy provides an override, or
-// those with an incognito profile, etc. The field trial is inactive for such
-// users, so their Instant preference setting is respected. The field trial is
-// initially inactive so testing is not affected by the field trial.
class InstantFieldTrial {
public:
enum Group {
@@ -38,7 +37,7 @@ class InstantFieldTrial {
};
// Activate the field trial. Before this call, all calls to GetGroup will
- // return INACTIVE.
+ // return INACTIVE. *** MUST NOT BE CALLED MORE THAN ONCE. ***
static void Activate();
// Return the field trial group this profile belongs to.
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 9a9fc6d..073b6aa 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -279,10 +279,6 @@ const char kInstantEnabledOnce[] = "instant.enabled_once";
// Time when instant was last enabled.
const char kInstantEnabledTime[] = "instant.enabled_time";
-// Random number drawn and used by the Instant field trial. Stored in prefs to
-// provide a consistent field trial experience across browser restarts.
-const char kInstantFieldTrialRandomDraw[] = "instant.field_trial_random_draw";
-
// Used to maintain instant promo keys. See PromoCounter for details of subkeys
// that are used.
const char kInstantPromo[] = "instant.promo";
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 1ff960b..790935e 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -95,7 +95,6 @@ extern const char kInstantConfirmDialogShown[];
extern const char kInstantEnabled[];
extern const char kInstantEnabledOnce[];
extern const char kInstantEnabledTime[];
-extern const char kInstantFieldTrialRandomDraw[];
extern const char kInstantPromo[];
extern const char kMultipleProfilePrefMigration[];
extern const char kNetworkPredictionEnabled[];