Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Unified Diff: Source/WebCore/loader/FrameLoader.cpp

Issue 12090050: Revert 138962 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1397/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/WebCore/loader/FrameLoader.h ('k') | Source/WebCore/loader/MainResourceLoader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/loader/FrameLoader.cpp
===================================================================
--- Source/WebCore/loader/FrameLoader.cpp (revision 141117)
+++ Source/WebCore/loader/FrameLoader.cpp (working copy)
@@ -854,7 +854,7 @@
&& !m_frame->document()->loadEventFinished()) {
HistoryItem* childItem = parentItem->childItemWithTarget(childFrame->tree()->uniqueName());
if (childItem) {
- childFrame->loader()->loadDifferentDocumentItem(childItem, loadType(), MayAttemptCacheOnlyLoadForFormSubmissionItem);
+ childFrame->loader()->loadDifferentDocumentItem(childItem, loadType());
return;
}
}
@@ -1463,8 +1463,6 @@
if (!unreachableURL.isEmpty())
request.setURL(unreachableURL);
- // FIXME: If the resource is a result of form submission and is not cached, the form will be silently resubmitted.
- // We should ask the user for confirmation in this case.
request.setCachePolicy(ReturnCacheDataElseLoad);
RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(request, defaultSubstituteDataForURL(request.url()));
@@ -2422,15 +2420,13 @@
void FrameLoader::addExtraFieldsToMainResourceRequest(ResourceRequest& request)
{
- // FIXME: Using m_loadType seems wrong for some callers.
- // If we are only preparing to load the main resource, that is previous load's load type!
addExtraFieldsToRequest(request, m_loadType, true);
}
void FrameLoader::addExtraFieldsToRequest(ResourceRequest& request, FrameLoadType loadType, bool mainResource)
{
// Don't set the cookie policy URL if it's already been set.
- // But make sure to set it on all requests regardless of protocol, as it has significance beyond the cookie policy (<rdar://problem/6616664>).
+ // But make sure to set it on all requests, as it has significance beyond the cookie policy for all protocols (<rdar://problem/6616664>).
if (request.firstPartyForCookies().isEmpty()) {
if (mainResource && isLoadingMainFrame())
request.setFirstPartyForCookies(request.url());
@@ -2443,31 +2439,26 @@
return;
applyUserAgent(request);
-
+
+ // If we inherit cache policy from a main resource, we use the DocumentLoader's
+ // original request cache policy for two reasons:
+ // 1. For POST requests, we mutate the cache policy for the main resource,
+ // but we do not want this to apply to subresources
+ // 2. Delegates that modify the cache policy using willSendRequest: should
+ // not affect any other resources. Such changes need to be done
+ // per request.
if (!mainResource) {
if (request.isConditional())
request.setCachePolicy(ReloadIgnoringCacheData);
- else if (documentLoader()->isLoadingInAPISense()) {
- // If we inherit cache policy from a main resource, we use the DocumentLoader's
- // original request cache policy for two reasons:
- // 1. For POST requests, we mutate the cache policy for the main resource,
- // but we do not want this to apply to subresources
- // 2. Delegates that modify the cache policy using willSendRequest: should
- // not affect any other resources. Such changes need to be done
- // per request.
- ResourceRequestCachePolicy mainDocumentOriginalCachePolicy = documentLoader()->originalRequest().cachePolicy();
- // Back-forward navigations try to load main resource from cache only to avoid re-submitting form data, and start over (with a warning dialog) if that fails.
- // This policy is set on initial request too, but should not be inherited.
- ResourceRequestCachePolicy subresourceCachePolicy = (mainDocumentOriginalCachePolicy == ReturnCacheDataDontLoad) ? ReturnCacheDataElseLoad : mainDocumentOriginalCachePolicy;
- request.setCachePolicy(subresourceCachePolicy);
- } else
+ else if (documentLoader()->isLoadingInAPISense())
+ request.setCachePolicy(documentLoader()->originalRequest().cachePolicy());
+ else
request.setCachePolicy(UseProtocolCachePolicy);
-
- // FIXME: Other FrameLoader functions have duplicated code for setting cache policy of main request when reloading.
- // It seems better to manage it explicitly than to hide the logic inside addExtraFieldsToRequest().
} else if (loadType == FrameLoadTypeReload || loadType == FrameLoadTypeReloadFromOrigin || request.isConditional())
request.setCachePolicy(ReloadIgnoringCacheData);
-
+ else if (isBackForwardLoadType(loadType) && m_stateMachine.committedFirstRealDocumentLoad())
+ request.setCachePolicy(ReturnCacheDataElseLoad);
+
if (request.cachePolicy() == ReloadIgnoringCacheData) {
if (loadType == FrameLoadTypeReload)
request.setHTTPHeaderField("Cache-Control", "max-age=0");
@@ -3051,7 +3042,7 @@
// FIXME: This function should really be split into a couple pieces, some of
// which should be methods of HistoryController and some of which should be
// methods of FrameLoader.
-void FrameLoader::loadDifferentDocumentItem(HistoryItem* item, FrameLoadType loadType, FormSubmissionCacheLoadPolicy cacheLoadPolicy)
+void FrameLoader::loadDifferentDocumentItem(HistoryItem* item, FrameLoadType loadType)
{
// Remember this item so we can traverse any child items as child frames load
history()->setProvisionalItem(item);
@@ -3086,7 +3077,7 @@
// Make sure to add extra fields to the request after the Origin header is added for the FormData case.
// See https://bugs.webkit.org/show_bug.cgi?id=22194 for more discussion.
- addExtraFieldsToRequest(request, loadType, true);
+ addExtraFieldsToRequest(request, m_loadType, true);
// FIXME: Slight hack to test if the NSURL cache contains the page we're going to.
// We want to know this before talking to the policy delegate, since it affects whether
@@ -3096,11 +3087,10 @@
// have the item vanish when we try to use it in the ensuing nav. This should be
// extremely rare, but in that case the user will get an error on the navigation.
- if (cacheLoadPolicy == MayAttemptCacheOnlyLoadForFormSubmissionItem) {
- request.setCachePolicy(ReturnCacheDataDontLoad);
+ if (ResourceHandle::willLoadFromCache(request, m_frame))
action = NavigationAction(request, loadType, false);
- } else {
- request.setCachePolicy(ReturnCacheDataElseLoad);
+ else {
+ request.setCachePolicy(ReloadIgnoringCacheData);
action = NavigationAction(request, NavigationTypeFormResubmitted);
}
} else {
@@ -3114,7 +3104,7 @@
case FrameLoadTypeIndexedBackForward:
// If the first load within a frame is a navigation within a back/forward list that was attached
// without any of the items being loaded then we should use the default caching policy (<rdar://problem/8131355>).
- if (m_stateMachine.committedFirstRealDocumentLoad())
+ if (m_stateMachine.committedFirstRealDocumentLoad() && !itemURL.protocolIs("https"))
request.setCachePolicy(ReturnCacheDataElseLoad);
break;
case FrameLoadTypeStandard:
@@ -3125,7 +3115,7 @@
ASSERT_NOT_REACHED();
}
- addExtraFieldsToRequest(request, loadType, true);
+ addExtraFieldsToRequest(request, m_loadType, true);
ResourceRequest requestForOriginalURL(request);
requestForOriginalURL.setURL(itemOriginalURL);
@@ -3145,25 +3135,9 @@
if (sameDocumentNavigation)
loadSameDocumentItem(item);
else
- loadDifferentDocumentItem(item, loadType, MayAttemptCacheOnlyLoadForFormSubmissionItem);
+ loadDifferentDocumentItem(item, loadType);
}
-void FrameLoader::retryAfterFailedCacheOnlyMainResourceLoad()
-{
- ASSERT(m_state == FrameStateProvisional);
- ASSERT(!m_loadingFromCachedPage);
- // We only use cache-only loads to avoid resubmitting forms.
- ASSERT(isBackForwardLoadType(m_loadType));
- ASSERT(m_history.provisionalItem()->formData());
- ASSERT(m_history.provisionalItem() == m_requestedHistoryItem.get());
-
- FrameLoadType loadType = m_loadType;
- HistoryItem* item = m_history.provisionalItem();
-
- stopAllLoaders(ShouldNotClearProvisionalItem);
- loadDifferentDocumentItem(item, loadType, MayNotAttemptCacheOnlyLoadForFormSubmissionItem);
-}
-
ResourceError FrameLoader::cancelledError(const ResourceRequest& request) const
{
ResourceError error = m_client->cancelledError(request);
« no previous file with comments | « Source/WebCore/loader/FrameLoader.h ('k') | Source/WebCore/loader/MainResourceLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698