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

Side by Side 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 unified diff | Download patch
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 "components/omnibox/browser/url_index_private_data.h" 5 #include "components/omnibox/browser/url_index_private_data.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <functional> 9 #include <functional>
10 #include <iterator> 10 #include <iterator>
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 if (!history_db) 390 if (!history_db)
391 return nullptr; 391 return nullptr;
392 392
393 base::TimeTicks beginning_time = base::TimeTicks::Now(); 393 base::TimeTicks beginning_time = base::TimeTicks::Now();
394 394
395 scoped_refptr<URLIndexPrivateData> 395 scoped_refptr<URLIndexPrivateData>
396 rebuilt_data(new URLIndexPrivateData); 396 rebuilt_data(new URLIndexPrivateData);
397 history::URLDatabase::URLEnumerator history_enum; 397 history::URLDatabase::URLEnumerator history_enum;
398 if (!history_db->InitURLEnumeratorForSignificant(&history_enum)) 398 if (!history_db->InitURLEnumeratorForSignificant(&history_enum))
399 return nullptr; 399 return nullptr;
400
400 rebuilt_data->last_time_rebuilt_from_history_ = base::Time::Now(); 401 rebuilt_data->last_time_rebuilt_from_history_ = base::Time::Now();
402
403 // Limiting the number of URLs indexed degrades the quality of suggestions to
404 // save memory. This limit is only applied for urls indexed at startup and
405 // more urls can be indexed during the browsing session. The primary use case
406 // is for Android devices where the session is typically short.
407 const int max_urls_indexed =
408 OmniboxFieldTrial::MaxNumHQPUrlsIndexedAtStartup();
409 int num_urls_indexed = 0;
401 for (history::URLRow row; history_enum.GetNextURL(&row);) { 410 for (history::URLRow row; history_enum.GetNextURL(&row);) {
411 // Do not use <= to account for case of -1 for unlimited urls.
sdefresne 2017/05/10 08:59:41 nit: Should this comment be "// Do not use >= to a
ssid 2017/05/10 19:47:58 Done.
412 if (num_urls_indexed++ == max_urls_indexed)
413 break;
402 rebuilt_data->IndexRow( 414 rebuilt_data->IndexRow(
403 history_db, nullptr, row, scheme_whitelist, nullptr); 415 history_db, nullptr, row, scheme_whitelist, nullptr);
404 } 416 }
405 417
406 UMA_HISTOGRAM_TIMES("History.InMemoryURLIndexingTime", 418 UMA_HISTOGRAM_TIMES("History.InMemoryURLIndexingTime",
407 base::TimeTicks::Now() - beginning_time); 419 base::TimeTicks::Now() - beginning_time);
408 UMA_HISTOGRAM_COUNTS("History.InMemoryURLHistoryItems", 420 UMA_HISTOGRAM_COUNTS("History.InMemoryURLHistoryItems",
409 rebuilt_data->history_id_word_map_.size()); 421 rebuilt_data->history_id_word_map_.size());
410 UMA_HISTOGRAM_COUNTS_10000("History.InMemoryURLWords", 422 UMA_HISTOGRAM_COUNTS_10000("History.InMemoryURLWords",
411 rebuilt_data->word_map_.size()); 423 rebuilt_data->word_map_.size());
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 // First cut: typed count, visit count, recency. 1278 // First cut: typed count, visit count, recency.
1267 // TODO(mrossetti): This is too simplistic. Consider an approach which ranks 1279 // TODO(mrossetti): This is too simplistic. Consider an approach which ranks
1268 // recently visited (within the last 12/24 hours) as highly important. Get 1280 // recently visited (within the last 12/24 hours) as highly important. Get
1269 // input from mpearson. 1281 // input from mpearson.
1270 if (r1.typed_count() != r2.typed_count()) 1282 if (r1.typed_count() != r2.typed_count())
1271 return (r1.typed_count() > r2.typed_count()); 1283 return (r1.typed_count() > r2.typed_count());
1272 if (r1.visit_count() != r2.visit_count()) 1284 if (r1.visit_count() != r2.visit_count())
1273 return (r1.visit_count() > r2.visit_count()); 1285 return (r1.visit_count() > r2.visit_count());
1274 return (r1.last_visit() > r2.last_visit()); 1286 return (r1.last_visit() > r2.last_visit());
1275 } 1287 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698