Index: components/precache/core/precache_database.h |
diff --git a/components/precache/core/precache_database.h b/components/precache/core/precache_database.h |
index cf2c4c25321f4dfcb5459d925ff69dc677a6afc5..fa3df5f5de1e2bcb0884d42935233a190cac5674 100644 |
--- a/components/precache/core/precache_database.h |
+++ b/components/precache/core/precache_database.h |
@@ -7,7 +7,6 @@ |
#include <stdint.h> |
-#include <list> |
#include <memory> |
#include <string> |
#include <vector> |
@@ -18,7 +17,9 @@ |
#include "base/memory/ref_counted.h" |
#include "base/memory/weak_ptr.h" |
#include "base/threading/thread_checker.h" |
+#include "base/time/time.h" |
#include "components/precache/core/precache_fetcher.h" |
+#include "components/precache/core/precache_referrer_host_table.h" |
#include "components/precache/core/precache_session_table.h" |
#include "components/precache/core/precache_url_table.h" |
@@ -26,7 +27,6 @@ class GURL; |
namespace base { |
class FilePath; |
-class Time; |
} |
namespace net { |
@@ -68,10 +68,14 @@ class PrecacheDatabase { |
// Report precache-related metrics in response to a URL being fetched, where |
// the fetch was motivated by precaching. |
+ void RecordURLPrefetchMetrics(const net::HttpResponseInfo& info, |
+ const base::TimeDelta& latency); |
+ |
+ // Records the precache of an url |url| for top host |referrer_host|. |
void RecordURLPrefetch(const GURL& url, |
- const base::TimeDelta& latency, |
+ const std::string& referrer_host, |
const base::Time& fetch_time, |
- const net::HttpResponseInfo& info, |
+ bool was_cached, |
int64_t size); |
// Report precache-related metrics in response to a URL being fetched, where |
@@ -85,6 +89,21 @@ class PrecacheDatabase { |
int host_rank, |
bool is_connection_cellular); |
+ // Returns the referrer host entry for the |referrer_host|. |
+ PrecacheReferrerHostEntry GetReferrerHost(const std::string& referrer_host); |
+ |
+ // Populates the list of used and unused resources for referrer host with id |
+ // |referrer_host_id|. |
+ void GetURLListForReferrerHost(int64_t referrer_host_id, |
+ std::vector<GURL>* used_urls, |
+ std::vector<GURL>* unused_urls); |
+ |
+ // Updates the |manifest_id| and |fetch_time| for the referrer host |
+ // |hostname|. |
+ void UpdatePrecacheReferrerHost(const std::string& hostname, |
+ int64_t manifest_id, |
+ const base::Time& fetch_time); |
+ |
// Gets the state required to continue a precache session. |
std::unique_ptr<PrecacheUnfinishedWork> GetUnfinishedWork(); |
@@ -120,6 +139,15 @@ class PrecacheDatabase { |
// Records the time since the last precache. |
void RecordTimeSinceLastPrecache(const base::Time& fetch_time); |
+ void RecordURLPrefetchInternal(const GURL& url, |
+ const std::string& referrer_host, |
+ bool is_precached, |
+ const base::Time& fetch_time); |
+ |
+ void UpdatePrecacheReferrerHostInternal(const std::string& hostname, |
+ int64_t manifest_id, |
+ const base::Time& fetch_time); |
+ |
std::unique_ptr<sql::Connection> db_; |
// Table that keeps track of URLs that are in the cache because of precaching, |
@@ -127,6 +155,10 @@ class PrecacheDatabase { |
// then this table will not be up to date until the next call to Flush(). |
PrecacheURLTable precache_url_table_; |
+ // If |buffered_writes_| is non-empty, |
+ // then this table will not be up to date until the next call to Flush(). |
+ PrecacheReferrerHostTable precache_referrer_host_table_; |
+ |
// Table that persists state related to a precache session, including |
// unfinished work to be done. |
PrecacheSessionTable precache_session_table_; |