summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-15 19:44:31 +0000
committermpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-15 19:44:31 +0000
commit8ad29cc3e656c3d949b04c2c81b343e8abb2747b (patch)
tree20493cec9f7d600ffabff408fe5ab2fa0a62524a
parentd376afe14ddabb7318fff20abca29b241e999858 (diff)
downloadchromium_src-8ad29cc3e656c3d949b04c2c81b343e8abb2747b.zip
chromium_src-8ad29cc3e656c3d949b04c2c81b343e8abb2747b.tar.gz
chromium_src-8ad29cc3e656c3d949b04c2c81b343e8abb2747b.tar.bz2
Omnibox: Create HistoryQuickProvider new scoring field trial.
And add a beacon to the histograms to allow identification of users in it. isherman: for field trial and histogram stuff (all files) sky: for OWNERs approval history stuff BUG= TEST=by hand, changed probabilities of field trial, looked at omnibox behavior and histogram behavior Review URL: https://chromiumcodereview.appspot.com/10532149 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142451 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autocomplete/autocomplete_field_trial.cc34
-rw-r--r--chrome/browser/autocomplete/autocomplete_field_trial.h15
-rw-r--r--chrome/browser/history/scored_history_match.cc82
-rw-r--r--chrome/browser/history/scored_history_match.h6
4 files changed, 123 insertions, 14 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_field_trial.cc b/chrome/browser/autocomplete/autocomplete_field_trial.cc
index 9f48b26..3f0f48a 100644
--- a/chrome/browser/autocomplete/autocomplete_field_trial.cc
+++ b/chrome/browser/autocomplete/autocomplete_field_trial.cc
@@ -17,6 +17,7 @@ namespace {
static const char kDisallowInlineHQPFieldTrialName[] =
"OmniboxDisallowInlineHQP";
static const char kSuggestFieldTrialName[] = "OmniboxSearchSuggest";
+static const char kHQPNewScoringFieldTrialName[] = "OmniboxHQPNewScoring";
// Field trial experiment probabilities.
@@ -31,6 +32,12 @@ const base::FieldTrial::Probability
// will decide what behavior (if any) to change based on the group.
const int kSuggestFieldTrialNumberOfGroups = 20;
+// For History Quick Provider new scoring field trial, put 25% ( = 25/100 )
+// of the users in the new scoring experiment group.
+const base::FieldTrial::Probability kHQPNewScoringFieldTrialDivisor = 100;
+const base::FieldTrial::Probability
+ kHQPNewScoringFieldTrialExperimentFraction = 25;
+
// Field trial IDs.
// Though they are not literally "const", they are set only once, in
// Activate() below.
@@ -39,6 +46,9 @@ const int kSuggestFieldTrialNumberOfGroups = 20;
// experiment group.
int disallow_inline_hqp_experiment_group = 0;
+// Field trial ID for the History Quick Provider new scoring experiment group.
+int hqp_new_scoring_experiment_group = 0;
+
}
@@ -90,6 +100,16 @@ void AutocompleteFieldTrial::Activate() {
static_cast<chrome_variations::ID>(
chrome_variations::kSuggestIDMin + i));
}
+
+ // Create inline History Quick Provider new scoring field trial.
+ // Make it expire on January 14, 2013.
+ trial = base::FieldTrialList::FactoryGetFieldTrial(
+ kHQPNewScoringFieldTrialName, kHQPNewScoringFieldTrialDivisor,
+ "Standard", 2013, 1, 14, NULL);
+ if (base::FieldTrialList::IsOneTimeRandomizationEnabled())
+ trial->UseOneTimeRandomization();
+ hqp_new_scoring_experiment_group = trial->AppendGroup("NewScoring",
+ kHQPNewScoringFieldTrialExperimentFraction);
}
bool AutocompleteFieldTrial::InDisallowInlineHQPFieldTrial() {
@@ -130,3 +150,17 @@ int AutocompleteFieldTrial::GetSuggestGroupNameAsNumber() {
int AutocompleteFieldTrial::GetSuggestNumberOfGroups() {
return kSuggestFieldTrialNumberOfGroups;
}
+
+bool AutocompleteFieldTrial::InHQPNewScoringFieldTrial() {
+ return base::FieldTrialList::TrialExists(kHQPNewScoringFieldTrialName);
+}
+
+bool AutocompleteFieldTrial::InHQPNewScoringFieldTrialExperimentGroup() {
+ if (!InHQPNewScoringFieldTrial())
+ return false;
+
+ // Return true if we're in the experiment group.
+ const int group = base::FieldTrialList::FindValue(
+ kHQPNewScoringFieldTrialName);
+ return group == hqp_new_scoring_experiment_group;
+}
diff --git a/chrome/browser/autocomplete/autocomplete_field_trial.h b/chrome/browser/autocomplete/autocomplete_field_trial.h
index 2b6b628..f179125 100644
--- a/chrome/browser/autocomplete/autocomplete_field_trial.h
+++ b/chrome/browser/autocomplete/autocomplete_field_trial.h
@@ -51,6 +51,21 @@ class AutocompleteFieldTrial {
// to create.)
static int GetSuggestNumberOfGroups();
+ // ---------------------------------------------------------
+ // For the History Quick Provider new scoring 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 InHQPNewScoringFieldTrial();
+
+ // Returns whether the user should get the experimental setup or
+ // the default setup for this field trial. The experiment
+ // group uses "new scoring" (a complex multiplicative calculation
+ // that, among other differences from "old scoring", uses word
+ // break information).
+ static bool InHQPNewScoringFieldTrialExperimentGroup();
+
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(AutocompleteFieldTrial);
};
diff --git a/chrome/browser/history/scored_history_match.cc b/chrome/browser/history/scored_history_match.cc
index 4724f5a..724acbc 100644
--- a/chrome/browser/history/scored_history_match.cc
+++ b/chrome/browser/history/scored_history_match.cc
@@ -14,8 +14,10 @@
#include "base/command_line.h"
#include "base/i18n/case_conversion.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/url_prefix.h"
#include "chrome/common/chrome_switches.h"
#include "content/public/browser/browser_thread.h"
@@ -35,18 +37,15 @@ const int kScoreRank[] = { 1450, 1200, 900, 400 };
// ScoredHistoryMatch ----------------------------------------------------------
-bool ScoredHistoryMatch::initialized = false;
+bool ScoredHistoryMatch::initialized_ = false;
bool ScoredHistoryMatch::use_new_scoring = false;
ScoredHistoryMatch::ScoredHistoryMatch()
: raw_score(0),
can_inline(false) {
- if (!initialized) {
- const std::string switch_value = CommandLine::ForCurrentProcess()->
- GetSwitchValueASCII(switches::kOmniboxHistoryQuickProviderNewScoring);
- if (switch_value == switches::kOmniboxHistoryQuickProviderNewScoringEnabled)
- use_new_scoring = true;
- initialized = true;
+ if (!initialized_) {
+ InitializeNewScoringField();
+ initialized_ = true;
}
}
@@ -58,12 +57,9 @@ ScoredHistoryMatch::ScoredHistoryMatch(const URLRow& row,
: HistoryMatch(row, 0, false, false),
raw_score(0),
can_inline(false) {
- if (!initialized) {
- const std::string switch_value = CommandLine::ForCurrentProcess()->
- GetSwitchValueASCII(switches::kOmniboxHistoryQuickProviderNewScoring);
- if (switch_value == switches::kOmniboxHistoryQuickProviderNewScoringEnabled)
- use_new_scoring = true;
- initialized = true;
+ if (!initialized_) {
+ InitializeNewScoringField();
+ initialized_ = true;
}
GURL gurl = row.url();
@@ -476,4 +472,64 @@ float ScoredHistoryMatch::GetPopularityScore(int typed_count,
(5.0 + 3.0);
}
+void ScoredHistoryMatch::InitializeNewScoringField() {
+ enum NewScoringOption {
+ OLD_SCORING = 0,
+ NEW_SCORING = 1,
+ NEW_SCORING_AUTO_BUT_NOT_IN_FIELD_TRIAL = 2,
+ NEW_SCORING_FIELD_TRIAL_DEFAULT_GROUP = 3,
+ NEW_SCORING_FIELD_TRIAL_EXPERIMENT_GROUP = 4,
+ NUM_OPTIONS = 5
+ };
+ // should always be overwritten
+ NewScoringOption new_scoring_option = NUM_OPTIONS;
+
+ const std::string switch_value = CommandLine::ForCurrentProcess()->
+ GetSwitchValueASCII(switches::kOmniboxHistoryQuickProviderNewScoring);
+ if (switch_value == switches::kOmniboxHistoryQuickProviderNewScoringEnabled) {
+ new_scoring_option = NEW_SCORING;
+ use_new_scoring = true;
+ } else if (switch_value ==
+ switches::kOmniboxHistoryQuickProviderNewScoringDisabled) {
+ new_scoring_option = OLD_SCORING;
+ use_new_scoring = false;
+ } else {
+ // We'll assume any other flag means automatic.
+ // Automatic means eligible for the field trial.
+
+ // For the field trial stuff to work correctly, we must be running
+ // on the same thread as the thread that created the field trial,
+ // which happens via a call to AutocompleteFieldTrial::Active in
+ // chrome_browser_main.cc on the main thread. Let's check this to
+ // be sure. We check "if we've heard of the UI thread then we'd better
+ // be on it." The first part is necessary so unit tests pass. (Many
+ // unit tests don't set up the threading naming system; hence
+ // CurrentlyOn(UI thread) will fail.)
+ DCHECK(!content::BrowserThread::IsWellKnownThread(
+ content::BrowserThread::UI) ||
+ content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ if (AutocompleteFieldTrial::InHQPNewScoringFieldTrial()) {
+ if (AutocompleteFieldTrial::
+ InHQPNewScoringFieldTrialExperimentGroup()) {
+ new_scoring_option = NEW_SCORING_FIELD_TRIAL_EXPERIMENT_GROUP;
+ use_new_scoring = true;
+ } else {
+ new_scoring_option = NEW_SCORING_FIELD_TRIAL_DEFAULT_GROUP;
+ use_new_scoring = false;
+ }
+ } else {
+ new_scoring_option = NEW_SCORING_AUTO_BUT_NOT_IN_FIELD_TRIAL;
+ use_new_scoring = false;
+ }
+ }
+
+ // Add a beacon to the logs that'll allow us to identify later what
+ // new scoring state a user is in. Do this by incrementing a bucket in
+ // a histogram, where the bucket represents the user's new scoring state.
+ UMA_HISTOGRAM_ENUMERATION(
+ "Omnibox.HistoryQuickProviderNewScoringFieldTrialBeacon",
+ new_scoring_option, NUM_OPTIONS);
+
+}
+
} // namespace history
diff --git a/chrome/browser/history/scored_history_match.h b/chrome/browser/history/scored_history_match.h
index 2644014..4ddd73b 100644
--- a/chrome/browser/history/scored_history_match.h
+++ b/chrome/browser/history/scored_history_match.h
@@ -97,6 +97,10 @@ struct ScoredHistoryMatch : public history::HistoryMatch {
static float GetPopularityScore(int typed_count,
int visit_count);
+ // Sets use_new_scoring based on command line flags and/or
+ // field trial state.
+ static void InitializeNewScoringField();
+
// End of functions used only in "new" scoring --------------------------
// An interim score taking into consideration location and completeness
@@ -127,7 +131,7 @@ struct ScoredHistoryMatch : public history::HistoryMatch {
static float* raw_term_score_to_topicality_score;
// Allows us to determing setting for use_new_scoring_ only once.
- static bool initialized;
+ static bool initialized_;
// Whether to use new-score or old-scoring. Set in the constructor
// by examining command line flags.