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

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

Issue 2586813004: Report downloaded resources at most once (Closed)
Patch Set: Fix race condition in PrecacheFetcherTest due to MaybePost Created 4 years 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.cc
diff --git a/components/precache/core/precache_database.cc b/components/precache/core/precache_database.cc
index 8650262a405707f64b27a55199c29dec8995cdb6..de44cbf24b86a9829e2272b270ccc56c58c59af9 100644
--- a/components/precache/core/precache_database.cc
+++ b/components/precache/core/precache_database.cc
@@ -133,7 +133,7 @@ PrecacheReferrerHostEntry PrecacheDatabase::GetReferrerHost(
void PrecacheDatabase::GetURLListForReferrerHost(
int64_t referrer_host_id,
std::vector<GURL>* used_urls,
- std::vector<GURL>* unused_urls) {
+ std::vector<GURL>* downloaded_urls) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_NE(PrecacheReferrerHostEntry::kInvalidId, referrer_host_id);
@@ -141,7 +141,7 @@ void PrecacheDatabase::GetURLListForReferrerHost(
Flush();
precache_url_table_.GetURLListForReferrerHost(referrer_host_id, used_urls,
- unused_urls);
+ downloaded_urls);
}
void PrecacheDatabase::RecordURLPrefetchMetrics(
@@ -200,7 +200,7 @@ void PrecacheDatabase::RecordURLPrefetch(const GURL& url,
&PrecacheDatabase::RecordURLPrefetchInternal, GetWeakPtr(), url,
referrer_host,
!was_cached || precache_url_table_.GetURLInfo(url).is_precached,
- fetch_time));
+ was_cached, fetch_time));
buffered_urls_.insert(url.spec());
MaybePostFlush();
}
@@ -209,6 +209,7 @@ void PrecacheDatabase::RecordURLPrefetchInternal(
const GURL& url,
const std::string& referrer_host,
bool is_precached,
+ bool was_cached,
const base::Time& fetch_time) {
int64_t referrer_host_id =
precache_referrer_host_table_.GetReferrerHost(referrer_host).id;
@@ -217,7 +218,8 @@ void PrecacheDatabase::RecordURLPrefetchInternal(
referrer_host, 0, fetch_time);
}
DCHECK_NE(referrer_host_id, PrecacheReferrerHostEntry::kInvalidId);
- precache_url_table_.AddURL(url, referrer_host_id, is_precached, fetch_time);
+ precache_url_table_.AddURL(url, referrer_host_id, is_precached, was_cached,
+ fetch_time);
}
void PrecacheDatabase::RecordURLNonPrefetch(const GURL& url,
@@ -337,6 +339,7 @@ void PrecacheDatabase::UpdatePrecacheReferrerHostInternal(
const base::Time& fetch_time) {
int64_t referrer_host_id = precache_referrer_host_table_.UpdateReferrerHost(
hostname, manifest_id, fetch_time);
+
if (referrer_host_id != PrecacheReferrerHostEntry::kInvalidId) {
precache_url_table_.ClearAllForReferrerHost(referrer_host_id);
}

Powered by Google App Engine
This is Rietveld 408576698