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

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

Issue 2364873004: Add Precache.CacheStatus.NonPrefetch.FromPrecache. (Closed)
Patch Set: Add const. 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: components/precache/core/precache_database.cc
diff --git a/components/precache/core/precache_database.cc b/components/precache/core/precache_database.cc
index 4d22ee1efae239bb73aef4f48a41c9e29ec9b1e2..404a53668a050b99463cab3be4c18e6bf91607c1 100644
--- a/components/precache/core/precache_database.cc
+++ b/components/precache/core/precache_database.cc
@@ -198,7 +198,8 @@ void PrecacheDatabase::RecordURLPrefetch(const GURL& url,
// then the timestamp is updated.
buffered_writes_.push_back(base::Bind(
&PrecacheDatabase::RecordURLPrefetchInternal, GetWeakPtr(), url,
- referrer_host, !was_cached || precache_url_table_.IsURLPrecached(url),
+ referrer_host,
+ !was_cached || precache_url_table_.GetURLInfo(url).is_precached,
fetch_time));
buffered_urls_.insert(url.spec());
MaybePostFlush();
@@ -250,10 +251,13 @@ void PrecacheDatabase::RecordURLNonPrefetch(const GURL& url,
Flush();
}
- bool is_precached = precache_url_table_.IsURLPrecachedAndUnused(url);
- if (info.was_cached && !is_precached) {
- // Ignore cache hits that precache can't take credit for.
- return;
+ const PrecacheURLInfo url_info = precache_url_table_.GetURLInfo(url);
+
+ if (url_info.was_precached) {
+ UMA_HISTOGRAM_ENUMERATION(
+ "Precache.CacheStatus.NonPrefetch.FromPrecache",
+ info.cache_entry_status,
+ net::HttpResponseInfo::CacheEntryStatus::ENTRY_MAX);
}
base::HistogramBase::Sample size_sample =
@@ -275,7 +279,8 @@ void PrecacheDatabase::RecordURLNonPrefetch(const GURL& url,
base::Unretained(&precache_url_table_), url));
buffered_urls_.insert(url.spec());
MaybePostFlush();
- } else { // info.was_cached.
+ } else if (/* info.was_cached && */ url_info.is_precached &&
+ !url_info.was_used) {
// The fetch was served from the cache, and since there's an entry for this
// URL in the URL table, this means that the resource was served from the
// cache only because precaching put it there. Thus, precaching was helpful,
« no previous file with comments | « components/precache/content/precache_manager_unittest.cc ('k') | components/precache/core/precache_database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698