summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-31 01:25:47 +0000
committermpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-31 01:25:47 +0000
commit146759d35ff6161c9b725ececebdfe197a1dfffa (patch)
tree054a72fc6e055446de37421e8515958a4a37ed50
parent20c50b71dcef9b24d444214289f849eb049465b2 (diff)
downloadchromium_src-146759d35ff6161c9b725ececebdfe197a1dfffa.zip
chromium_src-146759d35ff6161c9b725ececebdfe197a1dfffa.tar.gz
chromium_src-146759d35ff6161c9b725ececebdfe197a1dfffa.tar.bz2
Create a field trial for making omnibox autocomplete HistoryURL more aggressive.
This new class AutocompleteFieldTrial is meant to handle one or more field trials at once. I'll add another field trial to it (that makes HistoryQuickProvider more aggressive) soon. BUG= TEST= Review URL: http://codereview.chromium.org/9113037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119798 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autocomplete/autocomplete_field_trial.cc68
-rw-r--r--chrome/browser/autocomplete/autocomplete_field_trial.h36
-rw-r--r--chrome/browser/autocomplete/history_url_provider.cc38
-rw-r--r--chrome/browser/chrome_browser_main.cc2
-rw-r--r--chrome/chrome_browser.gypi2
5 files changed, 144 insertions, 2 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_field_trial.cc b/chrome/browser/autocomplete/autocomplete_field_trial.cc
new file mode 100644
index 0000000..bd05a52
--- /dev/null
+++ b/chrome/browser/autocomplete/autocomplete_field_trial.cc
@@ -0,0 +1,68 @@
+// Copyright (c) 2012 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/autocomplete/autocomplete_field_trial.h"
+
+#include <string>
+
+#include "base/metrics/field_trial.h"
+
+namespace {
+
+// Field trial names.
+static const char kAggressiveHUPFieldTrialName[] =
+ "OmniboxAggressiveHistoryURLProvider";
+
+// Field trial experiment probabilities.
+
+// For aggressive History URL Provider field trial, put 50% ( = 50/100 )
+// of the users in the aggressive experiment group.
+const base::FieldTrial::Probability kAggressiveHUPFieldTrialDivisor = 100;
+const base::FieldTrial::Probability
+ kAggressiveHUPFieldTrialExperimentFraction = 50;
+
+// Field trial IDs.
+// Though they are not literally "const", they are set only once, in
+// Activate() below.
+
+// Field trial ID for the aggressive History URL Provider experiment group.
+int aggressive_hup_experiment_group = 0;
+
+}
+
+
+void AutocompleteFieldTrial::Activate() {
+ // Because users tend to use omnibox without attention to it--habits
+ // get ingrained, users tend to learn that a particular suggestion is
+ // at a particular spot in the drop-down--we're going to make these
+ // field trials sticky. We want users to stay in them once assigned
+ // so they have a better experience and also so we don't get weird
+ // effects as omnibox ranking keeps changing and users learn they can't
+ // trust the omnibox. Hence, to create the field trials we require
+ // that field trials can be made sticky.
+ if (base::FieldTrialList::IsOneTimeRandomizationEnabled()) { // sticky trials
+ // Create aggressive History URL Provider field trial.
+ // Make it expire on August 1, 2012.
+ scoped_refptr<base::FieldTrial> trial(new base::FieldTrial(
+ kAggressiveHUPFieldTrialName, kAggressiveHUPFieldTrialDivisor,
+ "Standard", 2012, 8, 1));
+ trial->UseOneTimeRandomization();
+ aggressive_hup_experiment_group = trial->AppendGroup("Aggressive",
+ kAggressiveHUPFieldTrialExperimentFraction);
+ }
+}
+
+bool AutocompleteFieldTrial::InAggressiveHUPFieldTrial() {
+ return base::FieldTrialList::TrialExists(kAggressiveHUPFieldTrialName);
+}
+
+bool AutocompleteFieldTrial::InAggressiveHUPFieldTrialExperimentGroup() {
+ if (!base::FieldTrialList::TrialExists(kAggressiveHUPFieldTrialName))
+ return false;
+
+ // Return true if we're in the aggressive experiment group.
+ const int group = base::FieldTrialList::FindValue(
+ kAggressiveHUPFieldTrialName);
+ return group == aggressive_hup_experiment_group;
+}
diff --git a/chrome/browser/autocomplete/autocomplete_field_trial.h b/chrome/browser/autocomplete/autocomplete_field_trial.h
new file mode 100644
index 0000000..ec31a1d
--- /dev/null
+++ b/chrome/browser/autocomplete/autocomplete_field_trial.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2012 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.
+
+#ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_FIELD_TRIAL_H_
+#define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_FIELD_TRIAL_H_
+#pragma once
+
+#include <string>
+
+#include "base/basictypes.h"
+
+// This class manages the Autocomplete field trial.
+class AutocompleteFieldTrial {
+ public:
+ // Creates the field trial(s) groups.
+ // *** MUST NOT BE CALLED MORE THAN ONCE. ***
+ static void Activate();
+
+ // ---------------------------------------------------------
+ // For the aggressive History URL Provider field trial.
+
+ // Returns whether the user is in any field trial group for this
+ // field trial. False indicates that the field trial wasn't
+ // successfully created for some reason.
+ static bool InAggressiveHUPFieldTrial();
+
+ // Returns whether the user should get the experiment setup or
+ // the default setup for this field trial.
+ static bool InAggressiveHUPFieldTrialExperimentGroup();
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(AutocompleteFieldTrial);
+};
+
+#endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_FIELD_TRIAL_H_
diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc
index 53db4ab..c38a9d3 100644
--- a/chrome/browser/autocomplete/history_url_provider.cc
+++ b/chrome/browser/autocomplete/history_url_provider.cc
@@ -10,9 +10,11 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/message_loop.h"
+#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
+#include "chrome/browser/autocomplete/autocomplete_field_trial.h"
#include "chrome/browser/autocomplete/autocomplete_match.h"
#include "chrome/browser/history/history.h"
#include "chrome/browser/history/history_backend.h"
@@ -315,11 +317,24 @@ HistoryURLProvider::HistoryURLProvider(ACProviderListener* listener,
prefixes_(GetPrefixes()),
params_(NULL),
enable_aggressive_scoring_(false) {
+ enum AggressivenessOption {
+ AGGRESSIVENESS_DISABLED = 0,
+ AGGRESSIVENESS_ENABLED = 1,
+ AGGRESSIVENESS_AUTO_BUT_NOT_IN_FIELD_TRIAL = 2,
+ AGGRESSIVENESS_FIELD_TRIAL_DEFAULT_GROUP = 3,
+ AGGRESSIVENESS_FIELD_TRIAL_EXPERIMENT_GROUP = 4,
+ NUM_OPTIONS = 5
+ };
+ // should always be overwritten
+ AggressivenessOption aggressiveness_option = NUM_OPTIONS;
+
const std::string switch_value = CommandLine::ForCurrentProcess()->
GetSwitchValueASCII(switches::kOmniboxAggressiveHistoryURL);
if (switch_value == switches::kOmniboxAggressiveHistoryURLEnabled) {
+ aggressiveness_option = AGGRESSIVENESS_ENABLED;
enable_aggressive_scoring_ = true;
} else if (switch_value == switches::kOmniboxAggressiveHistoryURLDisabled) {
+ aggressiveness_option = AGGRESSIVENESS_DISABLED;
enable_aggressive_scoring_ = false;
} else {
// Either: switch_value == switches::kOmniboxAggressiveHistoryURLAuto
@@ -331,9 +346,28 @@ HistoryURLProvider::HistoryURLProvider(ACProviderListener* listener,
<< "received on command line: " << switch_value;
LOG(ERROR) << "Making automatic.";
}
- // For now automatic means disabled / not aggressive.
- enable_aggressive_scoring_ = false;
+ // Automatic means eligible for the field trial.
+ if (AutocompleteFieldTrial::InAggressiveHUPFieldTrial()) {
+ if (AutocompleteFieldTrial::InAggressiveHUPFieldTrialExperimentGroup()) {
+ enable_aggressive_scoring_ = true;
+ aggressiveness_option = AGGRESSIVENESS_FIELD_TRIAL_EXPERIMENT_GROUP;
+ } else {
+ enable_aggressive_scoring_ = false;
+ aggressiveness_option = AGGRESSIVENESS_FIELD_TRIAL_DEFAULT_GROUP;
+ }
+ } else {
+ enable_aggressive_scoring_ = false;
+ aggressiveness_option = AGGRESSIVENESS_AUTO_BUT_NOT_IN_FIELD_TRIAL;
+ }
}
+
+ // Add a beacon to the logs that'll allow us to identify later what
+ // aggressiveness state a user is in. Do this by incrementing a
+ // bucket in a histogram, where the bucket represents the user's
+ // aggressiveness state.
+ UMA_HISTOGRAM_ENUMERATION(
+ "Omnibox.AggressiveHistoryURLProviderFieldTrialBeacon",
+ aggressiveness_option, NUM_OPTIONS);
}
void HistoryURLProvider::Start(const AutocompleteInput& input,
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index 456ad4b..839c505 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -30,6 +30,7 @@
#include "build/build_config.h"
#include "chrome/browser/about_flags.h"
#include "chrome/browser/auto_launch_trial.h"
+#include "chrome/browser/autocomplete/autocomplete_field_trial.h"
#include "chrome/browser/background/background_mode_manager.h"
#include "chrome/browser/browser_process_impl.h"
#include "chrome/browser/browser_shutdown.h"
@@ -1029,6 +1030,7 @@ void ChromeBrowserMainParts::SetupFieldTrials(bool metrics_recording_enabled,
PredictorFieldTrial();
DefaultAppsFieldTrial();
AutoLaunchChromeFieldTrial();
+ AutocompleteFieldTrial::Activate();
sync_promo_trial::Activate();
NewTabUI::SetupFieldTrials();
}
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index de91944..3a5e6aa 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -104,6 +104,8 @@
'browser/autocomplete/autocomplete_controller_delegate.h',
'browser/autocomplete/autocomplete_edit.cc',
'browser/autocomplete/autocomplete_edit.h',
+ 'browser/autocomplete/autocomplete_field_trial.cc',
+ 'browser/autocomplete/autocomplete_field_trial.h',
'browser/autocomplete/autocomplete_match.cc',
'browser/autocomplete/autocomplete_match.h',
'browser/autocomplete/autocomplete_popup_model.cc',