2009-07-30 Michael Nordman <michaeln@google.com>
Reviewed by Darin Fisher.
https://bugs.webkit.org/show_bug.cgi?id=27821
ApplicationCacheHost refactoring.
1) Better encapsulate the interfaces between webcore common code
and the appcache system within a new class ApplicationCacheHost.
2) Use that interface throughout the loader system, replacing inline appcache logic.
3) Implement the interface in terms of webcore's appcache system.
4) Add the new files to various makefiles.
5) Implement protocolHostAndPortAreEqual() in KURLGoogle.cpp
No new features, no new tests. The existing layout tests all pass.
* GNUmakefile.am:
* WebCore.base.exp:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* WebCoreSources.bkl:
* html/HTMLHtmlElement.cpp:
(WebCore::HTMLHtmlElement::insertedIntoDocument):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::DocumentLoader):
(WebCore::DocumentLoader::~DocumentLoader):
(WebCore::DocumentLoader::mainReceivedError):
(WebCore::DocumentLoader::detachFromFrame):
(WebCore::DocumentLoader::setPrimaryLoadComplete):
* loader/DocumentLoader.h:
(WebCore::DocumentLoader::applicationCacheHost):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::canCachePageContainingThisFrame):
(WebCore::FrameLoader::logCanCacheFrameDecision):
(WebCore::FrameLoader::loadResourceSynchronously):
* loader/MainResourceLoader.cpp:
(WebCore::MainResourceLoader::didReceiveResponse):
(WebCore::MainResourceLoader::didReceiveData):
(WebCore::MainResourceLoader::didFinishLoading):
(WebCore::MainResourceLoader::didFail):
(WebCore::MainResourceLoader::load):
* loader/MainResourceLoader.h:
* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::load):
(WebCore::ResourceLoader::willSendRequest):
(WebCore::ResourceLoader::didReceiveResponse):
(WebCore::ResourceLoader::didFail):
* loader/ResourceLoader.h:
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::selectCache):
(WebCore::ApplicationCacheGroup::selectCacheWithoutManifestURL):
(WebCore::ApplicationCacheGroup::finishedLoadingMainResource):
(WebCore::ApplicationCacheGroup::failedLoadingMainResource):
(WebCore::ApplicationCacheGroup::disassociateDocumentLoader):
(WebCore::ApplicationCacheGroup::update):
(WebCore::ApplicationCacheGroup::didFinishLoadingManifest):
(WebCore::ApplicationCacheGroup::manifestNotFound):
(WebCore::ApplicationCacheGroup::checkIfLoadIsComplete):
(WebCore::ApplicationCacheGroup::startLoadingEntry):
(WebCore::ApplicationCacheGroup::associateDocumentLoaderWithCache):
(WebCore::CallCacheListenerTask::create):
(WebCore::CallCacheListenerTask::performTask):
(WebCore::CallCacheListenerTask::CallCacheListenerTask):
(WebCore::ApplicationCacheGroup::postListenerTask):
* loader/appcache/ApplicationCacheGroup.h:
* loader/appcache/ApplicationCacheHost.cpp: Added.
* loader/appcache/ApplicationCacheHost.h: Added.
* loader/appcache/ApplicationCacheStorage.cpp:
(WebCore::ApplicationCacheStorage::transferApplicationCache):
* loader/appcache/ApplicationCacheStorage.h:
* loader/appcache/DOMApplicationCache.cpp:
(WebCore::DOMApplicationCache::DOMApplicationCache):
(WebCore::DOMApplicationCache::disconnectFrame):
(WebCore::DOMApplicationCache::applicationCacheHost):
(WebCore::DOMApplicationCache::status):
(WebCore::DOMApplicationCache::update):
(WebCore::DOMApplicationCache::swapCache):
(WebCore::DOMApplicationCache::addEventListener):
(WebCore::DOMApplicationCache::removeEventListener):
(WebCore::DOMApplicationCache::dispatchEvent):
(WebCore::DOMApplicationCache::callListener):
(WebCore::DOMApplicationCache::toEventName):
(WebCore::DOMApplicationCache::toEventType):
* loader/appcache/DOMApplicationCache.h:
(WebCore::DOMApplicationCache::):
(WebCore::DOMApplicationCache::setAttributeEventListener):
(WebCore::DOMApplicationCache::getAttributeEventListener):
(WebCore::DOMApplicationCache::clearAttributeEventListener):
(WebCore::DOMApplicationCache::callEventListener):
(WebCore::DOMApplicationCache::setOnchecking):
(WebCore::DOMApplicationCache::onchecking):
(WebCore::DOMApplicationCache::setOnerror):
(WebCore::DOMApplicationCache::onerror):
(WebCore::DOMApplicationCache::setOnnoupdate):
(WebCore::DOMApplicationCache::onnoupdate):
(WebCore::DOMApplicationCache::setOndownloading):
(WebCore::DOMApplicationCache::ondownloading):
(WebCore::DOMApplicationCache::setOnprogress):
(WebCore::DOMApplicationCache::onprogress):
(WebCore::DOMApplicationCache::setOnupdateready):
(WebCore::DOMApplicationCache::onupdateready):
(WebCore::DOMApplicationCache::setOncached):
(WebCore::DOMApplicationCache::oncached):
(WebCore::DOMApplicationCache::setOnobsolete):
(WebCore::DOMApplicationCache::onobsolete):
(WebCore::DOMApplicationCache::~DOMApplicationCache):
* platform/KURLGoogle.cpp:
(WebCore::protocolHostAndPortAreEqual):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@46609 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp
index 9fe5adc..b7cb365 100644
--- a/WebCore/loader/FrameLoader.cpp
+++ b/WebCore/loader/FrameLoader.cpp
@@ -95,8 +95,7 @@
#include <wtf/StdLibExtras.h>
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
-#include "ApplicationCache.h"
-#include "ApplicationCacheResource.h"
+#include "ApplicationCacheHost.h"
#endif
#if ENABLE(SVG)
@@ -1816,8 +1815,7 @@
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
// FIXME: We should investigating caching frames that have an associated
// application cache. <rdar://problem/5917899> tracks that work.
- && !m_documentLoader->applicationCache()
- && !m_documentLoader->candidateApplicationCacheGroup()
+ && m_documentLoader->applicationCacheHost()->canCacheInPageCache()
#endif
#if ENABLE(WML)
&& !frameContainsWMLContent(m_frame)
@@ -1967,10 +1965,8 @@
if (!m_frame->document()->canSuspendActiveDOMObjects())
{ PCLOG(" -The document cannot suspect its active DOM Objects"); cannotCache = true; }
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
- if (m_documentLoader->applicationCache())
- { PCLOG(" -The DocumentLoader has an active application cache"); cannotCache = true; }
- if (m_documentLoader->candidateApplicationCacheGroup())
- { PCLOG(" -The DocumentLoader has a candidateApplicationCacheGroup"); cannotCache = true; }
+ if (!m_documentLoader->applicationCacheHost()->canCacheInPageCache())
+ { PCLOG(" -The DocumentLoader uses an application cache"); cannotCache = true; }
#endif
if (!m_client->canCachePage())
{ PCLOG(" -The client says this frame cannot be cached"); cannotCache = true; }
@@ -3681,30 +3677,11 @@
ASSERT(!newRequest.isNull());
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
- ApplicationCacheResource* resource;
- if (documentLoader()->shouldLoadResourceFromApplicationCache(newRequest, resource)) {
- if (resource) {
- response = resource->response();
- data.append(resource->data()->data(), resource->data()->size());
- } else
- error = cannotShowURLError(newRequest);
- } else {
+ if (!documentLoader()->applicationCacheHost()->maybeLoadSynchronously(newRequest, error, response, data)) {
#endif
ResourceHandle::loadResourceSynchronously(newRequest, storedCredentials, error, response, data, m_frame);
-
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
- // If normal loading results in a redirect to a resource with another origin (indicative of a captive portal), or a 4xx or 5xx status code or equivalent,
- // or if there were network errors (but not if the user canceled the download), then instead get, from the cache, the resource of the fallback entry
- // corresponding to the matched namespace.
- if ((!error.isNull() && !error.isCancellation())
- || response.httpStatusCode() / 100 == 4 || response.httpStatusCode() / 100 == 5
- || !protocolHostAndPortAreEqual(newRequest.url(), response.url())) {
- if (documentLoader()->getApplicationCacheFallbackResource(newRequest, resource)) {
- response = resource->response();
- data.clear();
- data.append(resource->data()->data(), resource->data()->size());
- }
- }
+ documentLoader()->applicationCacheHost()->maybeLoadFallbackSynchronously(newRequest, error, response, data);
}
#endif
}