Commit 837b694d authored by andersca@apple.com's avatar andersca@apple.com
Browse files

2008-04-17 Anders Carlsson <andersca@apple.com>

        Reviewed by Brady.

        When in the web archive debug mode, don't call didFail immediately. Instead,
        add the loader to the substitute resource map, but with a null resource, which
        indicates to substituteResourceDeliveryTimerFired that the load should fail.
        
        * loader/DocumentLoader.cpp:
        (WebCore::DocumentLoader::substituteResourceDeliveryTimerFired):
        (WebCore::DocumentLoader::scheduleArchiveLoad):
        * loader/ResourceLoader.cpp:
        (WebCore::ResourceLoader::load):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@32017 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 613a1045
2008-04-17 Anders Carlsson <andersca@apple.com>
Reviewed by Brady.
When in the web archive debug mode, don't call didFail immediately. Instead,
add the loader to the substitute resource map, but with a null resource, which
indicates to substituteResourceDeliveryTimerFired that the load should fail.
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::substituteResourceDeliveryTimerFired):
(WebCore::DocumentLoader::scheduleArchiveLoad):
* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::load):
2008-04-17 Anders Carlsson <andersca@apple.com>
 
Reviewed by Sam.
......@@ -31,6 +31,7 @@
#include "ApplicationCache.h"
#include "ApplicationCacheGroup.h"
#include "ArchiveFactory.h"
#include "ArchiveResourceCollection.h"
#include "CachedPage.h"
#include "DocLoader.h"
......@@ -44,6 +45,7 @@
#include "MainResourceLoader.h"
#include "Page.h"
#include "PlatformString.h"
#include "Settings.h"
#include "SharedBuffer.h"
#include "StringBuffer.h"
#include "XMLTokenizer.h"
......@@ -580,11 +582,17 @@ void DocumentLoader::substituteResourceDeliveryTimerFired(Timer<DocumentLoader>*
RefPtr<ResourceLoader> loader = it->first;
SubstituteResource* resource = it->second.get();
SharedBuffer* data = resource->data();
if (resource) {
SharedBuffer* data = resource->data();
loader->didReceiveResponse(resource->response());
loader->didReceiveData(data->data(), data->size(), data->size(), true);
loader->didFinishLoading();
loader->didReceiveResponse(resource->response());
loader->didReceiveData(data->data(), data->size(), data->size(), true);
loader->didFinishLoading();
} else {
// A null resource means that we should fail the load.
// FIXME: Maybe we should use another error here - something like "not in cache".
loader->didFail(loader->cannotShowURLError());
}
}
}
......@@ -606,13 +614,19 @@ void DocumentLoader::cancelPendingSubstituteLoad(ResourceLoader* loader)
bool DocumentLoader::scheduleArchiveLoad(ResourceLoader* loader, const ResourceRequest& request, const KURL& originalURL)
{
if (request.url() != originalURL)
return false;
ArchiveResource* resource = archiveResourceForURL(originalURL);
if (!resource)
return false;
ArchiveResource* resource = 0;
if (request.url() == originalURL)
resource = archiveResourceForURL(originalURL);
if (!resource) {
// WebArchiveDebugMode means we fail loads instead of trying to fetch them from the network if they're not in the archive.
bool shouldFailLoad = m_frame->settings()->webArchiveDebugModeEnabled() && ArchiveFactory::isArchiveMimeType(responseMIMEType());
if (!shouldFailLoad)
return false;
}
m_pendingSubstituteResources.set(loader, resource);
deliverSubstituteResourcesAfterDelay();
......
......@@ -30,7 +30,6 @@
#include "config.h"
#include "ResourceLoader.h"
#include "ArchiveFactory.h"
#include "DocumentLoader.h"
#include "Frame.h"
#include "FrameLoader.h"
......@@ -119,15 +118,6 @@ bool ResourceLoader::load(const ResourceRequest& r)
if (m_documentLoader->scheduleArchiveLoad(this, clientRequest, r.url()))
return true;
// WebArchiveDebugMode means we don't load resources not in the archive. Representing these loads as "cannot show URL" is clear enough
// for developers debugging webarchives
if (m_frame->settings()->webArchiveDebugModeEnabled()) {
if (ArchiveFactory::isArchiveMimeType(m_documentLoader->responseMIMEType())) {
didFail(cannotShowURLError());
return false;
}
}
if (m_defersLoading) {
m_deferredRequest = clientRequest;
return true;
......
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