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

Side by Side 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: revise comment 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/autocomplete/history_contents_provider.h" 5 #include "chrome/browser/autocomplete/history_contents_provider.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 13 matching lines...) Expand all
24 24
25 using base::TimeTicks; 25 using base::TimeTicks;
26 using history::HistoryDatabase; 26 using history::HistoryDatabase;
27 27
28 namespace { 28 namespace {
29 29
30 // Number of days to search for full text results. The longer this is, the more 30 // Number of days to search for full text results. The longer this is, the more
31 // time it will take. 31 // time it will take.
32 const int kDaysToSearch = 30; 32 const int kDaysToSearch = 30;
33 33
34 // The maximum number of characters used in a search for full text results.
35 // This was chosen arbitrarily because omnibox results that come back too
36 // late (after tens of seconds) aren't useful to the user so it's not
37 // worth spending CPU time on them. Furthermore, if a URL matches the
38 // first 2k of characters the user typed (more likely pasted) into the
39 // omnibox, it's likely it matches the rest; there's strongly diminished
40 // returns for the ability to add additional search terms.
41 const size_t kMaxCharactersToConsider = 2000u;
Peter Kasting 2013/04/17 22:59:45 Nit: Since this is only used in one function I sug
Mark P 2013/04/17 23:06:48 I kind of like having parameters called out somewh
Peter Kasting 2013/04/17 23:09:01 I don't care strongly. I always read the style gu
Mark P 2013/04/17 23:13:28 Okay, done.
42
34 } // namespace 43 } // namespace
35 44
36 HistoryContentsProvider::MatchReference::MatchReference( 45 HistoryContentsProvider::MatchReference::MatchReference(
37 const history::URLResult* result, 46 const history::URLResult* result,
38 int relevance) 47 int relevance)
39 : result(result), 48 : result(result),
40 relevance(relevance) { 49 relevance(relevance) {
41 } 50 }
42 51
43 // static 52 // static
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 HistoryService* history = 141 HistoryService* history =
133 HistoryServiceFactory::GetForProfile(profile_, 142 HistoryServiceFactory::GetForProfile(profile_,
134 Profile::EXPLICIT_ACCESS); 143 Profile::EXPLICIT_ACCESS);
135 if (history) { 144 if (history) {
136 done_ = false; 145 done_ = false;
137 146
138 history::QueryOptions options; 147 history::QueryOptions options;
139 options.body_only = body_only_; 148 options.body_only = body_only_;
140 options.SetRecentDayRange(kDaysToSearch); 149 options.SetRecentDayRange(kDaysToSearch);
141 options.max_count = kMaxMatches; 150 options.max_count = kMaxMatches;
142 history->QueryHistory(input.text(), options, 151 history->QueryHistory(
152 input.text().substr(0, kMaxCharactersToConsider),
153 options,
143 &request_consumer_, 154 &request_consumer_,
144 base::Bind(&HistoryContentsProvider::QueryComplete, 155 base::Bind(&HistoryContentsProvider::QueryComplete,
145 base::Unretained(this))); 156 base::Unretained(this)));
146 } 157 }
147 } 158 }
148 } 159 }
149 160
150 void HistoryContentsProvider::Stop(bool clear_cached_results) { 161 void HistoryContentsProvider::Stop(bool clear_cached_results) {
151 done_ = true; 162 done_ = true;
152 request_consumer_.CancelAllRequests(); 163 request_consumer_.CancelAllRequests();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 276
266 int HistoryContentsProvider::CalculateRelevance( 277 int HistoryContentsProvider::CalculateRelevance(
267 const history::URLResult& result) { 278 const history::URLResult& result) {
268 const bool in_title = MatchInTitle(result); 279 const bool in_title = MatchInTitle(result);
269 BookmarkModel* bm_model = BookmarkModelFactory::GetForProfile(profile_); 280 BookmarkModel* bm_model = BookmarkModelFactory::GetForProfile(profile_);
270 if (!bm_model || !bm_model->IsBookmarked(result.url())) 281 if (!bm_model || !bm_model->IsBookmarked(result.url()))
271 return in_title ? (700 + title_count_++) : (500 + contents_count_++); 282 return in_title ? (700 + title_count_++) : (500 + contents_count_++);
272 return in_title ? 283 return in_title ?
273 (1000 + star_title_count_++) : (550 + star_contents_count_++); 284 (1000 + star_title_count_++) : (550 + star_contents_count_++);
274 } 285 }
OLDNEW
« 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