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

Unified Diff: chrome/browser/net/chrome_network_delegate.cc

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
« no previous file with comments | « no previous file | chrome/browser/precache/precache_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/chrome_network_delegate.cc
diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc
index 7df2649315292d7c296b7f0ec1ac7068c7186d0f..d90c458fc794c11039c47e62e544bc24e65d7ff3 100644
--- a/chrome/browser/net/chrome_network_delegate.cc
+++ b/chrome/browser/net/chrome_network_delegate.cc
@@ -63,8 +63,7 @@
#if BUILDFLAG(ANDROID_JAVA_UI)
#include "chrome/browser/io_thread.h"
-#include "chrome/browser/precache/precache_manager_factory.h"
-#include "components/precache/content/precache_manager.h"
+#include "chrome/browser/precache/precache_util.h"
#endif
#if defined(OS_CHROMEOS)
@@ -107,31 +106,6 @@ void ForceGoogleSafeSearchCallbackWrapper(
callback.Run(rv);
}
-#if BUILDFLAG(ANDROID_JAVA_UI)
-void RecordPrecacheStatsOnUIThread(const GURL& url,
- const GURL& referrer,
- base::TimeDelta latency,
- const base::Time& fetch_time,
- int64_t size,
- bool was_cached,
- void* profile_id) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
-
- if (!g_browser_process->profile_manager()->IsValidProfile(profile_id))
- return;
- Profile* profile = reinterpret_cast<Profile*>(profile_id);
-
- precache::PrecacheManager* precache_manager =
- precache::PrecacheManagerFactory::GetForBrowserContext(profile);
- // |precache_manager| could be NULL if the profile is off the record.
- if (!precache_manager || !precache_manager->IsPrecachingAllowed())
- return;
-
- precache_manager->RecordStatsForFetch(url, referrer, latency, fetch_time,
- size, was_cached);
-}
-#endif // BUILDFLAG(ANDROID_JAVA_UI)
-
void ReportInvalidReferrerSendOnUI() {
base::RecordAction(
base::UserMetricsAction("Net.URLRequest_StartJob_InvalidReferrer"));
@@ -529,20 +503,7 @@ void ChromeNetworkDelegate::OnCompleted(net::URLRequest* request,
if (request->status().status() == net::URLRequestStatus::SUCCESS) {
#if BUILDFLAG(ANDROID_JAVA_UI)
- // For better accuracy, we use the actual bytes read instead of the length
- // specified with the Content-Length header, which may be inaccurate,
- // or missing, as is the case with chunked encoding.
- int64_t received_content_length =
- request->received_response_content_length();
- base::TimeDelta latency = base::TimeTicks::Now() - request->creation_time();
-
- // Record precache metrics when a fetch is completed successfully, if
- // precaching is allowed.
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&RecordPrecacheStatsOnUIThread, request->url(),
- GURL(request->referrer()), latency, base::Time::Now(),
- received_content_length, request->was_cached(), profile_));
+ precache::UpdatePrecacheMetricsAndState(request, profile_);
#endif // BUILDFLAG(ANDROID_JAVA_UI)
extensions_delegate_->OnCompleted(request, started);
} else if (request->status().status() == net::URLRequestStatus::FAILED ||
« no previous file with comments | « no previous file | chrome/browser/precache/precache_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698