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 "chrome/browser/history/url_index_private_data.h" | 5 #include "chrome/browser/history/url_index_private_data.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <iterator> | 9 #include <iterator> |
10 #include <limits> | 10 #include <limits> |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 return true; | 751 return true; |
752 } | 752 } |
753 | 753 |
754 void URLIndexPrivateData::AddRowWordsToIndex(const URLRow& row, | 754 void URLIndexPrivateData::AddRowWordsToIndex(const URLRow& row, |
755 RowWordStarts* word_starts, | 755 RowWordStarts* word_starts, |
756 const std::string& languages) { | 756 const std::string& languages) { |
757 HistoryID history_id = static_cast<HistoryID>(row.id()); | 757 HistoryID history_id = static_cast<HistoryID>(row.id()); |
758 // Split URL into individual, unique words then add in the title words. | 758 // Split URL into individual, unique words then add in the title words. |
759 const GURL& gurl(row.url()); | 759 const GURL& gurl(row.url()); |
760 const base::string16& url = | 760 const base::string16& url = |
761 bookmark_utils::CleanUpUrlForMatching(gurl, languages); | 761 bookmark_utils::CleanUpUrlForMatching(gurl, languages, NULL); |
762 String16Set url_words = String16SetFromString16(url, | 762 String16Set url_words = String16SetFromString16(url, |
763 word_starts ? &word_starts->url_word_starts_ : NULL); | 763 word_starts ? &word_starts->url_word_starts_ : NULL); |
764 const base::string16& title = | 764 const base::string16& title = |
765 bookmark_utils::CleanUpTitleForMatching(row.title()); | 765 bookmark_utils::CleanUpTitleForMatching(row.title()); |
766 String16Set title_words = String16SetFromString16(title, | 766 String16Set title_words = String16SetFromString16(title, |
767 word_starts ? &word_starts->title_word_starts_ : NULL); | 767 word_starts ? &word_starts->title_word_starts_ : NULL); |
768 String16Set words; | 768 String16Set words; |
769 std::set_union(url_words.begin(), url_words.end(), | 769 std::set_union(url_words.begin(), url_words.end(), |
770 title_words.begin(), title_words.end(), | 770 title_words.begin(), title_words.end(), |
771 std::insert_iterator<String16Set>(words, words.begin())); | 771 std::insert_iterator<String16Set>(words, words.begin())); |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 word_starts.title_word_starts_.push_back(*jiter); | 1233 word_starts.title_word_starts_.push_back(*jiter); |
1234 word_starts_map_[history_id] = word_starts; | 1234 word_starts_map_[history_id] = word_starts; |
1235 } | 1235 } |
1236 } else { | 1236 } else { |
1237 // Since the cache did not contain any word starts we must rebuild then from | 1237 // Since the cache did not contain any word starts we must rebuild then from |
1238 // the URL and page titles. | 1238 // the URL and page titles. |
1239 for (HistoryInfoMap::const_iterator iter = history_info_map_.begin(); | 1239 for (HistoryInfoMap::const_iterator iter = history_info_map_.begin(); |
1240 iter != history_info_map_.end(); ++iter) { | 1240 iter != history_info_map_.end(); ++iter) { |
1241 RowWordStarts word_starts; | 1241 RowWordStarts word_starts; |
1242 const URLRow& row(iter->second.url_row); | 1242 const URLRow& row(iter->second.url_row); |
1243 const base::string16& url = | 1243 const base::string16& url = bookmark_utils::CleanUpUrlForMatching( |
1244 bookmark_utils::CleanUpUrlForMatching(row.url(), languages); | 1244 row.url(), languages, NULL); |
1245 String16VectorFromString16(url, false, &word_starts.url_word_starts_); | 1245 String16VectorFromString16(url, false, &word_starts.url_word_starts_); |
1246 const base::string16& title = | 1246 const base::string16& title = |
1247 bookmark_utils::CleanUpTitleForMatching(row.title()); | 1247 bookmark_utils::CleanUpTitleForMatching(row.title()); |
1248 String16VectorFromString16(title, false, &word_starts.title_word_starts_); | 1248 String16VectorFromString16(title, false, &word_starts.title_word_starts_); |
1249 word_starts_map_[iter->first] = word_starts; | 1249 word_starts_map_[iter->first] = word_starts; |
1250 } | 1250 } |
1251 } | 1251 } |
1252 return true; | 1252 return true; |
1253 } | 1253 } |
1254 | 1254 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 // recently visited (within the last 12/24 hours) as highly important. Get | 1354 // recently visited (within the last 12/24 hours) as highly important. Get |
1355 // input from mpearson. | 1355 // input from mpearson. |
1356 if (r1.typed_count() != r2.typed_count()) | 1356 if (r1.typed_count() != r2.typed_count()) |
1357 return (r1.typed_count() > r2.typed_count()); | 1357 return (r1.typed_count() > r2.typed_count()); |
1358 if (r1.visit_count() != r2.visit_count()) | 1358 if (r1.visit_count() != r2.visit_count()) |
1359 return (r1.visit_count() > r2.visit_count()); | 1359 return (r1.visit_count() > r2.visit_count()); |
1360 return (r1.last_visit() > r2.last_visit()); | 1360 return (r1.last_visit() > r2.last_visit()); |
1361 } | 1361 } |
1362 | 1362 |
1363 } // namespace history | 1363 } // namespace history |
OLD | NEW |