diff options
author | davidben@chromium.org <davidben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-09 07:32:26 +0000 |
---|---|---|
committer | davidben@chromium.org <davidben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-09 07:32:26 +0000 |
commit | a8ff8ed57ec5efe39e7099f9973eb439e4b6bf96 (patch) | |
tree | b1f53b9205efdf3a543ddd84a3a0430814edc55a /content/renderer | |
parent | 944eaefd870eb3e3a246d8b165c3afd7b2349bf9 (diff) | |
download | chromium_src-a8ff8ed57ec5efe39e7099f9973eb439e4b6bf96.zip chromium_src-a8ff8ed57ec5efe39e7099f9973eb439e4b6bf96.tar.gz chromium_src-a8ff8ed57ec5efe39e7099f9973eb439e4b6bf96.tar.bz2 |
Override cache policy when changing a reload to a back/forward navigation.
In some cases, the RenderView performs a history navigation in response to a
reload when the WebFrame does not have the page in question committed. Override
the cache policy so the navigation revalidates the cache, rather than skipping
revalidation altogether.
BUG=331386
TEST=CrashRecoveryBrowserTest.ReloadCacheRevalidate
Review URL: https://codereview.chromium.org/101203007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243796 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer')
-rw-r--r-- | content/renderer/render_view_impl.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 3f5319e..0faf360 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -1361,6 +1361,8 @@ void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { FOR_EACH_OBSERVER(RenderViewObserver, observers_, Navigate(params.url)); bool is_reload = IsReload(params); + WebURLRequest::CachePolicy cache_policy = + WebURLRequest::UseProtocolCachePolicy; // If this is a stale back/forward (due to a recent navigation the browser // didn't know about), ignore it. @@ -1378,6 +1380,7 @@ void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { // params.state. Setting is_reload to false will treat this like a back // navigation to accomplish that. is_reload = false; + cache_policy = WebURLRequest::ReloadIgnoringCacheData; // We refresh timezone when a view is swapped in since timezone // can get out of sync when the system timezone is updated while @@ -1411,10 +1414,9 @@ void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { if (is_reload && frame->currentHistoryItem().isNull()) { // We cannot reload if we do not have any history state. This happens, for - // example, when recovering from a crash. Our workaround here is a bit of - // a hack since it means that reload after a crashed tab does not cause an - // end-to-end cache validation. + // example, when recovering from a crash. is_reload = false; + cache_policy = WebURLRequest::ReloadIgnoringCacheData; } pending_navigation_params_.reset(new ViewMsg_Navigate_Params(params)); @@ -1442,7 +1444,7 @@ void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { // Ensure we didn't save the swapped out URL in UpdateState, since the // browser should never be telling us to navigate to swappedout://. CHECK(item.urlString() != WebString::fromUTF8(kSwappedOutURL)); - frame->loadHistoryItem(item); + frame->loadHistoryItem(item, cache_policy); } } else if (!params.base_url_for_data_url.is_empty()) { // A loadData request with a specified base URL. @@ -3461,6 +3463,11 @@ void RenderViewImpl::PopulateDocumentStateFromPending( // can result in stale data for pages that are set to expire. We explicitly // override that by setting the policy here so that as necessary we load // from the network. + // + // TODO(davidben): Remove this in favor of passing a cache policy to the + // loadHistoryItem call in OnNavigate. That requires not overloading + // UseProtocolCachePolicy to mean both "normal load" and "determine cache + // policy based on load type, etc". internal_data->set_cache_policy_override( WebURLRequest::UseProtocolCachePolicy); } |