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

Unified Diff: chrome/browser/history/scored_history_match.cc

Issue 10532149: Omnibox: Create HistoryQuickProvider new scoring field trial. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ilya's comments. Created 8 years, 6 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
Index: chrome/browser/history/scored_history_match.cc
diff --git a/chrome/browser/history/scored_history_match.cc b/chrome/browser/history/scored_history_match.cc
index 4724f5adab9087af5c8e28d3c7d24b62f3103415..8aad91e78c6ceb057fdcc39a9f89d76dd4616306 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"
@@ -42,10 +44,7 @@ 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;
+ InitializeNewScoringField();
initialized = true;
}
}
@@ -59,10 +58,7 @@ ScoredHistoryMatch::ScoredHistoryMatch(const URLRow& row,
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;
+ InitializeNewScoringField();
initialized = true;
}
@@ -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

Powered by Google App Engine
This is Rietveld 408576698