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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 if (pre_filter_item_count_ > post_filter_item_count_) { | 246 if (pre_filter_item_count_ > post_filter_item_count_) { |
247 // If we trim the results set we do not want to cache the results for next | 247 // If we trim the results set we do not want to cache the results for next |
248 // time as the user's ultimately desired result could easily be eliminated | 248 // time as the user's ultimately desired result could easily be eliminated |
249 // in the early rough filter. | 249 // in the early rough filter. |
250 search_term_cache_.clear(); | 250 search_term_cache_.clear(); |
251 } else { | 251 } else { |
252 // Remove any stale SearchTermCacheItems. | 252 // Remove any stale SearchTermCacheItems. |
253 for (SearchTermCacheMap::iterator cache_iter = search_term_cache_.begin(); | 253 for (SearchTermCacheMap::iterator cache_iter = search_term_cache_.begin(); |
254 cache_iter != search_term_cache_.end(); ) { | 254 cache_iter != search_term_cache_.end(); ) { |
255 if (!cache_iter->second.used_) | 255 if (!cache_iter->second.used_) |
256 search_term_cache_.erase(cache_iter++); | 256 cache_iter = search_term_cache_.erase(cache_iter); |
257 else | 257 else |
258 ++cache_iter; | 258 ++cache_iter; |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 return scored_items; | 262 return scored_items; |
263 } | 263 } |
264 | 264 |
265 bool URLIndexPrivateData::UpdateURL( | 265 bool URLIndexPrivateData::UpdateURL( |
266 history::HistoryService* history_service, | 266 history::HistoryService* history_service, |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
490 word_id_history_map_.clear(); | 490 word_id_history_map_.clear(); |
491 history_id_word_map_.clear(); | 491 history_id_word_map_.clear(); |
492 history_info_map_.clear(); | 492 history_info_map_.clear(); |
493 word_starts_map_.clear(); | 493 word_starts_map_.clear(); |
494 } | 494 } |
495 | 495 |
496 URLIndexPrivateData::~URLIndexPrivateData() {} | 496 URLIndexPrivateData::~URLIndexPrivateData() {} |
497 | 497 |
498 HistoryIDSet URLIndexPrivateData::HistoryIDSetFromWords( | 498 HistoryIDSet URLIndexPrivateData::HistoryIDSetFromWords( |
499 const String16Vector& unsorted_words) { | 499 const String16Vector& unsorted_words) { |
500 SCOPED_UMA_HISTOGRAM_TIMER("Omnibox.HistoryIDSetFromWords"); | |
Peter Kasting
2016/11/30 21:39:50
Double-checking: the existing omnibox provider tim
| |
500 // Break the terms down into individual terms (words), get the candidate | 501 // Break the terms down into individual terms (words), get the candidate |
501 // set for each term, and intersect each to get a final candidate list. | 502 // set for each term, and intersect each to get a final candidate list. |
502 // Note that a single 'term' from the user's perspective might be | 503 // Note that a single 'term' from the user's perspective might be |
503 // a string like "http://www.somewebsite.com" which, from our perspective, | 504 // a string like "http://www.somewebsite.com" which, from our perspective, |
504 // is four words: 'http', 'www', 'somewebsite', and 'com'. | 505 // is four words: 'http', 'www', 'somewebsite', and 'com'. |
505 HistoryIDSet history_id_set; | 506 HistoryIDSet history_id_set; |
506 String16Vector words(unsorted_words); | 507 String16Vector words(unsorted_words); |
507 // Sort the words into the longest first as such are likely to narrow down | 508 // Sort the words into the longest first as such are likely to narrow down |
508 // the results quicker. Also, single character words are the most expensive | 509 // the results quicker. Also, single character words are the most expensive |
509 // to process so save them for last. | 510 // to process so save them for last. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
598 word_id_set, leftover_set); | 599 word_id_set, leftover_set); |
599 word_id_set.swap(new_word_id_set); | 600 word_id_set.swap(new_word_id_set); |
600 } | 601 } |
601 } | 602 } |
602 | 603 |
603 // We must filter the word list because the resulting word set surely | 604 // We must filter the word list because the resulting word set surely |
604 // contains words which do not have the search term as a proper subset. | 605 // contains words which do not have the search term as a proper subset. |
605 for (WordIDSet::iterator word_set_iter = word_id_set.begin(); | 606 for (WordIDSet::iterator word_set_iter = word_id_set.begin(); |
606 word_set_iter != word_id_set.end(); ) { | 607 word_set_iter != word_id_set.end(); ) { |
607 if (word_list_[*word_set_iter].find(term) == base::string16::npos) | 608 if (word_list_[*word_set_iter].find(term) == base::string16::npos) |
608 word_id_set.erase(word_set_iter++); | 609 word_set_iter = word_id_set.erase(word_set_iter); |
609 else | 610 else |
610 ++word_set_iter; | 611 ++word_set_iter; |
611 } | 612 } |
612 } else { | 613 } else { |
613 word_id_set = WordIDSetForTermChars(Char16SetFromString16(term)); | 614 word_id_set = WordIDSetForTermChars(Char16SetFromString16(term)); |
614 } | 615 } |
615 | 616 |
616 // If any words resulted then we can compose a set of history IDs by unioning | 617 // If any words resulted then we can compose a set of history IDs by unioning |
617 // the sets from each word. | 618 // the sets from each word. |
618 HistoryIDSet history_id_set; | 619 HistoryIDSet history_id_set; |
(...skipping 763 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 |