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

Unified Diff: components/precache/content/precache_manager.h

Issue 2202023002: Precache should cancel when there is user traffic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 5 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/content/precache_manager.h
diff --git a/components/precache/content/precache_manager.h b/components/precache/content/precache_manager.h
index 614ea0bd0b663d987d14371a516b984b491df4dd..259ced7678a585fbac5d62d569a4efd0fe06eebf 100644
--- a/components/precache/content/precache_manager.h
+++ b/components/precache/content/precache_manager.h
@@ -26,6 +26,7 @@
namespace base {
class FilePath;
class Time;
+class TimeDelta;
}
namespace content {
@@ -96,19 +97,34 @@ class PrecacheManager : public KeyedService,
// Returns true if precaching is currently in progress, or false otherwise.
bool IsPrecaching() const;
- // Update precache-related metrics in response to a URL being fetched.
- void RecordStatsForFetch(const GURL& url,
- const GURL& referrer,
- const base::TimeDelta& latency,
- const base::Time& fetch_time,
- int64_t size,
- bool was_cached);
-
// Posts a task to the DB thread to delete all history entries from the
// database. Does not wait for completion of this task.
void ClearHistory();
+ // Update precache about an URL being fetched. Metrics related to precache are
+ // updated and any ongoing precache will be cancelled if this is an user
+ // initiated request. Should be called on UI thread.
+ void UpdatePrecacheMetricsAndState(const GURL& url,
+ const GURL& referrer,
+ const base::TimeDelta& latency,
+ const base::Time& fetch_time,
+ int64_t size,
+ bool was_cached,
+ bool is_user_traffic);
+
private:
+ FRIEND_TEST_ALL_PREFIXES(PrecacheManagerTest, DeleteExpiredPrecacheHistory);
+ FRIEND_TEST_ALL_PREFIXES(PrecacheManagerTest,
+ RecordStatsForFetchDuringPrecaching);
+ FRIEND_TEST_ALL_PREFIXES(PrecacheManagerTest, RecordStatsForFetchHTTP);
+ FRIEND_TEST_ALL_PREFIXES(PrecacheManagerTest, RecordStatsForFetchHTTPS);
+ FRIEND_TEST_ALL_PREFIXES(PrecacheManagerTest, RecordStatsForFetchInTopHosts);
+ FRIEND_TEST_ALL_PREFIXES(PrecacheManagerTest,
+ RecordStatsForFetchWithEmptyURL);
+ FRIEND_TEST_ALL_PREFIXES(PrecacheManagerTest, RecordStatsForFetchWithNonHTTP);
+ FRIEND_TEST_ALL_PREFIXES(PrecacheManagerTest,
+ RecordStatsForFetchWithSizeZero);
+
enum class AllowedType {
ALLOWED,
DISALLOWED,
@@ -138,6 +154,14 @@ class PrecacheManager : public KeyedService,
// Returns true if precaching is allowed for the browser context.
AllowedType PrecachingAllowed() const;
+ // Update precache-related metrics in response to a URL being fetched.
+ void RecordStatsForFetch(const GURL& url,
+ const GURL& referrer,
+ const base::TimeDelta& latency,
+ const base::Time& fetch_time,
+ int64_t size,
+ bool was_cached);
+
// Update precache-related metrics in response to a URL being fetched. Called
// by RecordStatsForFetch() by way of an asynchronous HistoryService callback.
void RecordStatsForFetchInternal(const GURL& url,
« no previous file with comments | « components/data_use_measurement/content/data_use_measurement.cc ('k') | components/precache/content/precache_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698