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/autocomplete/url_index_private_data.h" | 5 #include "chrome/browser/autocomplete/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 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1282 // Calculate offsets for each term. For instance, the offset for | 1282 // Calculate offsets for each term. For instance, the offset for |
1283 // ".net" should be 1, indicating that the actual word-part of the term | 1283 // ".net" should be 1, indicating that the actual word-part of the term |
1284 // starts at offset 1. | 1284 // starts at offset 1. |
1285 lower_terms_to_word_starts_offsets_.resize(lower_terms_.size(), 0u); | 1285 lower_terms_to_word_starts_offsets_.resize(lower_terms_.size(), 0u); |
1286 for (size_t i = 0; i < lower_terms_.size(); ++i) { | 1286 for (size_t i = 0; i < lower_terms_.size(); ++i) { |
1287 base::i18n::BreakIterator iter(lower_terms_[i], | 1287 base::i18n::BreakIterator iter(lower_terms_[i], |
1288 base::i18n::BreakIterator::BREAK_WORD); | 1288 base::i18n::BreakIterator::BREAK_WORD); |
1289 // If the iterator doesn't work, assume an offset of 0. | 1289 // If the iterator doesn't work, assume an offset of 0. |
1290 if (!iter.Init()) | 1290 if (!iter.Init()) |
1291 continue; | 1291 continue; |
1292 // Find the first word start. | 1292 // Find the first word start. If the iterator didn't find a word break, set |
1293 // an offset of term size. For an instance, the offset for "://" should be | |
Mark P
2015/06/08 18:13:16
nit: For an instance -> For example
Pritam Nikam
2015/06/09 10:03:53
Done.
| |
1294 // 3, indicating that the word-part is missing. | |
1293 while (iter.Advance() && !iter.IsWord()) {} | 1295 while (iter.Advance() && !iter.IsWord()) {} |
1294 if (iter.IsWord()) | 1296 |
1295 lower_terms_to_word_starts_offsets_[i] = iter.prev(); | 1297 lower_terms_to_word_starts_offsets_[i] = iter.prev(); |
1296 // Else: the iterator didn't find a word break. Assume an offset of 0. | |
1297 } | 1298 } |
1298 } | 1299 } |
1299 | 1300 |
1300 URLIndexPrivateData::AddHistoryMatch::~AddHistoryMatch() { | 1301 URLIndexPrivateData::AddHistoryMatch::~AddHistoryMatch() { |
1301 } | 1302 } |
1302 | 1303 |
1303 void URLIndexPrivateData::AddHistoryMatch::operator()( | 1304 void URLIndexPrivateData::AddHistoryMatch::operator()( |
1304 const HistoryID history_id) { | 1305 const HistoryID history_id) { |
1305 HistoryInfoMap::const_iterator hist_pos = | 1306 HistoryInfoMap::const_iterator hist_pos = |
1306 private_data_.history_info_map_.find(history_id); | 1307 private_data_.history_info_map_.find(history_id); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1345 // First cut: typed count, visit count, recency. | 1346 // First cut: typed count, visit count, recency. |
1346 // TODO(mrossetti): This is too simplistic. Consider an approach which ranks | 1347 // TODO(mrossetti): This is too simplistic. Consider an approach which ranks |
1347 // recently visited (within the last 12/24 hours) as highly important. Get | 1348 // recently visited (within the last 12/24 hours) as highly important. Get |
1348 // input from mpearson. | 1349 // input from mpearson. |
1349 if (r1.typed_count() != r2.typed_count()) | 1350 if (r1.typed_count() != r2.typed_count()) |
1350 return (r1.typed_count() > r2.typed_count()); | 1351 return (r1.typed_count() > r2.typed_count()); |
1351 if (r1.visit_count() != r2.visit_count()) | 1352 if (r1.visit_count() != r2.visit_count()) |
1352 return (r1.visit_count() > r2.visit_count()); | 1353 return (r1.visit_count() > r2.visit_count()); |
1353 return (r1.last_visit() > r2.last_visit()); | 1354 return (r1.last_visit() > r2.last_visit()); |
1354 } | 1355 } |
OLD | NEW |