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

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

Issue 2596093002: Create a synthetic field trial for precache. (Closed)
Patch Set: Rebase. Created 3 years, 11 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.cc
diff --git a/components/precache/content/precache_manager.cc b/components/precache/content/precache_manager.cc
index 1bb682005b2131774772dff5e16e7320198e4508..7732807e8f8e6af204265c69fd075a3f9a0c9bc7 100644
--- a/components/precache/content/precache_manager.cc
+++ b/components/precache/content/precache_manager.cc
@@ -356,22 +356,35 @@ void PrecacheManager::UpdatePrecacheMetricsAndState(
const base::Time& fetch_time,
const net::HttpResponseInfo& info,
int64_t size,
- bool is_user_traffic) {
+ bool is_user_traffic,
+ const base::Callback<void(base::Time)>& register_synthetic_trial) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- RecordStatsForFetch(url, referrer, latency, fetch_time, info, size);
+ BrowserThread::PostTaskAndReplyWithResult(
+ BrowserThread::DB, FROM_HERE,
+ base::Bind(&PrecacheDatabase::GetLastPrecacheTimestamp,
+ base::Unretained(precache_database_.get())),
+ base::Bind(&PrecacheManager::RecordStatsForFetch, AsWeakPtr(), url,
+ referrer, latency, fetch_time, info, size,
+ register_synthetic_trial));
+
if (is_user_traffic && IsPrecaching())
CancelPrecaching();
}
-void PrecacheManager::RecordStatsForFetch(const GURL& url,
- const GURL& referrer,
- const base::TimeDelta& latency,
- const base::Time& fetch_time,
- const net::HttpResponseInfo& info,
- int64_t size) {
+void PrecacheManager::RecordStatsForFetch(
+ const GURL& url,
+ const GURL& referrer,
+ const base::TimeDelta& latency,
+ const base::Time& fetch_time,
+ const net::HttpResponseInfo& info,
+ int64_t size,
+ const base::Callback<void(base::Time)>& register_synthetic_trial,
+ base::Time last_precache_time) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ register_synthetic_trial.Run(last_precache_time);
+
if (size == 0 || url.is_empty() || !url.SchemeIsHTTPOrHTTPS()) {
// Ignore empty responses, empty URLs, or URLs that aren't HTTP or HTTPS.
return;
« no previous file with comments | « components/precache/content/precache_manager.h ('k') | components/precache/content/precache_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698