Commit f9053efc authored by Alexander Timin's avatar Alexander Timin Committed by Commit Bot

[bfcache] Add more trace events for bfcache

Restarting bfcached navigations (e.g. when we evict after the document
was restored) is potentially problematic - add trace events to ensure
that the problems are easy to diagnose.

R=alexmos@chromium.org

Change-Id: Ia1a888889e52d9e9a0aaec7119833a851060d234
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1930151
Commit-Queue: Alexander Timin <altimin@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722412}
parent 461f6587
......@@ -2576,6 +2576,7 @@ void NavigationControllerImpl::NavigateToExistingPendingEntry(
// BackForwardCache:
// Navigate immediately if the document is in the BackForwardCache.
if (back_forward_cache_.GetEntry(nav_entry_id)) {
TRACE_EVENT0("navigation", "BackForwardCache_CreateNavigationRequest");
DCHECK_EQ(reload_type, ReloadType::NONE);
auto navigation_request = CreateNavigationRequestFromEntry(
root, pending_entry_, pending_entry_->GetFrameEntry(root),
......
......@@ -3892,6 +3892,8 @@ void NavigationRequest::SetSourceSiteInstanceToInitiatorIfNeeded() {
}
void NavigationRequest::RestartBackForwardCachedNavigation() {
TRACE_EVENT0("navigation",
"NavigationRequest::RestartBackForwardCachedNavigation");
CHECK(IsServedFromBackForwardCache());
restarting_back_forward_cached_navigation_ = true;
base::PostTask(
......@@ -3901,6 +3903,8 @@ void NavigationRequest::RestartBackForwardCachedNavigation() {
}
void NavigationRequest::RestartBackForwardCachedNavigationImpl() {
TRACE_EVENT0("navigation",
"NavigationRequest::RestartBackForwardCachedNavigationImpl");
RenderFrameHostImpl* rfh = rfh_restored_from_back_forward_cache();
CHECK(rfh);
CHECK_EQ(rfh->frame_tree_node()->navigation_request(), this);
......
......@@ -1175,6 +1175,7 @@ void RenderFrameHostImpl::AudioContextPlaybackStopped(int audio_context_id) {
// The current frame went into the BackForwardCache.
void RenderFrameHostImpl::EnterBackForwardCache() {
TRACE_EVENT0("navigation", "RenderFrameHostImpl::EnterBackForwardCache");
DCHECK(IsBackForwardCacheEnabled());
DCHECK(!is_in_back_forward_cache_);
is_in_back_forward_cache_ = true;
......@@ -1204,6 +1205,7 @@ void RenderFrameHostImpl::EnterBackForwardCache() {
// The frame as been restored from the BackForwardCache.
void RenderFrameHostImpl::LeaveBackForwardCache() {
TRACE_EVENT0("navigation", "RenderFrameHostImpl::LeaveBackForwardCache");
DCHECK(IsBackForwardCacheEnabled());
DCHECK(is_in_back_forward_cache_);
is_in_back_forward_cache_ = false;
......@@ -3796,6 +3798,8 @@ void RenderFrameHostImpl::EvictFromBackForwardCacheWithReasons(
metrics->MarkNotRestoredWithReason(can_store);
if (!in_back_forward_cache) {
TRACE_EVENT0("navigation", "BackForwardCache_EvictAfterDocumentRestored");
BackForwardCacheMetrics::RecordEvictedAfterDocumentRestored(
BackForwardCacheMetrics::EvictedAfterDocumentRestoredReason::
kByJavaScript);
......
......@@ -616,6 +616,8 @@ bool RenderFrameHostManager::DeleteFromPendingList(
void RenderFrameHostManager::RestoreFromBackForwardCache(
std::unique_ptr<BackForwardCacheImpl::Entry> entry) {
TRACE_EVENT0("navigation",
"RenderFrameHostManager::RestoreFromBackForwardCache");
// Matched in CommitPending().
entry->render_frame_host->GetProcess()->AddPendingView();
......
......@@ -405,6 +405,7 @@ void RenderViewHostImpl::SetMainFrameRoutingId(int routing_id) {
}
void RenderViewHostImpl::EnterBackForwardCache() {
TRACE_EVENT0("navigation", "RenderViewHostImpl::EnterBackForwardCache");
FrameTree* frame_tree = GetDelegate()->GetFrameTree();
frame_tree->UnregisterRenderViewHost(this);
is_in_back_forward_cache_ = true;
......@@ -414,6 +415,7 @@ void RenderViewHostImpl::EnterBackForwardCache() {
void RenderViewHostImpl::LeaveBackForwardCache(
base::TimeTicks navigation_start) {
TRACE_EVENT0("navigation", "RenderViewHostImpl::LeaveBackForwardCache");
FrameTree* frame_tree = GetDelegate()->GetFrameTree();
// At this point, the frames |this| RenderViewHostImpl belongs to are
// guaranteed to be committed, so it should be reused going forward.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment