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

Unified Diff: chrome/browser/predictors/resource_prefetch_predictor.h

Issue 2321343002: Redirect handling in resource prefetch predictor (Closed)
Patch Set: test Created 4 years, 3 months 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: chrome/browser/predictors/resource_prefetch_predictor.h
diff --git a/chrome/browser/predictors/resource_prefetch_predictor.h b/chrome/browser/predictors/resource_prefetch_predictor.h
index edd31665ca0c79fdba83182c09523da9678bdd82..95866dabcb0bb0a6dd58fe5bf57c58566e5b8ae9 100644
--- a/chrome/browser/predictors/resource_prefetch_predictor.h
+++ b/chrome/browser/predictors/resource_prefetch_predictor.h
@@ -184,9 +184,16 @@ class ResourcePrefetchPredictor
typedef ResourcePrefetchPredictorTables::ResourceRows ResourceRows;
typedef ResourcePrefetchPredictorTables::PrefetchData PrefetchData;
typedef ResourcePrefetchPredictorTables::PrefetchDataMap PrefetchDataMap;
+
+ typedef ResourcePrefetchPredictorTables::RedirectStatRow RedirectStatRow;
+ typedef ResourcePrefetchPredictorTables::RedirectStatRows RedirectStatRows;
+ typedef ResourcePrefetchPredictorTables::RedirectData RedirectData;
+ typedef ResourcePrefetchPredictorTables::RedirectDataMap RedirectDataMap;
+
typedef std::map<NavigationID, linked_ptr<std::vector<URLRequestSummary> > >
mattcary 2016/09/09 13:19:21 To be consistent with other code, should remove sp
NavigationMap;
typedef std::map<NavigationID, std::unique_ptr<Result>> ResultsMap;
+ typedef std::map<NavigationID, linked_ptr<std::vector<GURL> > > RedirectsMap;
mattcary 2016/09/09 09:16:11 Should use unique_ptr instead, see https://www.ch
alexilin 2016/09/09 13:59:19 Yep, I used linked_ptr like in a rest of code but
// Returns true if the main page request is supported for prediction.
static bool IsHandledMainPage(net::URLRequest* request);
@@ -240,9 +247,11 @@ class ResourcePrefetchPredictor
void StartInitialization();
// Callback for task to read predictor database. Takes ownership of
- // |url_data_map| and |host_data_map|.
+ // all arguments.
void CreateCaches(std::unique_ptr<PrefetchDataMap> url_data_map,
- std::unique_ptr<PrefetchDataMap> host_data_map);
+ std::unique_ptr<PrefetchDataMap> host_data_map,
+ std::unique_ptr<RedirectDataMap> url_redirect_data_map,
+ std::unique_ptr<RedirectDataMap> host_redirect_data_map);
// Called during initialization when history is read and the predictor
// database has been read.
@@ -263,7 +272,8 @@ class ResourcePrefetchPredictor
// Callback for GetUrlVisitCountTask.
void OnVisitCountLookup(size_t visit_count,
const NavigationID& navigation_id,
- const std::vector<URLRequestSummary>& requests);
+ const std::vector<URLRequestSummary>& requests,
+ std::vector<GURL>* redirects);
// Removes the oldest entry in the input |data_map|, also deleting it from the
// predictor database.
@@ -278,6 +288,14 @@ class ResourcePrefetchPredictor
size_t max_data_map_size,
PrefetchDataMap* data_map);
+ // Updates information about final redirect destination for all |keys| in
+ // |redirect_map| and correspondingly updates the predictor database
+ void LearnRedirects(const std::vector<std::string>& keys,
+ PrefetchKeyType key_type,
+ const std::string& final_redirect,
+ size_t max_redirect_map_size,
+ RedirectDataMap* redirect_map);
+
// Reports overall page load time.
void ReportPageLoadTimeStats(base::TimeDelta plt) const;
@@ -338,8 +356,11 @@ class ResourcePrefetchPredictor
// Copy of the data in the predictor tables.
std::unique_ptr<PrefetchDataMap> url_table_cache_;
std::unique_ptr<PrefetchDataMap> host_table_cache_;
+ std::unique_ptr<RedirectDataMap> url_redirect_table_cache_;
+ std::unique_ptr<RedirectDataMap> host_redirect_table_cache_;
ResultsMap results_map_;
+ RedirectsMap redirects_map_;
ScopedObserver<history::HistoryService, history::HistoryServiceObserver>
history_service_observer_;

Powered by Google App Engine
This is Rietveld 408576698