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); |
} |