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( ...@@ -115,10 +115,6 @@ void BackForwardCacheCanStoreDocumentResult::NoDueToFeatures(
blocklisted_features_ |= features; blocklisted_features_ |= features;
} }
BackForwardCacheCanStoreDocumentResult::BackForwardCacheCanStoreDocumentResult(
const NotStoredReasons& reasons)
: not_stored_reasons_(reasons) {}
BackForwardCacheCanStoreDocumentResult:: BackForwardCacheCanStoreDocumentResult::
BackForwardCacheCanStoreDocumentResult() = default; BackForwardCacheCanStoreDocumentResult() = default;
BackForwardCacheCanStoreDocumentResult::BackForwardCacheCanStoreDocumentResult( BackForwardCacheCanStoreDocumentResult::BackForwardCacheCanStoreDocumentResult(
......
...@@ -21,8 +21,6 @@ class BackForwardCacheCanStoreDocumentResult { ...@@ -21,8 +21,6 @@ class BackForwardCacheCanStoreDocumentResult {
1ul>; 1ul>;
BackForwardCacheCanStoreDocumentResult(); BackForwardCacheCanStoreDocumentResult();
BackForwardCacheCanStoreDocumentResult(const NotStoredReasons& reasons);
BackForwardCacheCanStoreDocumentResult( BackForwardCacheCanStoreDocumentResult(
BackForwardCacheCanStoreDocumentResult&&); BackForwardCacheCanStoreDocumentResult&&);
BackForwardCacheCanStoreDocumentResult& operator=( BackForwardCacheCanStoreDocumentResult& operator=(
......
...@@ -3719,13 +3719,13 @@ void RenderFrameHostImpl::EvictFromBackForwardCache() { ...@@ -3719,13 +3719,13 @@ void RenderFrameHostImpl::EvictFromBackForwardCache() {
void RenderFrameHostImpl::EvictFromBackForwardCacheWithReason( void RenderFrameHostImpl::EvictFromBackForwardCacheWithReason(
BackForwardCacheMetrics::NotRestoredReason reason) { BackForwardCacheMetrics::NotRestoredReason reason) {
BackForwardCacheMetrics::NotRestoredReasons reasons; BackForwardCacheCanStoreDocumentResult can_store;
reasons.set(static_cast<size_t>(reason)); can_store.No(reason);
EvictFromBackForwardCacheWithReasons(reasons); EvictFromBackForwardCacheWithReasons(can_store);
} }
void RenderFrameHostImpl::EvictFromBackForwardCacheWithReasons( void RenderFrameHostImpl::EvictFromBackForwardCacheWithReasons(
const BackForwardCacheMetrics::NotRestoredReasons& reasons) { const BackForwardCacheCanStoreDocumentResult& can_store) {
DCHECK(IsBackForwardCacheEnabled()); DCHECK(IsBackForwardCacheEnabled());
if (is_evicted_from_back_forward_cache_) if (is_evicted_from_back_forward_cache_)
...@@ -3742,10 +3742,8 @@ void RenderFrameHostImpl::EvictFromBackForwardCacheWithReasons( ...@@ -3742,10 +3742,8 @@ void RenderFrameHostImpl::EvictFromBackForwardCacheWithReasons(
// TODO(hajimehoshi): Record the 'race condition' by JavaScript execution when // TODO(hajimehoshi): Record the 'race condition' by JavaScript execution when
// |is_in_back_forward_cache()| is false. // |is_in_back_forward_cache()| is false.
BackForwardCacheMetrics* metrics = top_document->GetBackForwardCacheMetrics(); BackForwardCacheMetrics* metrics = top_document->GetBackForwardCacheMetrics();
if (is_in_back_forward_cache() && metrics) { if (is_in_back_forward_cache() && metrics)
BackForwardCacheCanStoreDocumentResult can_store(reasons);
metrics->MarkNotRestoredWithReason(can_store); metrics->MarkNotRestoredWithReason(can_store);
}
if (!in_back_forward_cache) { if (!in_back_forward_cache) {
BackForwardCacheMetrics::RecordEvictedAfterDocumentRestored( BackForwardCacheMetrics::RecordEvictedAfterDocumentRestored(
...@@ -7872,9 +7870,7 @@ void RenderFrameHostImpl::MaybeEvictFromBackForwardCache() { ...@@ -7872,9 +7870,7 @@ void RenderFrameHostImpl::MaybeEvictFromBackForwardCache() {
if (can_store) if (can_store)
return; return;
// TODO(hajimehoshi): Pass and record the other information of |can_store| EvictFromBackForwardCacheWithReasons(can_store);
// like blocklisted features.
EvictFromBackForwardCacheWithReasons(can_store.not_stored_reasons());
} }
void RenderFrameHostImpl::LogCannotCommitOriginCrashKeys( void RenderFrameHostImpl::LogCannotCommitOriginCrashKeys(
......
...@@ -329,7 +329,7 @@ class CONTENT_EXPORT RenderFrameHostImpl ...@@ -329,7 +329,7 @@ class CONTENT_EXPORT RenderFrameHostImpl
void EvictFromBackForwardCacheWithReason( void EvictFromBackForwardCacheWithReason(
BackForwardCacheMetrics::NotRestoredReason reason); BackForwardCacheMetrics::NotRestoredReason reason);
void EvictFromBackForwardCacheWithReasons( void EvictFromBackForwardCacheWithReasons(
const BackForwardCacheMetrics::NotRestoredReasons& reasons); const BackForwardCacheCanStoreDocumentResult& can_store);
// IPC::Sender // IPC::Sender
bool Send(IPC::Message* msg) override; 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