| 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/scored_history_match.h" | 5 #include "components/omnibox/browser/scored_history_match.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 // Now that we're done processing this entry, correct the offsets of the | 313 // Now that we're done processing this entry, correct the offsets of the |
| 314 // matches in |url_matches| so they point to offsets in the original URL | 314 // matches in |url_matches| so they point to offsets in the original URL |
| 315 // spec, not the cleaned-up URL string that we used for matching. | 315 // spec, not the cleaned-up URL string that we used for matching. |
| 316 std::vector<size_t> offsets = OffsetsFromTermMatches(url_matches); | 316 std::vector<size_t> offsets = OffsetsFromTermMatches(url_matches); |
| 317 base::OffsetAdjuster::UnadjustOffsets(adjustments, &offsets); | 317 base::OffsetAdjuster::UnadjustOffsets(adjustments, &offsets); |
| 318 url_matches = ReplaceOffsetsInTermMatches(url_matches, offsets); | 318 url_matches = ReplaceOffsetsInTermMatches(url_matches, offsets); |
| 319 } | 319 } |
| 320 | 320 |
| 321 ScoredHistoryMatch::ScoredHistoryMatch(const ScoredHistoryMatch& other) = | 321 ScoredHistoryMatch::ScoredHistoryMatch(const ScoredHistoryMatch& other) = |
| 322 default; | 322 default; |
| 323 | 323 ScoredHistoryMatch::ScoredHistoryMatch(ScoredHistoryMatch&& other) = default; |
| 324 ScoredHistoryMatch::~ScoredHistoryMatch() { | 324 ScoredHistoryMatch& ScoredHistoryMatch::operator=( |
| 325 } | 325 const ScoredHistoryMatch& other) = default; |
| 326 ScoredHistoryMatch& ScoredHistoryMatch::operator=(ScoredHistoryMatch&& other) = |
| 327 default; |
| 328 ScoredHistoryMatch::~ScoredHistoryMatch() = default; |
| 326 | 329 |
| 327 // Comparison function for sorting ScoredMatches by their scores with | 330 // Comparison function for sorting ScoredMatches by their scores with |
| 328 // intelligent tie-breaking. | 331 // intelligent tie-breaking. |
| 329 bool ScoredHistoryMatch::MatchScoreGreater(const ScoredHistoryMatch& m1, | 332 bool ScoredHistoryMatch::MatchScoreGreater(const ScoredHistoryMatch& m1, |
| 330 const ScoredHistoryMatch& m2) { | 333 const ScoredHistoryMatch& m2) { |
| 331 if (m1.raw_score != m2.raw_score) | 334 if (m1.raw_score != m2.raw_score) |
| 332 return m1.raw_score > m2.raw_score; | 335 return m1.raw_score > m2.raw_score; |
| 333 | 336 |
| 334 // This tie-breaking logic is inspired by / largely copied from the | 337 // This tie-breaking logic is inspired by / largely copied from the |
| 335 // ordering logic in history_url_provider.cc CompareHistoryMatch(). | 338 // ordering logic in history_url_provider.cc CompareHistoryMatch(). |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 ScoreMaxRelevance bucket; | 726 ScoreMaxRelevance bucket; |
| 724 bool is_valid_intermediate_score = | 727 bool is_valid_intermediate_score = |
| 725 base::StringToDouble(it->first, &bucket.first); | 728 base::StringToDouble(it->first, &bucket.first); |
| 726 DCHECK(is_valid_intermediate_score); | 729 DCHECK(is_valid_intermediate_score); |
| 727 bool is_valid_hqp_score = base::StringToInt(it->second, &bucket.second); | 730 bool is_valid_hqp_score = base::StringToInt(it->second, &bucket.second); |
| 728 DCHECK(is_valid_hqp_score); | 731 DCHECK(is_valid_hqp_score); |
| 729 hqp_buckets.push_back(bucket); | 732 hqp_buckets.push_back(bucket); |
| 730 } | 733 } |
| 731 return hqp_buckets; | 734 return hqp_buckets; |
| 732 } | 735 } |
| OLD | NEW |