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

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

Issue 14330012: Omnibox: Truncate HistoryContents Searches at 10k Characters (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move to local scope. Created 7 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/history_contents_provider.cc
diff --git a/chrome/browser/autocomplete/history_contents_provider.cc b/chrome/browser/autocomplete/history_contents_provider.cc
index 190d0a3afc85bbd3186f5ca0caeda03bd8bdfa81..c18158fdd00f6d3f42ba304338839f1844ead278 100644
--- a/chrome/browser/autocomplete/history_contents_provider.cc
+++ b/chrome/browser/autocomplete/history_contents_provider.cc
@@ -25,14 +25,6 @@
using base::TimeTicks;
using history::HistoryDatabase;
-namespace {
-
-// Number of days to search for full text results. The longer this is, the more
-// time it will take.
-const int kDaysToSearch = 30;
-
-} // namespace
-
HistoryContentsProvider::MatchReference::MatchReference(
const history::URLResult* result,
int relevance)
@@ -135,11 +127,28 @@ void HistoryContentsProvider::Start(const AutocompleteInput& input,
if (history) {
done_ = false;
+ // Number of days to search for full text results. The longer
+ // this is, the more time it will take.
+ const int kDaysToSearch = 30;
+
+ // The maximum number of characters used in a search for full
+ // text results. This was chosen arbitrarily because omnibox
+ // results that come back too late (after tens of seconds)
+ // aren't useful to the user so it's not worth spending CPU time
+ // on them. Furthermore, if a URL matches the first 2k of
+ // characters the user typed (more likely pasted) into the
+ // omnibox, it's likely it matches the rest; there's strongly
+ // diminished returns for the ability to add additional search
+ // terms.
+ const size_t kMaxCharactersToConsider = 2000u;
+
history::QueryOptions options;
options.body_only = body_only_;
options.SetRecentDayRange(kDaysToSearch);
options.max_count = kMaxMatches;
- history->QueryHistory(input.text(), options,
+ history->QueryHistory(
+ input.text().substr(0, kMaxCharactersToConsider),
+ options,
&request_consumer_,
base::Bind(&HistoryContentsProvider::QueryComplete,
base::Unretained(this)));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698