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

Unified Diff: chrome/browser/page_load_metrics/metrics_web_contents_observer.cc

Issue 2218583002: [page_load_metrics] Log cache warmth ratios at parse stop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add histograms (trybots prev) Created 4 years, 4 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/page_load_metrics/metrics_web_contents_observer.cc
diff --git a/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc b/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
index f34a99596684586f6fd870b85392677e2762b6e4..1c004f9a08c580d8c3f9c6b3e288c747973a9321 100644
--- a/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
+++ b/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
@@ -259,6 +259,10 @@ PageLoadTracker::PageLoadTracker(
abort_type_(ABORT_NONE),
started_in_foreground_(in_foreground),
page_transition_(navigation_handle->GetPageTransition()),
+ cache_subresource_bytes_(0),
+ network_subresource_bytes_(0),
+ cache_requests_(0),
+ network_requests_(0),
aborted_chain_size_(aborted_chain_size),
aborted_chain_size_same_url_(aborted_chain_size_same_url),
embedder_interface_(embedder_interface) {
@@ -478,6 +482,16 @@ bool PageLoadTracker::UpdateTiming(const PageLoadTiming& new_timing,
return false;
}
+void PageLoadTracker::OnLoadedSubresource(int64_t bytes, bool was_cached) {
+ if (was_cached) {
+ ++cache_requests_;
+ cache_subresource_bytes_ += bytes;
+ } else {
+ ++network_requests_;
+ network_subresource_bytes_ += bytes;
+ }
+}
+
void PageLoadTracker::StopTracking() {
did_stop_tracking_ = true;
}
@@ -545,7 +559,8 @@ PageLoadExtraInfo PageLoadTracker::ComputePageLoadExtraInfo() {
return PageLoadExtraInfo(
first_background_time, first_foreground_time, started_in_foreground_,
commit_time_.is_null() ? GURL() : url_, time_to_commit, abort_type_,
- time_to_abort, metadata_);
+ time_to_abort, cache_subresource_bytes_, network_subresource_bytes_,
+ cache_requests_, network_requests_, metadata_);
}
void PageLoadTracker::NotifyAbort(UserAbortType abort_type,
@@ -732,6 +747,23 @@ void MetricsWebContentsObserver::WillStartNavigationRequest(
navigation_handle, chain_size, chain_size_same_url))));
}
+void MetricsWebContentsObserver::OnRequestComplete(
+ content::ResourceType resource_type,
+ bool was_cached,
+ int net_error,
+ int64_t total_received_bytes,
+ int64_t raw_body_bytes) {
+ // For simplicity, only count subresources.
+ if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME &&
+ net_error != net::OK) {
+ return;
+ }
+ if (!committed_load_)
+ return;
+ int64_t bytes = was_cached ? raw_body_bytes : total_received_bytes;
Bryan McQuade 2016/08/08 18:53:28 is raw_body_bytes uncompressed but total_received_
Charlie Harrison 2016/08/08 20:55:02 Great point. I chatted with mmenke@ about this and
+ committed_load_->OnLoadedSubresource(bytes, was_cached);
Bryan McQuade 2016/08/08 18:53:28 are we sure that all resources loaded are for the
Charlie Harrison 2016/08/08 20:55:02 I think this is reasonably accurate. If there are
+}
+
const PageLoadExtraInfo
MetricsWebContentsObserver::GetPageLoadExtraInfoForCommittedLoad() {
DCHECK(committed_load_);

Powered by Google App Engine
This is Rietveld 408576698