| 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/scored_history_match.h" | 5 #include "chrome/browser/history/scored_history_match.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <iterator> | 9 #include <iterator> |
| 10 #include <numeric> | 10 #include <numeric> |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 const VisitInfoVector& visits) { | 524 const VisitInfoVector& visits) { |
| 525 // Compute the weighted average |value_of_transition| over the last at | 525 // Compute the weighted average |value_of_transition| over the last at |
| 526 // most kMaxVisitsToScore visits, where each visit is weighted using | 526 // most kMaxVisitsToScore visits, where each visit is weighted using |
| 527 // GetRecencyScore() based on how many days ago it happened. Use | 527 // GetRecencyScore() based on how many days ago it happened. Use |
| 528 // kMaxVisitsToScore as the denominator for the average regardless of | 528 // kMaxVisitsToScore as the denominator for the average regardless of |
| 529 // how many visits there were in order to penalize a match that has | 529 // how many visits there were in order to penalize a match that has |
| 530 // fewer visits than kMaxVisitsToScore. | 530 // fewer visits than kMaxVisitsToScore. |
| 531 float summed_visit_points = 0; | 531 float summed_visit_points = 0; |
| 532 for (size_t i = 0; i < std::min(visits.size(), kMaxVisitsToScore); ++i) { | 532 for (size_t i = 0; i < std::min(visits.size(), kMaxVisitsToScore); ++i) { |
| 533 int value_of_transition = | 533 int value_of_transition = |
| 534 (visits[i].second == content::PAGE_TRANSITION_TYPED) ? 20 : 1; | 534 (visits[i].second == ui::PAGE_TRANSITION_TYPED) ? 20 : 1; |
| 535 if (bookmarked) | 535 if (bookmarked) |
| 536 value_of_transition = std::max(value_of_transition, bookmark_value_); | 536 value_of_transition = std::max(value_of_transition, bookmark_value_); |
| 537 const float bucket_weight = | 537 const float bucket_weight = |
| 538 GetRecencyScore((now - visits[i].first).InDays()); | 538 GetRecencyScore((now - visits[i].first).InDays()); |
| 539 summed_visit_points += (value_of_transition * bucket_weight); | 539 summed_visit_points += (value_of_transition * bucket_weight); |
| 540 } | 540 } |
| 541 return visits.size() * summed_visit_points / kMaxVisitsToScore; | 541 return visits.size() * summed_visit_points / kMaxVisitsToScore; |
| 542 } | 542 } |
| 543 | 543 |
| 544 // static | 544 // static |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 max_assigned_score_for_non_inlineable_matches_ = | 599 max_assigned_score_for_non_inlineable_matches_ = |
| 600 HistoryURLProvider::kScoreForBestInlineableResult - 1; | 600 HistoryURLProvider::kScoreForBestInlineableResult - 1; |
| 601 } | 601 } |
| 602 bookmark_value_ = OmniboxFieldTrial::HQPBookmarkValue(); | 602 bookmark_value_ = OmniboxFieldTrial::HQPBookmarkValue(); |
| 603 allow_tld_matches_ = OmniboxFieldTrial::HQPAllowMatchInTLDValue(); | 603 allow_tld_matches_ = OmniboxFieldTrial::HQPAllowMatchInTLDValue(); |
| 604 allow_scheme_matches_ = OmniboxFieldTrial::HQPAllowMatchInSchemeValue(); | 604 allow_scheme_matches_ = OmniboxFieldTrial::HQPAllowMatchInSchemeValue(); |
| 605 initialized_ = true; | 605 initialized_ = true; |
| 606 } | 606 } |
| 607 | 607 |
| 608 } // namespace history | 608 } // namespace history |
| OLD | NEW |