Commit 1597b857 authored by Lowell Manners's avatar Lowell Manners Committed by Commit Bot

[bfcache] Properly evict pages when cache is too large.

Calling EvictFromBackForwardCache() is better than directly deleting the
RenderFrameHostImpl, because it matches the behavior when the document
is evicted for other reasons (e.g. cache expiration, use of unsupported
features).

Change-Id: If76feb222b2496fb2431dd20892fd46a1f734bd4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1809163Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Reviewed-by: default avatarArthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Lowell Manners <lowell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697269}
parent 8d89ed8d
...@@ -177,12 +177,14 @@ void BackForwardCache::StoreDocument(std::unique_ptr<RenderFrameHostImpl> rfh) { ...@@ -177,12 +177,14 @@ void BackForwardCache::StoreDocument(std::unique_ptr<RenderFrameHostImpl> rfh) {
size_t size_limit = cache_size_limit_for_testing_ size_t size_limit = cache_size_limit_for_testing_
? cache_size_limit_for_testing_ ? cache_size_limit_for_testing_
: kBackForwardCacheLimit; : kBackForwardCacheLimit;
// Evict the least recently used documents if the BackForwardCache list is
// Remove the last recently used document if the BackForwardCache list is
// full. // full.
if (render_frame_hosts_.size() > size_limit) { size_t available_count = 0;
// TODO(arthursonzogni): Handle RenderFrame deletion appropriately. for (auto& frame_host : render_frame_hosts_) {
render_frame_hosts_.pop_back(); if (frame_host->is_evicted_from_back_forward_cache())
continue;
if (++available_count > size_limit)
frame_host->EvictFromBackForwardCache();
} }
} }
......
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