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

Unified Diff: components/omnibox/browser/url_index_private_data.cc

Issue 2864103003: Limit the number of history urls indexed for omnibox suggestions. (Closed)
Patch Set: Address comments. Created 3 years, 7 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 | « components/omnibox/browser/omnibox_field_trial.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/omnibox/browser/url_index_private_data.cc
diff --git a/components/omnibox/browser/url_index_private_data.cc b/components/omnibox/browser/url_index_private_data.cc
index b9f2a93ea945bc2e73e33afdb396d0bd0ef8a975..e239598c482aac7e9fd38c2fcbcc57d8d53e8251 100644
--- a/components/omnibox/browser/url_index_private_data.cc
+++ b/components/omnibox/browser/url_index_private_data.cc
@@ -397,8 +397,20 @@ scoped_refptr<URLIndexPrivateData> URLIndexPrivateData::RebuildFromHistory(
history::URLDatabase::URLEnumerator history_enum;
if (!history_db->InitURLEnumeratorForSignificant(&history_enum))
return nullptr;
+
rebuilt_data->last_time_rebuilt_from_history_ = base::Time::Now();
+
+ // Limiting the number of URLs indexed degrades the quality of suggestions to
+ // save memory. This limit is only applied for urls indexed at startup and
+ // more urls can be indexed during the browsing session. The primary use case
+ // is for Android devices where the session is typically short.
+ const int max_urls_indexed =
+ OmniboxFieldTrial::MaxNumHQPUrlsIndexedAtStartup();
+ int num_urls_indexed = 0;
for (history::URLRow row; history_enum.GetNextURL(&row);) {
+ // Do not use >= to account for case of -1 for unlimited urls.
+ if (num_urls_indexed++ == max_urls_indexed)
+ break;
rebuilt_data->IndexRow(
history_db, nullptr, row, scheme_whitelist, nullptr);
}
« no previous file with comments | « components/omnibox/browser/omnibox_field_trial.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698