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 2e2f2733a00449d67ae13a07070db5afc8b69427..aee6e41a69ebda173d9cc34b99d1f969fbc657ee 100644 |
--- a/chrome/browser/predictors/resource_prefetch_predictor_tables.h |
+++ b/chrome/browser/predictors/resource_prefetch_predictor_tables.h |
@@ -13,15 +13,12 @@ |
#include "base/gtest_prod_util.h" |
#include "base/macros.h" |
+#include "chrome/browser/predictors/glowplug_key_value_table.h" |
#include "chrome/browser/predictors/predictor_table_base.h" |
#include "chrome/browser/predictors/resource_prefetch_common.h" |
#include "chrome/browser/predictors/resource_prefetch_predictor.pb.h" |
#include "components/precache/core/proto/precache.pb.h" |
-namespace sql { |
-class Statement; |
-} |
- |
namespace predictors { |
// Interface for database tables used by the ResourcePrefetchPredictor. |
@@ -29,10 +26,13 @@ namespace predictors { |
// thread. |
// |
// Currently manages: |
-// - UrlResourceTable - resources per Urls. |
-// - UrlRedirectTable - redirects per Urls. |
-// - HostResourceTable - resources per host. |
-// - HostRedirectTable - redirects per host. |
+// - UrlResourceTable - key: url, value: PrefetchData |
+// - UrlRedirectTable - key: url, value: RedirectData |
+// - HostResourceTable - key: host, value: PrefetchData |
+// - HostRedirectTable - key: host, value: RedirectData |
+// - ManifestTable - key: host with stripped "www." prefix, |
+// value: precache::PrecacheManifest |
+// - OriginTable - key: host, value: OriginData |
class ResourcePrefetchPredictorTables : public PredictorTableBase { |
public: |
typedef std::map<std::string, PrefetchData> PrefetchDataMap; |
@@ -131,11 +131,6 @@ class ResourcePrefetchPredictorTables : public PredictorTableBase { |
~ResourcePrefetchPredictorTables() override; |
private: |
- // Represents the type of information that is stored in prefetch database. |
- enum class PrefetchDataType { RESOURCE, REDIRECT, MANIFEST, ORIGIN }; |
- |
- enum class TableOperationType { INSERT, REMOVE }; |
- |
friend class PredictorDatabaseInternal; |
FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTablesTest, |
DatabaseVersionIsSet); |
@@ -146,23 +141,6 @@ class ResourcePrefetchPredictorTables : public PredictorTableBase { |
// schema (including the .proto). |
static constexpr int kDatabaseVersion = 8; |
- // Helper functions below help perform functions on the Url and host table |
- // using the same code. |
- void GetAllResourceDataHelper(PrefetchKeyType key_type, |
- PrefetchDataMap* data_map); |
- void GetAllRedirectDataHelper(PrefetchKeyType key_type, |
- RedirectDataMap* redirect_map); |
- void GetAllManifestDataHelper(ManifestDataMap* manifest_map); |
- void GetAllOriginDataHelper(OriginDataMap* manifest_map); |
- |
- void UpdateDataHelper(PrefetchKeyType key_type, |
- PrefetchDataType data_type, |
- const std::string& key, |
- const google::protobuf::MessageLite& data); |
- void DeleteDataHelper(PrefetchKeyType key_type, |
- PrefetchDataType data_type, |
- const std::vector<std::string>& keys); |
- |
// PredictorTableBase: |
void CreateTableIfNonExistent() override; |
void LogDatabaseStats() override; |
@@ -171,14 +149,13 @@ class ResourcePrefetchPredictorTables : public PredictorTableBase { |
static int GetDatabaseVersion(sql::Connection* db); |
static bool SetDatabaseVersion(sql::Connection* db, int version); |
- // Helper to return cached Statements. |
- std::unique_ptr<sql::Statement> GetTableUpdateStatement( |
- PrefetchKeyType key_type, |
- PrefetchDataType data_type, |
- TableOperationType op_type); |
- |
- static const char* GetTableName(PrefetchKeyType key_type, |
- PrefetchDataType data_type); |
+ std::unique_ptr<GlowplugKeyValueTable<PrefetchData>> url_resource_table_; |
+ std::unique_ptr<GlowplugKeyValueTable<RedirectData>> url_redirect_table_; |
+ std::unique_ptr<GlowplugKeyValueTable<PrefetchData>> host_resource_table_; |
+ std::unique_ptr<GlowplugKeyValueTable<RedirectData>> host_redirect_table_; |
+ std::unique_ptr<GlowplugKeyValueTable<precache::PrecacheManifest>> |
+ manifest_table_; |
+ std::unique_ptr<GlowplugKeyValueTable<OriginData>> origin_table_; |
DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorTables); |
}; |