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), |
721 [this, &lower_raw_string, &lower_raw_terms, | 722 [this, &lower_raw_string, &lower_raw_terms, |
722 &lower_terms_to_word_starts_offsets, &bookmark_model, | 723 &lower_terms_to_word_starts_offsets, &bookmark_model, &num_matches, |
723 &now](const HistoryID history_id) { | 724 &now](const HistoryID history_id) { |
Peter Kasting
2016/12/01 07:07:53
Nit: Bleh, I'm inclined to replace this huge list
Mark P
2016/12/04 01:06:42
Done.
| |
724 auto hist_pos = history_info_map_.find(history_id); | 725 auto hist_pos = history_info_map_.find(history_id); |
725 const history::URLRow& hist_item = hist_pos->second.url_row; | 726 const history::URLRow& hist_item = hist_pos->second.url_row; |
726 auto starts_pos = word_starts_map_.find(history_id); | 727 auto starts_pos = word_starts_map_.find(history_id); |
727 DCHECK(starts_pos != word_starts_map_.end()); | 728 DCHECK(starts_pos != word_starts_map_.end()); |
728 return ScoredHistoryMatch( | 729 return ScoredHistoryMatch( |
729 hist_item, hist_pos->second.visits, lower_raw_string, | 730 hist_item, hist_pos->second.visits, lower_raw_string, |
730 lower_raw_terms, lower_terms_to_word_starts_offsets, | 731 lower_raw_terms, lower_terms_to_word_starts_offsets, |
731 starts_pos->second, | 732 starts_pos->second, |
732 bookmark_model && bookmark_model->IsBookmarked(hist_item.url()), | 733 bookmark_model && bookmark_model->IsBookmarked(hist_item.url()), |
733 now); | 734 num_matches, now); |
734 }); | 735 }); |
735 | 736 |
736 // Filter all matches that ended up scoring 0. (These are usually matches | 737 // Filter all matches that ended up scoring 0. (These are usually matches |
737 // which didn't match the user's raw terms.) | 738 // which didn't match the user's raw terms.) |
738 scored_items->erase(std::remove_if(scored_items->begin(), scored_items->end(), | 739 scored_items->erase(std::remove_if(scored_items->begin(), scored_items->end(), |
739 [](const ScoredHistoryMatch& match) { | 740 [](const ScoredHistoryMatch& match) { |
740 return match.raw_score == 0; | 741 return match.raw_score == 0; |
741 }), | 742 }), |
742 scored_items->end()); | 743 scored_items->end()); |
743 } | 744 } |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1382 // First cut: typed count, visit count, recency. | 1383 // First cut: typed count, visit count, recency. |
1383 // TODO(mrossetti): This is too simplistic. Consider an approach which ranks | 1384 // TODO(mrossetti): This is too simplistic. Consider an approach which ranks |
1384 // recently visited (within the last 12/24 hours) as highly important. Get | 1385 // recently visited (within the last 12/24 hours) as highly important. Get |
1385 // input from mpearson. | 1386 // input from mpearson. |
1386 if (r1.typed_count() != r2.typed_count()) | 1387 if (r1.typed_count() != r2.typed_count()) |
1387 return (r1.typed_count() > r2.typed_count()); | 1388 return (r1.typed_count() > r2.typed_count()); |
1388 if (r1.visit_count() != r2.visit_count()) | 1389 if (r1.visit_count() != r2.visit_count()) |
1389 return (r1.visit_count() > r2.visit_count()); | 1390 return (r1.visit_count() > r2.visit_count()); |
1390 return (r1.last_visit() > r2.last_visit()); | 1391 return (r1.last_visit() > r2.last_visit()); |
1391 } | 1392 } |
OLD | NEW |