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

Unified Diff: chrome/browser/autocomplete/search_provider.cc

Issue 470313004: [AiS] Use top local result for prefetch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Score HistoryResults earlier if part of Answers FieldTrial Created 6 years, 4 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
« no previous file with comments | « chrome/browser/autocomplete/search_provider.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/search_provider.cc
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index c059c6ec2030c57e826980c33907b53beb5e7646..5fcaebc3a79f4f8687e4d82d5c8512f07bf91724 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -245,6 +245,16 @@ void SearchProvider::Start(const AutocompleteInput& input,
input_ = input;
DoHistoryQuery(minimal_changes);
+ // Answers needs the scored history results before any suggest query has been
+ // started.
+ if (OmniboxFieldTrial::EnableAnswersInSuggest()) {
groby-ooo-7-16 2014/08/22 23:09:56 Do we want a UMA histogram for the time spent here
+ scored_default_history_results_.clear();
+ scored_keyword_history_results_.clear();
+ ScoreHistoryResultsMultiWord(
+ default_history_results_, false, &scored_default_history_results_);
+ ScoreHistoryResultsMultiWord(
+ keyword_history_results_, true, &scored_keyword_history_results_);
+ }
DoAnswersQuery(input);
StartOrStopSuggestQuery(minimal_changes);
UpdateMatches();
@@ -873,35 +883,23 @@ void SearchProvider::AddHistoryResultsToMap(const HistoryResults& results,
return;
base::TimeTicks start_time(base::TimeTicks::Now());
- bool prevent_inline_autocomplete = input_.prevent_inline_autocomplete() ||
- (input_.type() == metrics::OmniboxInputType::URL);
- const base::string16& input_text =
- is_keyword ? keyword_input_.text() : input_.text();
- bool input_multiple_words = HasMultipleWords(input_text);
- SearchSuggestionParser::SuggestResults scored_results;
- if (!prevent_inline_autocomplete && input_multiple_words) {
- // ScoreHistoryResults() allows autocompletion of multi-word, 1-visit
- // queries if the input also has multiple words. But if we were already
- // scoring a multi-word, multi-visit query aggressively, and the current
- // input is still a prefix of it, then changing the suggestion suddenly
- // feels wrong. To detect this case, first score as if only one word has
- // been typed, then check if the best result came from aggressive search
- // history scoring. If it did, then just keep that score set. This
- // 1200 the lowest possible score in CalculateRelevanceForHistory()'s
- // aggressive-scoring curve.
- scored_results = ScoreHistoryResults(results, prevent_inline_autocomplete,
- false, input_text, is_keyword);
- if ((scored_results.front().relevance() < 1200) ||
- !HasMultipleWords(scored_results.front().suggestion()))
- scored_results.clear(); // Didn't detect the case above, score normally.
+ // Until Answers becomes default, scoring of history results will still happen
+ // here for non-Answers Chrome, to prevent any impact on timing measurements.
+ // Answers FieldTrials will instead use scoring results obtained previously.
+ SearchSuggestionParser::SuggestResults local_scored_results;
+ const SearchSuggestionParser::SuggestResults* scored_results = NULL;
+ if (!OmniboxFieldTrial::EnableAnswersInSuggest()) {
groby-ooo-7-16 2014/08/22 23:09:56 Since scoring can now take two different paths - s
+ ScoreHistoryResultsMultiWord(results, is_keyword, &local_scored_results);
+ scored_results = &local_scored_results;
+ } else {
+ scored_results = is_keyword ? &scored_keyword_history_results_
+ : &scored_default_history_results_;
}
- if (scored_results.empty())
- scored_results = ScoreHistoryResults(results, prevent_inline_autocomplete,
- input_multiple_words, input_text,
- is_keyword);
+ DCHECK(scored_results);
+
for (SearchSuggestionParser::SuggestResults::const_iterator i(
- scored_results.begin()); i != scored_results.end(); ++i) {
+ scored_results->begin()); i != scored_results->end(); ++i) {
AddMatchToMap(*i, std::string(), did_not_accept_suggestion, true,
providers_.GetKeywordProviderURL() != NULL, map);
}
@@ -1021,6 +1019,39 @@ SearchSuggestionParser::SuggestResults SearchProvider::ScoreHistoryResults(
return scored_results;
}
+void SearchProvider::ScoreHistoryResultsMultiWord(
+ const HistoryResults& results,
+ bool is_keyword,
+ SearchSuggestionParser::SuggestResults* scored_results) {
+ bool prevent_inline_autocomplete =
+ input_.prevent_inline_autocomplete() ||
+ (input_.type() == metrics::OmniboxInputType::URL);
+ const base::string16& input_text =
+ is_keyword ? keyword_input_.text() : input_.text();
+ bool input_multiple_words = HasMultipleWords(input_text);
+
+ if (!prevent_inline_autocomplete && input_multiple_words) {
+ // ScoreHistoryResults() allows autocompletion of multi-word, 1-visit
+ // queries if the input also has multiple words. But if we were already
+ // scoring a multi-word, multi-visit query aggressively, and the current
+ // input is still a prefix of it, then changing the suggestion suddenly
+ // feels wrong. To detect this case, first score as if only one word has
+ // been typed, then check if the best result came from aggressive search
+ // history scoring. If it did, then just keep that score set. This
+ // 1200 the lowest possible score in CalculateRelevanceForHistory()'s
+ // aggressive-scoring curve.
+ *scored_results = ScoreHistoryResults(
+ results, prevent_inline_autocomplete, false, input_text, is_keyword);
+ if ((scored_results->front().relevance() < 1200) ||
+ !HasMultipleWords(scored_results->front().suggestion()))
+ scored_results->clear(); // Didn't detect the case above, score normally.
+ }
+ if (scored_results->empty())
+ *scored_results = ScoreHistoryResults(results, prevent_inline_autocomplete,
+ input_multiple_words, input_text,
+ is_keyword);
+}
+
void SearchProvider::AddSuggestResultsToMap(
const SearchSuggestionParser::SuggestResults& results,
const std::string& metadata,
« no previous file with comments | « chrome/browser/autocomplete/search_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698