bfcache: Don't record MaxFrameCount for frames in bfcache
The MaxFrameCount UMA records the maximum number of frames in a page,
and is triggered by RenderFrameDeleted. Since RenderFrameDeleted is not
called on a bfcached frame when we navigate away from it (but will be
called when it is evicted from the bfcache/the tab is closed/etc),
the |max_frame_count_| is already overwritten and should not be
recorded.
Bug: 1010870
Change-Id: I669e91aec29af74d3b9e154356b034b50aeaf75a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1855543
Commit-Queue: Rakina Zata Amni <[email protected]>
Reviewed-by: Alex Moshchuk <[email protected]>
Cr-Commit-Position: refs/heads/master@{#705796}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 98da3ab..3e6ff3e45 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -5428,8 +5428,16 @@
void WebContentsImpl::RenderFrameDeleted(RenderFrameHost* render_frame_host) {
if (!render_frame_host->GetParent() && IsBeingDestroyed() &&
- record_max_frame_count_when_leaving_current_page_) {
+ record_max_frame_count_when_leaving_current_page_ &&
+ !static_cast<RenderFrameHostImpl*>(render_frame_host)
+ ->is_in_back_forward_cache()) {
// Main frame has been deleted because WebContents is being destroyed.
+ // Note that we aren't recording this here when the main frame is in the
+ // back-forward cache because that means we've actually already navigated
+ // away from it (and we got to this point because the WebContents is
+ // deleted), which means |max_frame_count_| is already overwritten.
+ // The |max_frame_count_| value will instead be recorded from within
+ // |WebContentsImpl::ReadyToCommitNavigation()|.
RecordMaxFrameCountUMA(max_frame_count_);
}