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