Chromium Code Reviews| Index: chrome/browser/predictors/resource_prefetch_predictor_tables.h |
| diff --git a/chrome/browser/predictors/resource_prefetch_predictor_tables.h b/chrome/browser/predictors/resource_prefetch_predictor_tables.h |
| index 953c23f1c553437fb7354050c2bc7bb7b3a2c521..c5ed20f2deb8b941e7e4fbe1f1892ebebf32167c 100644 |
| --- a/chrome/browser/predictors/resource_prefetch_predictor_tables.h |
| +++ b/chrome/browser/predictors/resource_prefetch_predictor_tables.h |
| @@ -98,16 +98,43 @@ class ResourcePrefetchPredictorTables : public PredictorTableBase { |
| // Map from primary key to PrefetchData for the key. |
| typedef std::map<std::string, PrefetchData> PrefetchDataMap; |
| + struct RedirectStatRow { |
| + RedirectStatRow(); |
| + RedirectStatRow(const RedirectStatRow& other); |
| + |
| + std::string final_redirect; |
| + size_t number_of_hits; |
| + size_t number_of_misses; |
| + size_t consecutive_misses; |
| + }; |
| + typedef std::vector<RedirectStatRow> RedirectStatRows; |
|
mattcary
2016/09/09 13:19:21
Would prefer not to typedef the vector. You don't
|
| + |
| + struct RedirectData { |
| + RedirectData(PrefetchKeyType key_type, const std::string& primary_key); |
| + RedirectData(const RedirectData& other); |
| + ~RedirectData(); |
| + |
| + bool is_host() const { return key_type == PREFETCH_KEY_TYPE_HOST; } |
| + |
| + PrefetchKeyType key_type; |
| + std::string primary_key; |
| + base::Time last_visit; |
| + RedirectStatRows redirect_stats; |
| + }; |
| + typedef std::map<std::string, RedirectData> RedirectDataMap; |
| + |
| // Returns data for all Urls and Hosts. |
| virtual void GetAllData(PrefetchDataMap* url_data_map, |
| - PrefetchDataMap* host_data_map); |
| + PrefetchDataMap* host_data_map, |
| + RedirectDataMap* url_redirect_data_map, |
| + RedirectDataMap* host_redirect_data_map); |
| // Updates data for a Url and a host. If either of the |url_data| or |
| // |host_data| has an empty primary key, it will be ignored. |
| // Note that the Urls and primary key in |url_data| and |host_data| should be |
| // less than |kMaxStringLength| in length. |
| - virtual void UpdateData(const PrefetchData& url_data, |
| - const PrefetchData& host_data); |
| + virtual void UpdatePrefetchData(const PrefetchData& url_data, |
| + const PrefetchData& host_data); |
| // Delete data for the input |urls| and |hosts|. |
| virtual void DeleteData(const std::vector<std::string>& urls, |
| @@ -139,13 +166,14 @@ class ResourcePrefetchPredictorTables : public PredictorTableBase { |
| void GetAllDataHelper(PrefetchKeyType key_type, |
| PrefetchDataMap* data_map, |
| std::vector<std::string>* to_delete); |
| - bool UpdateDataHelper(const PrefetchData& data); |
| + bool UpdatePrefetchDataHelper(const PrefetchData& data); |
| void DeleteDataHelper(PrefetchKeyType key_type, |
| const std::vector<std::string>& keys); |
| // Returns true if the strings in the |data| are less than |kMaxStringLength| |
| // in length. |
| static bool StringsAreSmallerThanDBLimit(const PrefetchData& data); |
| + static bool StringsAreSmallerThanDBLimit(const RedirectData& data); |
| // PredictorTableBase methods. |
| void CreateTableIfNonExistent() override; |