void DocumentLoader::setupForReplaceByMIMEType(const String& newMIMEType) { if (!mainResourceData()) return; String oldMIMEType = m_response.mimeType(); if (!doesProgressiveLoad(oldMIMEType)) { frameLoader()->client()->revertToProvisionalState(this); setupForReplace(); RefPtr<SharedBuffer> resourceData = mainResourceData(); commitLoad(resourceData->data(), resourceData->size()); } maybeCreateArchive(); m_writer.end(); frameLoader()->setReplacing(); m_gotFirstByte = false; if (doesProgressiveLoad(newMIMEType)) { frameLoader()->client()->revertToProvisionalState(this); setupForReplace(); } stopLoadingSubresources(); stopLoadingPlugIns(); #if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML) clearArchiveResources(); #endif }
void DocumentLoader::setupForReplaceByMIMEType(const String& newMIMEType) { if (!m_gotFirstByte) return; String oldMIMEType = m_response.mimeType(); if (!doesProgressiveLoad(oldMIMEType)) { frameLoader()->revertToProvisional(this); setupForReplace(); RefPtr<SharedBuffer> resourceData = mainResourceData(); commitLoad(resourceData->data(), resourceData->size()); } frameLoader()->finishedLoadingDocument(this); m_frame->loader()->end(); frameLoader()->setReplacing(); m_gotFirstByte = false; if (doesProgressiveLoad(newMIMEType)) { frameLoader()->revertToProvisional(this); setupForReplace(); } stopLoadingSubresources(); stopLoadingPlugIns(); #if ENABLE(ARCHIVE) // ANDROID extension: disabled to reduce code size clearArchiveResources(); #endif }
PassRefPtr<ArchiveResource> DocumentLoader::mainResource() const { const ResourceResponse& r = response(); RefPtr<SharedBuffer> mainResourceBuffer = mainResourceData(); if (!mainResourceBuffer) mainResourceBuffer = SharedBuffer::create(); return ArchiveResource::create(mainResourceBuffer, r.url(), r.mimeType(), r.textEncodingName(), frame()->tree()->name()); }
void DocumentLoader::maybeFinishLoadingMultipartContent() { if (!doesProgressiveLoad(m_response.mimeType())) { frameLoader()->client()->revertToProvisionalState(this); setupForReplace(); RefPtr<SharedBuffer> resourceData = mainResourceData(); commitLoad(resourceData->data(), resourceData->size()); } }
void DocumentLoader::maybeFinishLoadingMultipartContent() { if (!frameLoader()->isReplacing()) return; frameLoader()->setupForReplace(); m_committed = false; RefPtr<ResourceBuffer> resourceData = mainResourceData(); commitLoad(resourceData->data(), resourceData->size()); }
PassRefPtr<ArchiveResource> DocumentLoader::mainResource() const { const ResourceResponse& r = response(); RefPtr<ResourceBuffer> mainResourceBuffer = mainResourceData(); RefPtr<SharedBuffer> data = mainResourceBuffer ? mainResourceBuffer->sharedBuffer() : 0; if (!data) data = SharedBuffer::create(); return ArchiveResource::create(data, r.url(), r.mimeType(), r.textEncodingName(), frame()->tree()->uniqueName()); }
void DocumentLoader::setupForReplace() { if (!mainResourceData()) return; maybeFinishLoadingMultipartContent(); maybeCreateArchive(); m_writer.end(); frameLoader()->setReplacing(); m_gotFirstByte = false; stopLoadingSubresources(); stopLoadingPlugIns(); #if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML) clearArchiveResources(); #endif }
bool DocumentLoader::maybeCreateArchive() { // Give the archive machinery a crack at this document. If the MIME type is not an archive type, it will return 0. if (!isArchiveMIMEType(m_response.mimeType())) return false; m_archive = MHTMLArchive::create(m_response.url(), mainResourceData().get()); ASSERT(m_archive); addAllArchiveResources(m_archive.get()); ArchiveResource* mainResource = m_archive->mainResource(); m_writer.setMIMEType(mainResource->mimeType()); ASSERT(m_frame->document()); commitData(mainResource->data()->data(), mainResource->data()->size()); return true; }
bool DocumentLoader::maybeCreateArchive() { #if !ENABLE(WEB_ARCHIVE) && !ENABLE(MHTML) return false; #else // Give the archive machinery a crack at this document. If the MIME type is not an archive type, it will return 0. m_archive = ArchiveFactory::create(m_response.url(), mainResourceData().get(), m_response.mimeType()); if (!m_archive) return false; addAllArchiveResources(m_archive.get()); ArchiveResource* mainResource = m_archive->mainResource(); m_parsedArchiveData = mainResource->data(); m_writer.setMIMEType(mainResource->mimeType()); ASSERT(m_frame->document()); commitData(mainResource->data()->data(), mainResource->data()->size()); return true; #endif // !ENABLE(WEB_ARCHIVE) && !ENABLE(MHTML) }