Index: Source/core/loader/DocumentLoader.cpp |
diff --git a/Source/core/loader/DocumentLoader.cpp b/Source/core/loader/DocumentLoader.cpp |
index 81db5347980b3047f6c6f2213481f8e89743b261..04ffea3e9eff86698a3afda3b262519acae0a9d9 100644 |
--- a/Source/core/loader/DocumentLoader.cpp |
+++ b/Source/core/loader/DocumentLoader.cpp |
@@ -103,7 +103,6 @@ DocumentLoader::DocumentLoader(const ResourceRequest& req, const SubstituteData& |
, m_isClientRedirect(false) |
, m_isLoadingMultipartContent(false) |
, m_wasOnloadHandled(false) |
- , m_substituteResourceDeliveryTimer(this, &DocumentLoader::substituteResourceDeliveryTimerFired) |
, m_loadingMainResource(false) |
, m_timeOfLastDataReceived(0.0) |
, m_identifierForLoadWithoutResourceLoader(0) |
@@ -690,8 +689,6 @@ void DocumentLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const |
info.addMember(m_originalRequestCopy, "originalRequestCopy"); |
info.addMember(m_request, "request"); |
info.addMember(m_response, "response"); |
- info.addMember(m_pendingSubstituteResources, "pendingSubstituteResources"); |
- info.addMember(m_substituteResourceDeliveryTimer, "substituteResourceDeliveryTimer"); |
info.addMember(m_archiveResourceCollection, "archiveResourceCollection"); |
info.addMember(m_archive, "archive"); |
info.addMember(m_resourcesClientKnowsAbout, "resourcesClientKnowsAbout"); |
@@ -839,96 +836,23 @@ void DocumentLoader::prepareSubframeArchiveLoadIfNeeded() |
void DocumentLoader::clearArchiveResources() |
{ |
m_archiveResourceCollection.clear(); |
- m_substituteResourceDeliveryTimer.stop(); |
} |
-ArchiveResource* DocumentLoader::archiveResourceForURL(const KURL& url) const |
+bool DocumentLoader::scheduleArchiveLoad(CachedResource* cachedResource, const ResourceRequest& request) |
{ |
- if (!m_archiveResourceCollection) |
- return 0; |
- |
- ArchiveResource* resource = m_archiveResourceCollection->archiveResourceForURL(url); |
- |
- return resource && !resource->shouldIgnoreWhenUnarchiving() ? resource : 0; |
-} |
- |
-void DocumentLoader::deliverSubstituteResourcesAfterDelay() |
-{ |
- if (m_pendingSubstituteResources.isEmpty()) |
- return; |
- ASSERT(m_frame && m_frame->page()); |
- if (m_frame->page()->defersLoading()) |
- return; |
- if (!m_substituteResourceDeliveryTimer.isActive()) |
- m_substituteResourceDeliveryTimer.startOneShot(0); |
-} |
- |
-void DocumentLoader::substituteResourceDeliveryTimerFired(Timer<DocumentLoader>*) |
-{ |
- if (m_pendingSubstituteResources.isEmpty()) |
- return; |
- ASSERT(m_frame && m_frame->page()); |
- if (m_frame->page()->defersLoading()) |
- return; |
- |
- SubstituteResourceMap copy; |
- copy.swap(m_pendingSubstituteResources); |
- |
- SubstituteResourceMap::const_iterator end = copy.end(); |
- for (SubstituteResourceMap::const_iterator it = copy.begin(); it != end; ++it) { |
- RefPtr<ResourceLoader> loader = it->key; |
- SubstituteResource* resource = it->value.get(); |
- |
- if (resource) { |
- SharedBuffer* data = resource->data(); |
- |
- loader->didReceiveResponse(0, resource->response()); |
- |
- // Calling ResourceLoader::didReceiveResponse can end up cancelling the load, |
- // so we need to check if the loader has reached its terminal state. |
- if (loader->reachedTerminalState()) |
- return; |
- |
- loader->didReceiveData(0, data->data(), data->size(), data->size()); |
- |
- // Calling ResourceLoader::didReceiveData can end up cancelling the load, |
- // so we need to check if the loader has reached its terminal state. |
- if (loader->reachedTerminalState()) |
- return; |
- |
- loader->didFinishLoading(0, 0); |
- } 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(0, loader->cannotShowURLError()); |
- } |
- } |
-} |
- |
-#ifndef NDEBUG |
-bool DocumentLoader::isSubstituteLoadPending(ResourceLoader* loader) const |
-{ |
- return m_pendingSubstituteResources.contains(loader); |
-} |
-#endif |
+ if (!m_archive) |
+ return false; |
-void DocumentLoader::cancelPendingSubstituteLoad(ResourceLoader* loader) |
-{ |
- if (m_pendingSubstituteResources.isEmpty()) |
- return; |
- m_pendingSubstituteResources.remove(loader); |
- if (m_pendingSubstituteResources.isEmpty()) |
- m_substituteResourceDeliveryTimer.stop(); |
-} |
+ ASSERT(m_archiveResourceCollection); |
+ ArchiveResource* archiveResource = m_archiveResourceCollection->archiveResourceForURL(request.url()); |
+ ASSERT(archiveResource); |
-bool DocumentLoader::scheduleArchiveLoad(ResourceLoader* loader, const ResourceRequest& request) |
-{ |
- if (ArchiveResource* resource = archiveResourceForURL(request.url())) { |
- m_pendingSubstituteResources.set(loader, resource); |
- deliverSubstituteResourcesAfterDelay(); |
- return true; |
- } |
- return m_archive; |
+ cachedResource->setLoading(true); |
+ SharedBuffer* data = archiveResource->data(); |
+ cachedResource->responseReceived(archiveResource->response()); |
+ cachedResource->appendData(data->data(), data->size()); |
+ cachedResource->finish(); |
+ return true; |
} |
void DocumentLoader::setTitle(const StringWithDirection& title) |
@@ -990,8 +914,6 @@ void DocumentLoader::setDefersLoading(bool defers) |
mainResourceLoader()->setDefersLoading(defers); |
setAllDefersLoading(m_resourceLoaders, defers); |
- if (!defers) |
- deliverSubstituteResourcesAfterDelay(); |
} |
void DocumentLoader::setMainResourceDataBufferingPolicy(DataBufferingPolicy dataBufferingPolicy) |