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

Unified Diff: components/precache/core/precache_database.h

Issue 2229983002: Send the list of used and unused resources for precache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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: components/precache/core/precache_database.h
diff --git a/components/precache/core/precache_database.h b/components/precache/core/precache_database.h
index cf2c4c25321f4dfcb5459d925ff69dc677a6afc5..6aec79cfbba2a266854c180a7bbd1f921094a267 100644
--- a/components/precache/core/precache_database.h
+++ b/components/precache/core/precache_database.h
@@ -7,7 +7,7 @@
#include <stdint.h>
-#include <list>
+#include <deque>
#include <memory>
#include <string>
#include <vector>
@@ -19,6 +19,7 @@
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.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"
@@ -68,10 +69,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 +90,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::deque<GURL>& used_urls,
sclittle 2016/08/11 22:52:35 Don't pass stuff in Chromium by non-const referenc
Raj 2016/08/12 19:04:20 Done.
+ std::deque<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 +140,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 +156,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_;

Powered by Google App Engine
This is Rietveld 408576698