Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(775)

Unified Diff: components/omnibox/browser/scored_history_match.h

Issue 2548363010: Omnibox - Refactor |relevance_buckets| to Remove Memory Leak on Exit (Closed)
Patch Set: polish Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/omnibox/browser/scored_history_match.h
diff --git a/components/omnibox/browser/scored_history_match.h b/components/omnibox/browser/scored_history_match.h
index dacd31cec537b30c501c35a6410bca55cbe20d96..63db82160e4a5d531cea26b117d87051f06c3c32 100644
--- a/components/omnibox/browser/scored_history_match.h
+++ b/components/omnibox/browser/scored_history_match.h
@@ -24,7 +24,7 @@ class ScoredHistoryMatchTest;
struct ScoredHistoryMatch : public history::HistoryMatch {
// ScoreMaxRelevance maps from an intermediate-score to the maximum
// final-relevance score given to a URL for this intermediate score.
- // This is used to store the score ranges of HQP relevance buckets.
+ // This is used to store the score ranges of relevance buckets.
// Please see GetFinalRelevancyScore() for details.
typedef std::pair<double, int> ScoreMaxRelevance;
@@ -128,29 +128,22 @@ struct ScoredHistoryMatch : public history::HistoryMatch {
const bool bookmarked,
const VisitInfoVector& visits) const;
- // Combines the two component scores into a final score that's
- // an appropriate value to use as a relevancy score. Scoring buckets are
- // specified through |hqp_relevance_buckets|. Please see the function
- // implementation for more details.
- static float GetFinalRelevancyScore(
- float topicality_score,
- float frequency_score,
- const std::vector<ScoreMaxRelevance>& hqp_relevance_buckets);
-
- // Initializes the HQP experimental params: |hqp_relevance_buckets_|
- // to default buckets. If hqp experimental scoring is enabled, it
- // fetches the |hqp_experimental_scoring_enabled_|, |topicality_threshold_|
- // and |hqp_relevance_buckets_| from omnibox field trials.
- static void InitHQPExperimentalParams();
-
- // Helper function to parse the string containing the scoring buckets.
- // For example,
- // String: "0.0:400,1.5:600,12.0:1300,20.0:1399"
- // Buckets: vector[(0.0, 400),(1.5,600),(12.0,1300),(20.0,1399)]
- // Returns false, in case if it fail to parse the string.
- static bool GetHQPBucketsFromString(
- const std::string& buckets_str,
- std::vector<ScoreMaxRelevance>* hqp_buckets);
+ // Combines the two component scores into a final score that's an appropriate
+ // value to use as a relevancy score.
+ static float GetFinalRelevancyScore(float topicality_score,
+ float frequency_score);
+
+ // Helper function that returns the string containing the scoring buckets
+ // (either the default ones or ones specified in an experiment).
+ static std::vector<ScoreMaxRelevance> GetHQPBuckets();
Peter Kasting 2016/12/08 01:29:21 I don't love how often "std::vector<ScoreMaxReleva
Mark P 2016/12/09 20:40:56 Done.
+
+ // Helper function to parse the string containing the scoring buckets and
+ // return the results. For example, with |bucket_str| as
Peter Kasting 2016/12/08 01:29:21 Nit: buckets
Mark P 2016/12/09 20:40:56 Done.
+ // "0.0:400,1.5:600,12.0:1300,20.0:1399", it returns [(0.0, 400), (1.5, 600),
+ // (12.0, 1300), (20.0, 1399)]. It returns an empty list in the case of a
Peter Kasting 2016/12/08 01:29:22 Nit: list -> vector
Mark P 2016/12/09 20:40:56 Done.
+ // malformed |buckets_str|.
+ static std::vector<ScoreMaxRelevance> GetHQPBucketsFromString(
+ const std::string& buckets_str);
// If true, assign raw scores to be max(whatever it normally would be, a
// score that's similar to the score HistoryURL provider would assign).
@@ -184,22 +177,15 @@ struct ScoredHistoryMatch : public history::HistoryMatch {
// Words beyond this number are ignored.
static size_t num_title_words_to_allow_;
- // True, if hqp experimental scoring is enabled.
- static bool hqp_experimental_scoring_enabled_;
-
// |topicality_threshold_| is used to control the topicality scoring.
- // If |topicality_threshold_| > 0, then URLs with topicality-score < threshold
- // are given topicality score of 0. By default it is initalized to -1.
+ // If |topicality_threshold_| > 0, then URLs with topicality-score less than
+ // the threshold are given topicality score of 0.
static float topicality_threshold_;
- // |hqp_relevance_buckets_str_| is used to control the hqp score ranges.
- // It is the string representation of |hqp_relevance_buckets_|.
- static char hqp_relevance_buckets_str_[];
-
- // |hqp_relevance_buckets_| gives mapping from (topicality*frequency)
- // to the final relevance scoring. Please see GetFinalRelevancyScore()
- // for more details and scoring method.
- static std::vector<ScoreMaxRelevance>* hqp_relevance_buckets_;
+ // Used for testing. This is a pointer to the static local variable
+ // |relevance_buckets| declared in GetFinalRelevancyScore(). It's not valid
+ // until after the first call to GetFinalRelevancyScore().
+ static std::vector<ScoreMaxRelevance>* relevance_buckets_;
};
typedef std::vector<ScoredHistoryMatch> ScoredHistoryMatches;
« no previous file with comments | « no previous file | components/omnibox/browser/scored_history_match.cc » ('j') | components/omnibox/browser/scored_history_match.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698