diff options
Diffstat (limited to 'WebCore/loader/DocumentLoader.cpp')
-rw-r--r-- | WebCore/loader/DocumentLoader.cpp | 137 |
1 files changed, 9 insertions, 128 deletions
diff --git a/WebCore/loader/DocumentLoader.cpp b/WebCore/loader/DocumentLoader.cpp index ffc61df..ddab04f 100644 --- a/WebCore/loader/DocumentLoader.cpp +++ b/WebCore/loader/DocumentLoader.cpp @@ -29,12 +29,16 @@ #include "config.h" #include "DocumentLoader.h" +#ifdef MANUAL_MERGE_REQUIRED #if ENABLE(OFFLINE_WEB_APPLICATIONS) #include "ApplicationCache.h" #include "ApplicationCacheGroup.h" #include "ApplicationCacheResource.h" #endif #if ENABLE(ARCHIVE) // ANDROID extension: disabled to reduce code size +#else // MANUAL_MERGE_REQUIRED +#include "ApplicationCacheHost.h" +#endif // MANUAL_MERGE_REQUIRED #include "ArchiveFactory.h" #include "ArchiveResourceCollection.h" #else @@ -157,7 +161,7 @@ DocumentLoader::DocumentLoader(const ResourceRequest& req, const SubstituteData& , m_substituteResourceDeliveryTimer(this, &DocumentLoader::substituteResourceDeliveryTimerFired) , m_didCreateGlobalHistoryEntry(false) #if ENABLE(OFFLINE_WEB_APPLICATIONS) - , m_candidateApplicationCacheGroup(0) + , m_applicationCacheHost(new ApplicationCacheHost(this)) #endif { } @@ -172,13 +176,6 @@ FrameLoader* DocumentLoader::frameLoader() const DocumentLoader::~DocumentLoader() { ASSERT(!m_frame || frameLoader()->activeDocumentLoader() != this || !frameLoader()->isLoading()); - -#if ENABLE(OFFLINE_WEB_APPLICATIONS) - if (m_applicationCache) - m_applicationCache->group()->disassociateDocumentLoader(this); - else if (m_candidateApplicationCacheGroup) - m_candidateApplicationCacheGroup->disassociateDocumentLoader(this); -#endif } PassRefPtr<SharedBuffer> DocumentLoader::mainResourceData() const @@ -262,14 +259,7 @@ void DocumentLoader::mainReceivedError(const ResourceError& error, bool isComple ASSERT(!error.isNull()); #if ENABLE(OFFLINE_WEB_APPLICATIONS) - ApplicationCacheGroup* group = m_candidateApplicationCacheGroup; - if (!group && m_applicationCache) { - ASSERT(!mainResourceApplicationCache()); // If the main resource were loaded from a cache, it wouldn't fail. - group = m_applicationCache->group(); - } - - if (group) - group->failedLoadingMainResource(this); + m_applicationCacheHost->failedLoadingMainResource(); #endif if (!frameLoader()) @@ -436,6 +426,9 @@ void DocumentLoader::attachToFrame() void DocumentLoader::detachFromFrame() { ASSERT(m_frame); +#if ENABLE(OFFLINE_WEB_APPLICATIONS) + m_applicationCacheHost->setDOMApplicationCache(0); +#endif m_frame = 0; } @@ -457,9 +450,6 @@ void DocumentLoader::setPrimaryLoadComplete(bool flag) if (flag) { if (m_mainResourceLoader) { m_mainResourceData = m_mainResourceLoader->resourceData(); -#if ENABLE(OFFLINE_WEB_APPLICATIONS) - m_mainResourceApplicationCache = m_mainResourceLoader->applicationCache(); -#endif m_mainResourceLoader = 0; } @@ -857,113 +847,4 @@ void DocumentLoader::iconLoadDecisionAvailable() m_frame->loader()->iconLoadDecisionAvailable(); } -#if ENABLE(OFFLINE_WEB_APPLICATIONS) -void DocumentLoader::setCandidateApplicationCacheGroup(ApplicationCacheGroup* group) -{ - ASSERT(!m_applicationCache); - m_candidateApplicationCacheGroup = group; -} - -void DocumentLoader::setApplicationCache(PassRefPtr<ApplicationCache> applicationCache) -{ - if (m_candidateApplicationCacheGroup) { - ASSERT(!m_applicationCache); - m_candidateApplicationCacheGroup = 0; - } - - m_applicationCache = applicationCache; -} - -ApplicationCache* DocumentLoader::mainResourceApplicationCache() const -{ - if (m_mainResourceApplicationCache) - return m_mainResourceApplicationCache.get(); - if (m_mainResourceLoader) - return m_mainResourceLoader->applicationCache(); - return 0; -} - -bool DocumentLoader::shouldLoadResourceFromApplicationCache(const ResourceRequest& request, ApplicationCacheResource*& resource) -{ - ApplicationCache* cache = applicationCache(); - if (!cache || !cache->isComplete()) - return false; - - // If the resource is not a HTTP/HTTPS GET, then abort - if (!ApplicationCache::requestIsHTTPOrHTTPSGet(request)) - return false; - - // If the resource's URL is an master entry, the manifest, an explicit entry, a fallback entry, or a dynamic entry - // in the application cache, then get the resource from the cache (instead of fetching it). - resource = cache->resourceForURL(request.url()); - - // Resources that match fallback namespaces or online whitelist entries are fetched from the network, - // unless they are also cached. - if (!resource && (cache->urlMatchesFallbackNamespace(request.url()) || cache->isURLInOnlineWhitelist(request.url()))) - return false; - - // Resources that are not present in the manifest will always fail to load (at least, after the - // cache has been primed the first time), making the testing of offline applications simpler. - return true; -} - -bool DocumentLoader::getApplicationCacheFallbackResource(const ResourceRequest& request, ApplicationCacheResource*& resource, ApplicationCache* cache) -{ - if (!cache) { - cache = applicationCache(); - if (!cache) - return false; - } - if (!cache->isComplete()) - return false; - - // If the resource is not a HTTP/HTTPS GET, then abort - if (!ApplicationCache::requestIsHTTPOrHTTPSGet(request)) - return false; - - KURL fallbackURL; - if (!cache->urlMatchesFallbackNamespace(request.url(), &fallbackURL)) - return false; - - resource = cache->resourceForURL(fallbackURL); - ASSERT(resource); - - return true; -} - -bool DocumentLoader::scheduleApplicationCacheLoad(ResourceLoader* loader, const ResourceRequest& request, const KURL& originalURL) -{ - if (!frameLoader()->frame()->settings() || !frameLoader()->frame()->settings()->offlineWebApplicationCacheEnabled()) - return false; - - if (request.url() != originalURL) - return false; - - ApplicationCacheResource* resource; - if (!shouldLoadResourceFromApplicationCache(request, resource)) - return false; - - m_pendingSubstituteResources.set(loader, resource); - deliverSubstituteResourcesAfterDelay(); - - return true; -} - -bool DocumentLoader::scheduleLoadFallbackResourceFromApplicationCache(ResourceLoader* loader, const ResourceRequest& request, ApplicationCache* cache) -{ - if (!frameLoader()->frame()->settings() || !frameLoader()->frame()->settings()->offlineWebApplicationCacheEnabled()) - return false; - - ApplicationCacheResource* resource; - if (!getApplicationCacheFallbackResource(request, resource, cache)) - return false; - - m_pendingSubstituteResources.set(loader, resource); - deliverSubstituteResourcesAfterDelay(); - - return true; -} - -#endif // ENABLE(OFFLINE_WEB_APPLICATIONS) - } |