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 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 HistoryIDSet history_id_set; | 797 HistoryIDSet history_id_set; |
798 history_id_set.insert(history_id); | 798 history_id_set.insert(history_id); |
799 word_id_history_map_[word_id] = history_id_set; | 799 word_id_history_map_[word_id] = history_id_set; |
800 AddToHistoryIDWordMap(history_id, word_id); | 800 AddToHistoryIDWordMap(history_id, word_id); |
801 | 801 |
802 // For each character in the newly added word (i.e. a word that is not | 802 // For each character in the newly added word (i.e. a word that is not |
803 // already in the word index), add the word to the character index. | 803 // already in the word index), add the word to the character index. |
804 Char16Set characters = Char16SetFromString16(term); | 804 Char16Set characters = Char16SetFromString16(term); |
805 for (Char16Set::iterator uni_char_iter = characters.begin(); | 805 for (Char16Set::iterator uni_char_iter = characters.begin(); |
806 uni_char_iter != characters.end(); ++uni_char_iter) { | 806 uni_char_iter != characters.end(); ++uni_char_iter) { |
807 char16 uni_char = *uni_char_iter; | 807 base::char16 uni_char = *uni_char_iter; |
808 CharWordIDMap::iterator char_iter = char_word_map_.find(uni_char); | 808 CharWordIDMap::iterator char_iter = char_word_map_.find(uni_char); |
809 if (char_iter != char_word_map_.end()) { | 809 if (char_iter != char_word_map_.end()) { |
810 // Update existing entry in the char/word index. | 810 // Update existing entry in the char/word index. |
811 WordIDSet& word_id_set(char_iter->second); | 811 WordIDSet& word_id_set(char_iter->second); |
812 word_id_set.insert(word_id); | 812 word_id_set.insert(word_id); |
813 } else { | 813 } else { |
814 // Create a new entry in the char/word index. | 814 // Create a new entry in the char/word index. |
815 WordIDSet word_id_set; | 815 WordIDSet word_id_set; |
816 word_id_set.insert(word_id); | 816 word_id_set.insert(word_id); |
817 char_word_map_[uni_char] = word_id_set; | 817 char_word_map_[uni_char] = word_id_set; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 WordID word_id = *word_id_iter; | 861 WordID word_id = *word_id_iter; |
862 word_id_history_map_[word_id].erase(history_id); | 862 word_id_history_map_[word_id].erase(history_id); |
863 if (!word_id_history_map_[word_id].empty()) | 863 if (!word_id_history_map_[word_id].empty()) |
864 continue; // The word is still in use. | 864 continue; // The word is still in use. |
865 | 865 |
866 // The word is no longer in use. Reconcile any changes to character usage. | 866 // The word is no longer in use. Reconcile any changes to character usage. |
867 base::string16 word = word_list_[word_id]; | 867 base::string16 word = word_list_[word_id]; |
868 Char16Set characters = Char16SetFromString16(word); | 868 Char16Set characters = Char16SetFromString16(word); |
869 for (Char16Set::iterator uni_char_iter = characters.begin(); | 869 for (Char16Set::iterator uni_char_iter = characters.begin(); |
870 uni_char_iter != characters.end(); ++uni_char_iter) { | 870 uni_char_iter != characters.end(); ++uni_char_iter) { |
871 char16 uni_char = *uni_char_iter; | 871 base::char16 uni_char = *uni_char_iter; |
872 char_word_map_[uni_char].erase(word_id); | 872 char_word_map_[uni_char].erase(word_id); |
873 if (char_word_map_[uni_char].empty()) | 873 if (char_word_map_[uni_char].empty()) |
874 char_word_map_.erase(uni_char); // No longer in use. | 874 char_word_map_.erase(uni_char); // No longer in use. |
875 } | 875 } |
876 | 876 |
877 // Complete the removal of references to the word. | 877 // Complete the removal of references to the word. |
878 word_id_history_map_.erase(word_id); | 878 word_id_history_map_.erase(word_id); |
879 word_map_.erase(word); | 879 word_map_.erase(word); |
880 word_list_[word_id] = base::string16(); | 880 word_list_[word_id] = base::string16(); |
881 available_words_.insert(word_id); | 881 available_words_.insert(word_id); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 if (actual_item_count == 0 || actual_item_count != expected_item_count) | 1113 if (actual_item_count == 0 || actual_item_count != expected_item_count) |
1114 return false; | 1114 return false; |
1115 const RepeatedPtrField<CharWordMapEntry>& | 1115 const RepeatedPtrField<CharWordMapEntry>& |
1116 entries(list_item.char_word_map_entry()); | 1116 entries(list_item.char_word_map_entry()); |
1117 for (RepeatedPtrField<CharWordMapEntry>::const_iterator iter = | 1117 for (RepeatedPtrField<CharWordMapEntry>::const_iterator iter = |
1118 entries.begin(); iter != entries.end(); ++iter) { | 1118 entries.begin(); iter != entries.end(); ++iter) { |
1119 expected_item_count = iter->item_count(); | 1119 expected_item_count = iter->item_count(); |
1120 actual_item_count = iter->word_id_size(); | 1120 actual_item_count = iter->word_id_size(); |
1121 if (actual_item_count == 0 || actual_item_count != expected_item_count) | 1121 if (actual_item_count == 0 || actual_item_count != expected_item_count) |
1122 return false; | 1122 return false; |
1123 char16 uni_char = static_cast<char16>(iter->char_16()); | 1123 base::char16 uni_char = static_cast<base::char16>(iter->char_16()); |
1124 WordIDSet word_id_set; | 1124 WordIDSet word_id_set; |
1125 const RepeatedField<int32>& word_ids(iter->word_id()); | 1125 const RepeatedField<int32>& word_ids(iter->word_id()); |
1126 for (RepeatedField<int32>::const_iterator jiter = word_ids.begin(); | 1126 for (RepeatedField<int32>::const_iterator jiter = word_ids.begin(); |
1127 jiter != word_ids.end(); ++jiter) | 1127 jiter != word_ids.end(); ++jiter) |
1128 word_id_set.insert(*jiter); | 1128 word_id_set.insert(*jiter); |
1129 char_word_map_[uni_char] = word_id_set; | 1129 char_word_map_[uni_char] = word_id_set; |
1130 } | 1130 } |
1131 return true; | 1131 return true; |
1132 } | 1132 } |
1133 | 1133 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1332 // recently visited (within the last 12/24 hours) as highly important. Get | 1332 // recently visited (within the last 12/24 hours) as highly important. Get |
1333 // input from mpearson. | 1333 // input from mpearson. |
1334 if (r1.typed_count() != r2.typed_count()) | 1334 if (r1.typed_count() != r2.typed_count()) |
1335 return (r1.typed_count() > r2.typed_count()); | 1335 return (r1.typed_count() > r2.typed_count()); |
1336 if (r1.visit_count() != r2.visit_count()) | 1336 if (r1.visit_count() != r2.visit_count()) |
1337 return (r1.visit_count() > r2.visit_count()); | 1337 return (r1.visit_count() > r2.visit_count()); |
1338 return (r1.last_visit() > r2.last_visit()); | 1338 return (r1.last_visit() > r2.last_visit()); |
1339 } | 1339 } |
1340 | 1340 |
1341 } // namespace history | 1341 } // namespace history |
OLD | NEW |