Diff
Modified: branches/chromium/1397/Source/WebCore/html/HTMLAnchorElement.cpp (141117 => 141118)
--- branches/chromium/1397/Source/WebCore/html/HTMLAnchorElement.cpp 2013-01-29 16:51:32 UTC (rev 141117)
+++ branches/chromium/1397/Source/WebCore/html/HTMLAnchorElement.cpp 2013-01-29 16:54:27 UTC (rev 141118)
@@ -509,7 +509,6 @@
if (hasAttribute(downloadAttr)) {
ResourceRequest request(kurl);
- // FIXME: Why are we not calling addExtraFieldsToMainResourceRequest() if this check fails? It sets many important header fields.
if (!hasRel(RelationNoReferrer)) {
String referrer = SecurityPolicy::generateReferrerHeader(document()->referrerPolicy(), kurl, frame->loader()->outgoingReferrer());
if (!referrer.isEmpty())
Modified: branches/chromium/1397/Source/WebCore/loader/DocumentLoader.cpp (141117 => 141118)
--- branches/chromium/1397/Source/WebCore/loader/DocumentLoader.cpp 2013-01-29 16:51:32 UTC (rev 141117)
+++ branches/chromium/1397/Source/WebCore/loader/DocumentLoader.cpp 2013-01-29 16:54:27 UTC (rev 141118)
@@ -894,8 +894,6 @@
// FIXME: Is there any way the extra fields could have not been added by now?
// If not, it would be great to remove this line of code.
- // Note that currently, some requests may have incorrect extra fields even if this function has been called,
- // because we pass a wrong loadType (see FIXME in addExtraFieldsToMainResourceRequest()).
frameLoader()->addExtraFieldsToMainResourceRequest(m_request);
m_mainResourceLoader->load(m_request, m_substituteData);
Modified: branches/chromium/1397/Source/WebCore/loader/FrameLoader.cpp (141117 => 141118)
--- branches/chromium/1397/Source/WebCore/loader/FrameLoader.cpp 2013-01-29 16:51:32 UTC (rev 141117)
+++ branches/chromium/1397/Source/WebCore/loader/FrameLoader.cpp 2013-01-29 16:54:27 UTC (rev 141118)
@@ -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 = "" loadType, false);
- } else {
- request.setCachePolicy(ReturnCacheDataElseLoad);
+ else {
+ request.setCachePolicy(ReloadIgnoringCacheData);
action = "" 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);
Modified: branches/chromium/1397/Source/WebCore/loader/FrameLoader.h (141117 => 141118)
--- branches/chromium/1397/Source/WebCore/loader/FrameLoader.h 2013-01-29 16:51:32 UTC (rev 141117)
+++ branches/chromium/1397/Source/WebCore/loader/FrameLoader.h 2013-01-29 16:54:27 UTC (rev 141118)
@@ -123,8 +123,6 @@
void loadItem(HistoryItem*, FrameLoadType);
HistoryItem* requestedHistoryItem() const { return m_requestedHistoryItem.get(); }
- void retryAfterFailedCacheOnlyMainResourceLoad();
-
static void reportLocalLoadFailed(Frame*, const String& url);
// FIXME: These are all functions which stop loads. We have too many.
@@ -284,17 +282,12 @@
void reportMemoryUsage(MemoryObjectInfo*) const;
private:
- enum FormSubmissionCacheLoadPolicy {
- MayAttemptCacheOnlyLoadForFormSubmissionItem,
- MayNotAttemptCacheOnlyLoadForFormSubmissionItem
- };
-
bool allChildrenAreComplete() const; // immediate children, not all descendants
void checkTimerFired(Timer<FrameLoader>*);
void loadSameDocumentItem(HistoryItem*);
- void loadDifferentDocumentItem(HistoryItem*, FrameLoadType, FormSubmissionCacheLoadPolicy);
+ void loadDifferentDocumentItem(HistoryItem*, FrameLoadType);
void loadProvisionalItemFromCachedPage();
Modified: branches/chromium/1397/Source/WebCore/loader/MainResourceLoader.cpp (141117 => 141118)
--- branches/chromium/1397/Source/WebCore/loader/MainResourceLoader.cpp 2013-01-29 16:51:32 UTC (rev 141117)
+++ branches/chromium/1397/Source/WebCore/loader/MainResourceLoader.cpp 2013-01-29 16:54:27 UTC (rev 141118)
@@ -548,17 +548,11 @@
void MainResourceLoader::notifyFinished(CachedResource* resource)
{
ASSERT_UNUSED(resource, m_resource == resource);
- ASSERT(m_resource);
- if (!m_resource->errorOccurred() && !m_resource->wasCanceled()) {
+ if (!m_resource || (!m_resource->errorOccurred() && !m_resource->wasCanceled())) {
didFinishLoading(m_resource->loadFinishTime());
return;
}
- if (m_documentLoader->request().cachePolicy() == ReturnCacheDataDontLoad && !m_resource->wasCanceled()) {
- frameLoader()->retryAfterFailedCacheOnlyMainResourceLoad();
- return;
- }
-
const ResourceError& error = m_resource->resourceError();
if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForMainError(request(), error))
return;
Modified: branches/chromium/1397/Source/WebCore/platform/network/ResourceHandle.h (141117 => 141118)
--- branches/chromium/1397/Source/WebCore/platform/network/ResourceHandle.h 2013-01-29 16:51:32 UTC (rev 141117)
+++ branches/chromium/1397/Source/WebCore/platform/network/ResourceHandle.h 2013-01-29 16:54:27 UTC (rev 141118)
@@ -100,6 +100,7 @@
static PassRefPtr<ResourceHandle> create(NetworkingContext*, const ResourceRequest&, ResourceHandleClient*, bool defersLoading, bool shouldContentSniff);
static void loadResourceSynchronously(NetworkingContext*, const ResourceRequest&, StoredCredentials, ResourceError&, ResourceResponse&, Vector<char>& data);
+ static bool willLoadFromCache(ResourceRequest&, Frame*);
static void cacheMetadata(const ResourceResponse&, const Vector<char>&);
virtual ~ResourceHandle();
Modified: branches/chromium/1397/Source/WebCore/platform/network/blackberry/ResourceHandleBlackBerry.cpp (141117 => 141118)
--- branches/chromium/1397/Source/WebCore/platform/network/blackberry/ResourceHandleBlackBerry.cpp 2013-01-29 16:51:32 UTC (rev 141117)
+++ branches/chromium/1397/Source/WebCore/platform/network/blackberry/ResourceHandleBlackBerry.cpp 2013-01-29 16:54:27 UTC (rev 141118)
@@ -126,6 +126,12 @@
NetworkManager::instance()->pauseLoad(this, pause);
}
+bool ResourceHandle::willLoadFromCache(ResourceRequest&, Frame*)
+{
+ notImplemented();
+ return false;
+}
+
void ResourceHandle::cancel()
{
NetworkManager::instance()->stopJob(this);
Modified: branches/chromium/1397/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp (141117 => 141118)
--- branches/chromium/1397/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp 2013-01-29 16:51:32 UTC (rev 141117)
+++ branches/chromium/1397/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp 2013-01-29 16:54:27 UTC (rev 141118)
@@ -808,6 +808,23 @@
return false;
}
+bool ResourceHandle::willLoadFromCache(ResourceRequest& request, Frame*)
+{
+ request.setCachePolicy(ReturnCacheDataDontLoad);
+
+ CFURLResponseRef cfResponse = 0;
+ CFErrorRef cfError = 0;
+ RetainPtr<CFDataRef> data = "" &cfResponse, &cfError, request.timeoutInterval()));
+ bool cached = cfResponse && !cfError;
+
+ if (cfError)
+ CFRelease(cfError);
+ if (cfResponse)
+ CFRelease(cfResponse);
+
+ return cached;
+}
+
#if PLATFORM(MAC)
void ResourceHandle::schedule(SchedulePair* pair)
{
Modified: branches/chromium/1397/Source/WebCore/platform/network/chromium/ResourceHandle.cpp (141117 => 141118)
--- branches/chromium/1397/Source/WebCore/platform/network/chromium/ResourceHandle.cpp 2013-01-29 16:51:32 UTC (rev 141117)
+++ branches/chromium/1397/Source/WebCore/platform/network/chromium/ResourceHandle.cpp 2013-01-29 16:54:27 UTC (rev 141118)
@@ -277,6 +277,22 @@
}
// static
+bool ResourceHandle::willLoadFromCache(ResourceRequest& request, Frame*)
+{
+ // This method is used to determine if a POST request can be repeated from
+ // cache, but you cannot really know until you actually try to read from the
+ // cache. Even if we checked now, something else could come along and wipe
+ // out the cache entry by the time we fetch it.
+ //
+ // So, we always say yes here, to prevent the FrameLoader from initiating a
+ // reload. Then in FrameLoaderClientImpl::dispatchWillSendRequest, we
+ // fix-up the cache policy of the request to force a load from the cache.
+ //
+ ASSERT(request.httpMethod() == "POST");
+ return true;
+}
+
+// static
void ResourceHandle::cacheMetadata(const ResourceResponse& response, const Vector<char>& data)
{
WebKit::Platform::current()->cacheMetadata(response.url(), response.responseTime(), data.data(), data.size());
Modified: branches/chromium/1397/Source/WebCore/platform/network/curl/ResourceHandleCurl.cpp (141117 => 141118)
--- branches/chromium/1397/Source/WebCore/platform/network/curl/ResourceHandleCurl.cpp 2013-01-29 16:51:32 UTC (rev 141117)
+++ branches/chromium/1397/Source/WebCore/platform/network/curl/ResourceHandleCurl.cpp 2013-01-29 16:54:27 UTC (rev 141118)
@@ -166,6 +166,12 @@
#endif
}
+bool ResourceHandle::willLoadFromCache(ResourceRequest&, Frame*)
+{
+ notImplemented();
+ return false;
+}
+
bool ResourceHandle::loadsBlocked()
{
notImplemented();
Modified: branches/chromium/1397/Source/WebCore/platform/network/mac/ResourceHandleMac.mm (141117 => 141118)
--- branches/chromium/1397/Source/WebCore/platform/network/mac/ResourceHandleMac.mm 2013-01-29 16:51:32 UTC (rev 141117)
+++ branches/chromium/1397/Source/WebCore/platform/network/mac/ResourceHandleMac.mm 2013-01-29 16:54:27 UTC (rev 141118)
@@ -357,6 +357,19 @@
return false;
}
+bool ResourceHandle::willLoadFromCache(ResourceRequest& request, Frame*)
+{
+ request.setCachePolicy(ReturnCacheDataDontLoad);
+ NSURLResponse *nsURLResponse = nil;
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+
+ [NSURLConnection sendSynchronousRequest:request.nsURLRequest() returningResponse:&nsURLResponse error:nil];
+
+ END_BLOCK_OBJC_EXCEPTIONS;
+
+ return nsURLResponse;
+}
+
CFStringRef ResourceHandle::synchronousLoadRunLoopMode()
{
return CFSTR("WebCoreSynchronousLoaderRunLoopMode");
Modified: branches/chromium/1397/Source/WebCore/platform/network/qt/ResourceHandleQt.cpp (141117 => 141118)
--- branches/chromium/1397/Source/WebCore/platform/network/qt/ResourceHandleQt.cpp 2013-01-29 16:51:32 UTC (rev 141117)
+++ branches/chromium/1397/Source/WebCore/platform/network/qt/ResourceHandleQt.cpp 2013-01-29 16:54:27 UTC (rev 141118)
@@ -125,6 +125,30 @@
return false;
}
+bool ResourceHandle::willLoadFromCache(ResourceRequest& request, Frame* frame)
+{
+ if (!frame)
+ return false;
+
+ QNetworkAccessManager* manager = 0;
+ QAbstractNetworkCache* cache = 0;
+ if (frame->loader()->networkingContext()) {
+ manager = frame->loader()->networkingContext()->networkAccessManager();
+ cache = manager->cache();
+ }
+
+ if (!cache)
+ return false;
+
+ QNetworkCacheMetaData data = ""
+ if (data.isValid()) {
+ request.setCachePolicy(ReturnCacheDataDontLoad);
+ return true;
+ }
+
+ return false;
+}
+
void ResourceHandle::loadResourceSynchronously(NetworkingContext* context, const ResourceRequest& request, StoredCredentials /*storedCredentials*/, ResourceError& error, ResourceResponse& response, Vector<char>& data)
{
#if ENABLE(BLOB)
Modified: branches/chromium/1397/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp (141117 => 141118)
--- branches/chromium/1397/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp 2013-01-29 16:51:32 UTC (rev 141117)
+++ branches/chromium/1397/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp 2013-01-29 16:54:27 UTC (rev 141118)
@@ -1286,6 +1286,14 @@
return false;
}
+bool ResourceHandle::willLoadFromCache(ResourceRequest&, Frame*)
+{
+ // Not having this function means that we'll ask the user about re-posting a form
+ // even when we go back to a page that's still in the cache.
+ notImplemented();
+ return false;
+}
+
void ResourceHandle::loadResourceSynchronously(NetworkingContext* context, const ResourceRequest& request, StoredCredentials /*storedCredentials*/, ResourceError& error, ResourceResponse& response, Vector<char>& data)
{
#if ENABLE(BLOB)
Modified: branches/chromium/1397/Source/WebCore/platform/network/win/ResourceHandleWin.cpp (141117 => 141118)
--- branches/chromium/1397/Source/WebCore/platform/network/win/ResourceHandleWin.cpp 2013-01-29 16:51:32 UTC (rev 141117)
+++ branches/chromium/1397/Source/WebCore/platform/network/win/ResourceHandleWin.cpp 2013-01-29 16:54:27 UTC (rev 141118)
@@ -431,6 +431,12 @@
d->m_loadSynchronously = true;
}
+bool ResourceHandle::willLoadFromCache(ResourceRequest&, Frame*)
+{
+ notImplemented();
+ return false;
+}
+
void prefetchDNS(const String&)
{
notImplemented();