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

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

Issue 2388783002: predictors: Refactor resource_prefetch_predictor_tables. (Closed)
Patch Set: Created 4 years, 2 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_tables.h
diff --git a/chrome/browser/predictors/resource_prefetch_predictor_tables.h b/chrome/browser/predictors/resource_prefetch_predictor_tables.h
index 6588b546c69e8eae8536ff60e4c4b840c5e3b7f8..c3b2eeda4de4c4a9349c15cd4bb6f89e585efa89 100644
--- a/chrome/browser/predictors/resource_prefetch_predictor_tables.h
+++ b/chrome/browser/predictors/resource_prefetch_predictor_tables.h
@@ -8,13 +8,13 @@
#include <stddef.h>
#include <map>
+#include <memory>
#include <string>
#include <vector>
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
-#include "base/time/time.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"
@@ -29,6 +29,7 @@ class Statement;
namespace predictors {
// From resource_prefetch_predictor.proto.
+using ResourceData = PrefetchData_ResourceData;
using RedirectStat = RedirectData_RedirectStat;
// Interface for database tables used by the ResourcePrefetchPredictor.
@@ -37,30 +38,11 @@ using RedirectStat = RedirectData_RedirectStat;
//
// Currently manages:
// - UrlResourceTable - resources per Urls.
-// - UrlMetadataTable - misc data for Urls (like last visit time).
// - UrlRedirectTable - redirects per Urls.
// - HostResourceTable - resources per host.
-// - HostMetadataTable - misc data for hosts.
// - HostRedirectTable - redirects per host.
class ResourcePrefetchPredictorTables : public PredictorTableBase {
public:
- // Aggregated data for a Url or Host. Although the data differs slightly, we
- // store them in the same structure, because most of the fields are common and
- // it allows us to use the same functions.
- struct PrefetchData {
- PrefetchData(PrefetchKeyType key_type, const std::string& primary_key);
- PrefetchData(const PrefetchData& other);
- ~PrefetchData();
-
- bool is_host() const { return key_type == PREFETCH_KEY_TYPE_HOST; }
-
- // Is the data a host as opposed to a Url?
- PrefetchKeyType key_type; // Not const to be able to assign.
- std::string primary_key; // is_host() ? host : main frame url.
-
- base::Time last_visit;
- std::vector<ResourceData> resources;
- };
// Map from primary key to PrefetchData for the key.
typedef std::map<std::string, PrefetchData> PrefetchDataMap;
@@ -114,7 +96,7 @@ class ResourcePrefetchPredictorTables : public PredictorTableBase {
private:
// Represents the type of information that is stored in prefetch database.
- enum class PrefetchDataType { RESOURCE, REDIRECT, METADATA };
+ enum class PrefetchDataType { RESOURCE, REDIRECT };
enum class TableOperationType { INSERT, REMOVE };
@@ -133,8 +115,7 @@ class ResourcePrefetchPredictorTables : public PredictorTableBase {
// Helper functions below help perform functions on the Url and host table
// using the same code.
void GetAllResourceDataHelper(PrefetchKeyType key_type,
- PrefetchDataMap* data_map,
- std::vector<std::string>* to_delete);
+ PrefetchDataMap* data_map);
void GetAllRedirectDataHelper(PrefetchKeyType key_type,
RedirectDataMap* redirect_map);
bool UpdateResourceDataHelper(PrefetchKeyType key_type,

Powered by Google App Engine
This is Rietveld 408576698