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

Unified Diff: chrome/browser/prerender/prerender_manager.cc

Issue 160513002: Reports Prerender and Profile Total Bytes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing prerender UMA byte tracking. Created 6 years, 10 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: chrome/browser/prerender/prerender_manager.cc
diff --git a/chrome/browser/prerender/prerender_manager.cc b/chrome/browser/prerender/prerender_manager.cc
index bee549a950864481555ff56c6b7e9385a3053c21..acfa0f871f95c3c8349a2cf5e1ee9e1cac2451d7 100644
--- a/chrome/browser/prerender/prerender_manager.cc
+++ b/chrome/browser/prerender/prerender_manager.cc
@@ -241,7 +241,9 @@ PrerenderManager::PrerenderManager(Profile* profile,
last_prerender_start_time_(GetCurrentTimeTicks() -
base::TimeDelta::FromMilliseconds(kMinTimeBetweenPrerendersMs)),
prerender_history_(new PrerenderHistory(kHistoryLength)),
- histograms_(new PrerenderHistograms()) {
+ histograms_(new PrerenderHistograms()),
+ profile_network_bytes_(0),
+ last_recorded_profile_network_bytes_(0) {
// There are some assumptions that the PrerenderManager is on the UI thread.
// Any other checks simply make sure that the PrerenderManager is accessed on
// the same thread that it was created on.
@@ -1767,4 +1769,20 @@ void PrerenderManager::HangSessionStorageMergesForTesting() {
g_hang_session_storage_merges_for_testing = true;
}
+void PrerenderManager::RecordNetworkBytes(bool used, int64 prerender_bytes) {
+ if (!ActuallyPrerendering())
+ return;
+ int64 recent_profile_bytes =
+ profile_network_bytes_ - last_recorded_profile_network_bytes_;
+ last_recorded_profile_network_bytes_ = profile_network_bytes_;
+ DCHECK_GE(recent_profile_bytes, 0);
+ histograms_->RecordNetworkBytes(used, prerender_bytes, recent_profile_bytes);
+}
+
+void PrerenderManager::AddProfileNetworkBytesIfEnabled(int64 bytes) {
+ DCHECK_GE(bytes, 0);
+ if (IsEnabled() && ActuallyPrerendering())
+ profile_network_bytes_ += bytes;
+}
+
} // namespace prerender
« no previous file with comments | « chrome/browser/prerender/prerender_manager.h ('k') | chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698