Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // Limit the nuber of URLs indexed on low end devices. This would degrade the | |
|
Mark P
2017/05/07 21:32:38
nit: would degrade -> degrades
| |
| 404 // quality of suggestions to save memory. | |
| 405 int max_history_urls_indexed = -1; // unlimited | |
| 406 if (base::SysInfo::IsLowEndDevice()) { | |
| 407 std::string limit = | |
| 408 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
| 409 switches::kLimitHistoryUrlIndexingForOmnibox); | |
| 410 if (!limit.empty() && !base::StringToInt(limit, &max_history_urls_indexed)) | |
| 411 max_history_urls_indexed = -1; | |
| 412 } | |
| 413 | |
| 414 int num_urls_indexed = 0; | |
| 401 for (history::URLRow row; history_enum.GetNextURL(&row);) { | 415 for (history::URLRow row; history_enum.GetNextURL(&row);) { |
| 416 if (++num_urls_indexed == max_history_urls_indexed) | |
| 417 break; | |
| 402 rebuilt_data->IndexRow( | 418 rebuilt_data->IndexRow( |
| 403 history_db, nullptr, row, scheme_whitelist, nullptr); | 419 history_db, nullptr, row, scheme_whitelist, nullptr); |
| 404 } | 420 } |
| 405 | 421 |
| 406 UMA_HISTOGRAM_TIMES("History.InMemoryURLIndexingTime", | 422 UMA_HISTOGRAM_TIMES("History.InMemoryURLIndexingTime", |
| 407 base::TimeTicks::Now() - beginning_time); | 423 base::TimeTicks::Now() - beginning_time); |
| 408 UMA_HISTOGRAM_COUNTS("History.InMemoryURLHistoryItems", | 424 UMA_HISTOGRAM_COUNTS("History.InMemoryURLHistoryItems", |
| 409 rebuilt_data->history_id_word_map_.size()); | 425 rebuilt_data->history_id_word_map_.size()); |
| 410 UMA_HISTOGRAM_COUNTS_10000("History.InMemoryURLWords", | 426 UMA_HISTOGRAM_COUNTS_10000("History.InMemoryURLWords", |
| 411 rebuilt_data->word_map_.size()); | 427 rebuilt_data->word_map_.size()); |
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1266 // First cut: typed count, visit count, recency. | 1282 // First cut: typed count, visit count, recency. |
| 1267 // TODO(mrossetti): This is too simplistic. Consider an approach which ranks | 1283 // TODO(mrossetti): This is too simplistic. Consider an approach which ranks |
| 1268 // recently visited (within the last 12/24 hours) as highly important. Get | 1284 // recently visited (within the last 12/24 hours) as highly important. Get |
| 1269 // input from mpearson. | 1285 // input from mpearson. |
| 1270 if (r1.typed_count() != r2.typed_count()) | 1286 if (r1.typed_count() != r2.typed_count()) |
| 1271 return (r1.typed_count() > r2.typed_count()); | 1287 return (r1.typed_count() > r2.typed_count()); |
| 1272 if (r1.visit_count() != r2.visit_count()) | 1288 if (r1.visit_count() != r2.visit_count()) |
| 1273 return (r1.visit_count() > r2.visit_count()); | 1289 return (r1.visit_count() > r2.visit_count()); |
| 1274 return (r1.last_visit() > r2.last_visit()); | 1290 return (r1.last_visit() > r2.last_visit()); |
| 1275 } | 1291 } |
| OLD | NEW |