Commit d20c87a4 authored by Hajime Hoshi's avatar Hajime Hoshi Committed by Commit Bot

BackForwardCache: Refactoring: EvictFromBackForwardCacheWithReasons now takes the result

This CL is a pure refactoring. After this change,
BackForwardCacheMetrics can take the full information about storing a
document into the cache.

Bug: 1004676
Change-Id: Ie56dfde2f2d5e0cb6d8507607dfd38f61837a358
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1899630
Commit-Queue: Hajime Hoshi <hajimehoshi@chromium.org>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Reviewed-by: default avatarArthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712914}
parent 1d08b684
......@@ -115,10 +115,6 @@ void BackForwardCacheCanStoreDocumentResult::NoDueToFeatures(
blocklisted_features_ |= features;
}
BackForwardCacheCanStoreDocumentResult::BackForwardCacheCanStoreDocumentResult(
const NotStoredReasons& reasons)
: not_stored_reasons_(reasons) {}
BackForwardCacheCanStoreDocumentResult::
BackForwardCacheCanStoreDocumentResult() = default;
BackForwardCacheCanStoreDocumentResult::BackForwardCacheCanStoreDocumentResult(
......
......@@ -21,8 +21,6 @@ class BackForwardCacheCanStoreDocumentResult {
1ul>;
BackForwardCacheCanStoreDocumentResult();
BackForwardCacheCanStoreDocumentResult(const NotStoredReasons& reasons);
BackForwardCacheCanStoreDocumentResult(
BackForwardCacheCanStoreDocumentResult&&);
BackForwardCacheCanStoreDocumentResult& operator=(
......
......@@ -3719,13 +3719,13 @@ void RenderFrameHostImpl::EvictFromBackForwardCache() {
void RenderFrameHostImpl::EvictFromBackForwardCacheWithReason(
BackForwardCacheMetrics::NotRestoredReason reason) {
BackForwardCacheMetrics::NotRestoredReasons reasons;
reasons.set(static_cast<size_t>(reason));
EvictFromBackForwardCacheWithReasons(reasons);
BackForwardCacheCanStoreDocumentResult can_store;
can_store.No(reason);
EvictFromBackForwardCacheWithReasons(can_store);
}
void RenderFrameHostImpl::EvictFromBackForwardCacheWithReasons(
const BackForwardCacheMetrics::NotRestoredReasons& reasons) {
const BackForwardCacheCanStoreDocumentResult& can_store) {
DCHECK(IsBackForwardCacheEnabled());
if (is_evicted_from_back_forward_cache_)
......@@ -3742,10 +3742,8 @@ void RenderFrameHostImpl::EvictFromBackForwardCacheWithReasons(
// TODO(hajimehoshi): Record the 'race condition' by JavaScript execution when
// |is_in_back_forward_cache()| is false.
BackForwardCacheMetrics* metrics = top_document->GetBackForwardCacheMetrics();
if (is_in_back_forward_cache() && metrics) {
BackForwardCacheCanStoreDocumentResult can_store(reasons);
if (is_in_back_forward_cache() && metrics)
metrics->MarkNotRestoredWithReason(can_store);
}
if (!in_back_forward_cache) {
BackForwardCacheMetrics::RecordEvictedAfterDocumentRestored(
......@@ -7872,9 +7870,7 @@ void RenderFrameHostImpl::MaybeEvictFromBackForwardCache() {
if (can_store)
return;
// TODO(hajimehoshi): Pass and record the other information of |can_store|
// like blocklisted features.
EvictFromBackForwardCacheWithReasons(can_store.not_stored_reasons());
EvictFromBackForwardCacheWithReasons(can_store);
}
void RenderFrameHostImpl::LogCannotCommitOriginCrashKeys(
......
......@@ -329,7 +329,7 @@ class CONTENT_EXPORT RenderFrameHostImpl
void EvictFromBackForwardCacheWithReason(
BackForwardCacheMetrics::NotRestoredReason reason);
void EvictFromBackForwardCacheWithReasons(
const BackForwardCacheMetrics::NotRestoredReasons& reasons);
const BackForwardCacheCanStoreDocumentResult& can_store);
// IPC::Sender
bool Send(IPC::Message* msg) override;
......
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