summaryrefslogtreecommitdiffstats
path: root/chrome/browser/history
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 /chrome/browser/history
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
Diffstat (limited to 'chrome/browser/history')
-rw-r--r--chrome/browser/history/scored_history_match.cc82
-rw-r--r--chrome/browser/history/scored_history_match.h6
2 files changed, 74 insertions, 14 deletions
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.