| 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 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 it = std::find_if(it, history_id_set.end(), | 707 it = std::find_if(it, history_id_set.end(), |
| 708 [this, template_url_service](const HistoryID history_id) { | 708 [this, template_url_service](const HistoryID history_id) { |
| 709 return ShouldFilter(history_id, template_url_service); | 709 return ShouldFilter(history_id, template_url_service); |
| 710 }); | 710 }); |
| 711 if (it == history_id_set.end()) | 711 if (it == history_id_set.end()) |
| 712 break; | 712 break; |
| 713 it = history_id_set.erase(it); | 713 it = history_id_set.erase(it); |
| 714 } | 714 } |
| 715 | 715 |
| 716 // Score the matches. | 716 // Score the matches. |
| 717 const size_t num_matches = history_id_set.size(); |
| 717 const base::Time now = base::Time::Now(); | 718 const base::Time now = base::Time::Now(); |
| 718 std::transform( | 719 std::transform( |
| 719 history_id_set.begin(), history_id_set.end(), | 720 history_id_set.begin(), history_id_set.end(), |
| 720 std::back_inserter(*scored_items), | 721 std::back_inserter(*scored_items), [&](const HistoryID history_id) { |
| 721 [this, &lower_raw_string, &lower_raw_terms, | |
| 722 &lower_terms_to_word_starts_offsets, &bookmark_model, | |
| 723 &now](const HistoryID history_id) { | |
| 724 auto hist_pos = history_info_map_.find(history_id); | 722 auto hist_pos = history_info_map_.find(history_id); |
| 725 const history::URLRow& hist_item = hist_pos->second.url_row; | 723 const history::URLRow& hist_item = hist_pos->second.url_row; |
| 726 auto starts_pos = word_starts_map_.find(history_id); | 724 auto starts_pos = word_starts_map_.find(history_id); |
| 727 DCHECK(starts_pos != word_starts_map_.end()); | 725 DCHECK(starts_pos != word_starts_map_.end()); |
| 728 return ScoredHistoryMatch( | 726 return ScoredHistoryMatch( |
| 729 hist_item, hist_pos->second.visits, lower_raw_string, | 727 hist_item, hist_pos->second.visits, lower_raw_string, |
| 730 lower_raw_terms, lower_terms_to_word_starts_offsets, | 728 lower_raw_terms, lower_terms_to_word_starts_offsets, |
| 731 starts_pos->second, | 729 starts_pos->second, |
| 732 bookmark_model && bookmark_model->IsBookmarked(hist_item.url()), | 730 bookmark_model && bookmark_model->IsBookmarked(hist_item.url()), |
| 733 now); | 731 num_matches, now); |
| 734 }); | 732 }); |
| 735 | 733 |
| 736 // Filter all matches that ended up scoring 0. (These are usually matches | 734 // Filter all matches that ended up scoring 0. (These are usually matches |
| 737 // which didn't match the user's raw terms.) | 735 // which didn't match the user's raw terms.) |
| 738 scored_items->erase(std::remove_if(scored_items->begin(), scored_items->end(), | 736 scored_items->erase(std::remove_if(scored_items->begin(), scored_items->end(), |
| 739 [](const ScoredHistoryMatch& match) { | 737 [](const ScoredHistoryMatch& match) { |
| 740 return match.raw_score == 0; | 738 return match.raw_score == 0; |
| 741 }), | 739 }), |
| 742 scored_items->end()); | 740 scored_items->end()); |
| 743 } | 741 } |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1382 // First cut: typed count, visit count, recency. | 1380 // First cut: typed count, visit count, recency. |
| 1383 // TODO(mrossetti): This is too simplistic. Consider an approach which ranks | 1381 // TODO(mrossetti): This is too simplistic. Consider an approach which ranks |
| 1384 // recently visited (within the last 12/24 hours) as highly important. Get | 1382 // recently visited (within the last 12/24 hours) as highly important. Get |
| 1385 // input from mpearson. | 1383 // input from mpearson. |
| 1386 if (r1.typed_count() != r2.typed_count()) | 1384 if (r1.typed_count() != r2.typed_count()) |
| 1387 return (r1.typed_count() > r2.typed_count()); | 1385 return (r1.typed_count() > r2.typed_count()); |
| 1388 if (r1.visit_count() != r2.visit_count()) | 1386 if (r1.visit_count() != r2.visit_count()) |
| 1389 return (r1.visit_count() > r2.visit_count()); | 1387 return (r1.visit_count() > r2.visit_count()); |
| 1390 return (r1.last_visit() > r2.last_visit()); | 1388 return (r1.last_visit() > r2.last_visit()); |
| 1391 } | 1389 } |
| OLD | NEW |