diff options
author | shishir@chromium.org <shishir@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-29 22:54:47 +0000 |
---|---|---|
committer | shishir@chromium.org <shishir@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-29 22:54:47 +0000 |
commit | e42285a3b4def2770cc3ad504a0d73d2d565a313 (patch) | |
tree | 1a2c50e5a48f2fe89b21f2b11843fa11634f5d63 /chrome/browser/predictors/resource_prefetch_predictor_tables.h | |
parent | ce112fe17067812a9014c6b10e041435aedf9998 (diff) | |
download | chromium_src-e42285a3b4def2770cc3ad504a0d73d2d565a313.zip chromium_src-e42285a3b4def2770cc3ad504a0d73d2d565a313.tar.gz chromium_src-e42285a3b4def2770cc3ad504a0d73d2d565a313.tar.bz2 |
ResourcePrefetchPredictor: Storing last_visit time instead of looking it up at
startup to avoid startup latency.
BUG=149743
Review URL: https://chromiumcodereview.appspot.com/11275015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164761 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/predictors/resource_prefetch_predictor_tables.h')
-rw-r--r-- | chrome/browser/predictors/resource_prefetch_predictor_tables.h | 59 |
1 files changed, 36 insertions, 23 deletions
diff --git a/chrome/browser/predictors/resource_prefetch_predictor_tables.h b/chrome/browser/predictors/resource_prefetch_predictor_tables.h index 51ddf11..7d6f8e0 100644 --- a/chrome/browser/predictors/resource_prefetch_predictor_tables.h +++ b/chrome/browser/predictors/resource_prefetch_predictor_tables.h @@ -10,6 +10,7 @@ #include <string> #include <vector> +#include "base/time.h" #include "googleurl/src/gurl.h" #include "webkit/glue/resource_type.h" @@ -18,23 +19,24 @@ namespace predictors { // Interface for database tables used by the ResourcePrefetchPredictor. // All methods except the constructor and destructor need to be called on the DB // thread. -// NOTE: This class is named in plural as it will hold other tables shortly. // -// TODO(shishir): Move to composition model instead of implemented inheritance. +// Currently manages two tables: +// - UrlResourceTable - Keeps track of resources per Urls. +// - UrlMetadataTable - Keeps misc data for Urls (like last visit time). class ResourcePrefetchPredictorTables : public PredictorTableBase { public: - struct UrlTableRow { - UrlTableRow(); - UrlTableRow(const UrlTableRow& other); - UrlTableRow(const std::string& main_frame_url, - const std::string& resource_url, - ResourceType::Type resource_type, - int number_of_hits, - int number_of_misses, - int consecutive_misses, - double average_position); + struct UrlResourceRow { + UrlResourceRow(); + UrlResourceRow(const UrlResourceRow& other); + UrlResourceRow(const std::string& main_frame_url, + const std::string& resource_url, + ResourceType::Type resource_type, + int number_of_hits, + int number_of_misses, + int consecutive_misses, + double average_position); void UpdateScore(); - bool operator==(const UrlTableRow& rhs) const; + bool operator==(const UrlResourceRow& rhs) const; GURL main_frame_url; GURL resource_url; @@ -47,19 +49,30 @@ class ResourcePrefetchPredictorTables : public PredictorTableBase { // Not stored. float score; }; - typedef std::vector<UrlTableRow> UrlTableRows; + typedef std::vector<UrlResourceRow> UrlResourceRows; - // Sorts the UrlTableRows by score, descending. - struct UrlTableRowSorter { - bool operator()(const UrlTableRow& x, const UrlTableRow& y) const; + // Sorts the UrlResourceRows by score, descending. + struct UrlResourceRowSorter { + bool operator()(const UrlResourceRow& x, const UrlResourceRow& y) const; }; - // |url_row_buffer| should be empty for GetAllRows. - virtual void GetAllRows(UrlTableRows* url_row_buffer); - virtual void UpdateRowsForUrl(const GURL& main_page_url, - const UrlTableRows& row_buffer); - virtual void DeleteRowsForUrls(const std::vector<GURL>& urls); - virtual void DeleteAllRows(); + // Data from both the tables for a particular main frame url. + struct UrlData { + explicit UrlData(const GURL& main_frame_url); + UrlData(const UrlData& other); + ~UrlData(); + bool operator==(const UrlData& rhs) const; + + GURL main_frame_url; + base::Time last_visit; + UrlResourceRows resources; + }; + + // |url_data_buffer| should be empty for GetAllRows. + virtual void GetAllUrlData(std::vector<UrlData>* url_data_buffer); + virtual void UpdateDataForUrl(const UrlData& url_data); + virtual void DeleteDataForUrls(const std::vector<GURL>& urls); + virtual void DeleteAllUrlData(); private: friend class PredictorDatabaseInternal; |