| 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 <functional> | 7 #include <functional> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <numeric> | 10 #include <numeric> |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 return true; | 741 return true; |
| 742 } | 742 } |
| 743 | 743 |
| 744 void URLIndexPrivateData::AddRowWordsToIndex(const URLRow& row, | 744 void URLIndexPrivateData::AddRowWordsToIndex(const URLRow& row, |
| 745 RowWordStarts* word_starts, | 745 RowWordStarts* word_starts, |
| 746 const std::string& languages) { | 746 const std::string& languages) { |
| 747 HistoryID history_id = static_cast<HistoryID>(row.id()); | 747 HistoryID history_id = static_cast<HistoryID>(row.id()); |
| 748 // Split URL into individual, unique words then add in the title words. | 748 // Split URL into individual, unique words then add in the title words. |
| 749 const GURL& gurl(row.url()); | 749 const GURL& gurl(row.url()); |
| 750 const base::string16& url = | 750 const base::string16& url = |
| 751 bookmark_utils::CleanUpUrlForMatching(gurl, languages, NULL); | 751 bookmarks::CleanUpUrlForMatching(gurl, languages, NULL); |
| 752 String16Set url_words = String16SetFromString16(url, | 752 String16Set url_words = String16SetFromString16(url, |
| 753 word_starts ? &word_starts->url_word_starts_ : NULL); | 753 word_starts ? &word_starts->url_word_starts_ : NULL); |
| 754 const base::string16& title = | 754 const base::string16& title = bookmarks::CleanUpTitleForMatching(row.title()); |
| 755 bookmark_utils::CleanUpTitleForMatching(row.title()); | |
| 756 String16Set title_words = String16SetFromString16(title, | 755 String16Set title_words = String16SetFromString16(title, |
| 757 word_starts ? &word_starts->title_word_starts_ : NULL); | 756 word_starts ? &word_starts->title_word_starts_ : NULL); |
| 758 String16Set words = base::STLSetUnion<String16Set>(url_words, title_words); | 757 String16Set words = base::STLSetUnion<String16Set>(url_words, title_words); |
| 759 for (String16Set::iterator word_iter = words.begin(); | 758 for (String16Set::iterator word_iter = words.begin(); |
| 760 word_iter != words.end(); ++word_iter) | 759 word_iter != words.end(); ++word_iter) |
| 761 AddWordToIndex(*word_iter, history_id); | 760 AddWordToIndex(*word_iter, history_id); |
| 762 | 761 |
| 763 search_term_cache_.clear(); // Invalidate the term cache. | 762 search_term_cache_.clear(); // Invalidate the term cache. |
| 764 } | 763 } |
| 765 | 764 |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 word_starts.title_word_starts_.push_back(*jiter); | 1219 word_starts.title_word_starts_.push_back(*jiter); |
| 1221 word_starts_map_[history_id] = word_starts; | 1220 word_starts_map_[history_id] = word_starts; |
| 1222 } | 1221 } |
| 1223 } else { | 1222 } else { |
| 1224 // Since the cache did not contain any word starts we must rebuild then from | 1223 // Since the cache did not contain any word starts we must rebuild then from |
| 1225 // the URL and page titles. | 1224 // the URL and page titles. |
| 1226 for (HistoryInfoMap::const_iterator iter = history_info_map_.begin(); | 1225 for (HistoryInfoMap::const_iterator iter = history_info_map_.begin(); |
| 1227 iter != history_info_map_.end(); ++iter) { | 1226 iter != history_info_map_.end(); ++iter) { |
| 1228 RowWordStarts word_starts; | 1227 RowWordStarts word_starts; |
| 1229 const URLRow& row(iter->second.url_row); | 1228 const URLRow& row(iter->second.url_row); |
| 1230 const base::string16& url = bookmark_utils::CleanUpUrlForMatching( | 1229 const base::string16& url = |
| 1231 row.url(), languages, NULL); | 1230 bookmarks::CleanUpUrlForMatching(row.url(), languages, NULL); |
| 1232 String16VectorFromString16(url, false, &word_starts.url_word_starts_); | 1231 String16VectorFromString16(url, false, &word_starts.url_word_starts_); |
| 1233 const base::string16& title = | 1232 const base::string16& title = |
| 1234 bookmark_utils::CleanUpTitleForMatching(row.title()); | 1233 bookmarks::CleanUpTitleForMatching(row.title()); |
| 1235 String16VectorFromString16(title, false, &word_starts.title_word_starts_); | 1234 String16VectorFromString16(title, false, &word_starts.title_word_starts_); |
| 1236 word_starts_map_[iter->first] = word_starts; | 1235 word_starts_map_[iter->first] = word_starts; |
| 1237 } | 1236 } |
| 1238 } | 1237 } |
| 1239 return true; | 1238 return true; |
| 1240 } | 1239 } |
| 1241 | 1240 |
| 1242 // static | 1241 // static |
| 1243 bool URLIndexPrivateData::URLSchemeIsWhitelisted( | 1242 bool URLIndexPrivateData::URLSchemeIsWhitelisted( |
| 1244 const GURL& gurl, | 1243 const GURL& gurl, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1341 // recently visited (within the last 12/24 hours) as highly important. Get | 1340 // recently visited (within the last 12/24 hours) as highly important. Get |
| 1342 // input from mpearson. | 1341 // input from mpearson. |
| 1343 if (r1.typed_count() != r2.typed_count()) | 1342 if (r1.typed_count() != r2.typed_count()) |
| 1344 return (r1.typed_count() > r2.typed_count()); | 1343 return (r1.typed_count() > r2.typed_count()); |
| 1345 if (r1.visit_count() != r2.visit_count()) | 1344 if (r1.visit_count() != r2.visit_count()) |
| 1346 return (r1.visit_count() > r2.visit_count()); | 1345 return (r1.visit_count() > r2.visit_count()); |
| 1347 return (r1.last_visit() > r2.last_visit()); | 1346 return (r1.last_visit() > r2.last_visit()); |
| 1348 } | 1347 } |
| 1349 | 1348 |
| 1350 } // namespace history | 1349 } // namespace history |
| OLD | NEW |