| 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..94e62082ec161d52dd46c1065311b66df317c611 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,8 @@ void PrecacheDatabase::GetURLListForReferrerHost(
|
| Flush();
|
|
|
| precache_url_table_.GetURLListForReferrerHost(referrer_host_id, used_urls,
|
| - unused_urls);
|
| + downloaded_urls);
|
| + precache_url_table_.SetDownloadReported(referrer_host_id);
|
| }
|
|
|
| void PrecacheDatabase::RecordURLPrefetchMetrics(
|
| @@ -196,11 +197,15 @@ void PrecacheDatabase::RecordURLPrefetch(const GURL& url,
|
| // since it had no significant effect (besides a possible revalidation and a
|
| // change in the cache LRU priority). If a row for the URL already exists,
|
| // then the timestamp is updated.
|
| - buffered_writes_.push_back(base::Bind(
|
| - &PrecacheDatabase::RecordURLPrefetchInternal, GetWeakPtr(), url,
|
| - referrer_host,
|
| - !was_cached || precache_url_table_.GetURLInfo(url).is_precached,
|
| - fetch_time));
|
| + const PrecacheURLInfo info = precache_url_table_.GetURLInfo(url);
|
| + bool is_download_reported = info.is_download_reported;
|
| + if (info.is_precached && !was_cached) {
|
| + is_download_reported = false;
|
| + }
|
| + buffered_writes_.push_back(
|
| + base::Bind(&PrecacheDatabase::RecordURLPrefetchInternal, GetWeakPtr(),
|
| + url, referrer_host, !was_cached || info.is_precached,
|
| + fetch_time, is_download_reported));
|
| buffered_urls_.insert(url.spec());
|
| MaybePostFlush();
|
| }
|
| @@ -209,7 +214,8 @@ void PrecacheDatabase::RecordURLPrefetchInternal(
|
| const GURL& url,
|
| const std::string& referrer_host,
|
| bool is_precached,
|
| - const base::Time& fetch_time) {
|
| + const base::Time& fetch_time,
|
| + bool is_download_reported) {
|
| int64_t referrer_host_id =
|
| precache_referrer_host_table_.GetReferrerHost(referrer_host).id;
|
| if (referrer_host_id == PrecacheReferrerHostEntry::kInvalidId) {
|
| @@ -217,7 +223,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, fetch_time,
|
| + is_download_reported);
|
| }
|
|
|
| void PrecacheDatabase::RecordURLNonPrefetch(const GURL& url,
|
| @@ -337,6 +344,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);
|
| }
|
|
|