summaryrefslogtreecommitdiffstats
path: root/WebCore/loader/MainResourceLoader.cpp
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2009-08-11 17:01:47 +0100
committerBen Murdoch <benm@google.com>2009-08-11 18:21:02 +0100
commit0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5 (patch)
tree2943df35f62d885c89d01063cc528dd73b480fea /WebCore/loader/MainResourceLoader.cpp
parent7e7a70bfa49a1122b2597a1e6367d89eb4035eca (diff)
downloadexternal_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.zip
external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.gz
external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.bz2
Merge in WebKit r47029.
Diffstat (limited to 'WebCore/loader/MainResourceLoader.cpp')
-rw-r--r--WebCore/loader/MainResourceLoader.cpp60
1 files changed, 14 insertions, 46 deletions
diff --git a/WebCore/loader/MainResourceLoader.cpp b/WebCore/loader/MainResourceLoader.cpp
index 39e5b90..6c843e9 100644
--- a/WebCore/loader/MainResourceLoader.cpp
+++ b/WebCore/loader/MainResourceLoader.cpp
@@ -30,6 +30,7 @@
#include "config.h"
#include "MainResourceLoader.h"
+#include "ApplicationCacheHost.h"
#include "DocumentLoader.h"
#include "FormState.h"
#include "Frame.h"
@@ -41,12 +42,6 @@
#include "ResourceHandle.h"
#include "Settings.h"
-#if ENABLE(OFFLINE_WEB_APPLICATIONS)
-#include "ApplicationCache.h"
-#include "ApplicationCacheGroup.h"
-#include "ApplicationCacheResource.h"
-#endif
-
// FIXME: More that is in common with SubresourceLoader should move up into ResourceLoader.
namespace WebCore {
@@ -283,15 +278,8 @@ void MainResourceLoader::continueAfterContentPolicy(PolicyAction policy)
void MainResourceLoader::didReceiveResponse(const ResourceResponse& r)
{
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
- if (r.httpStatusCode() / 100 == 4 || r.httpStatusCode() / 100 == 5) {
- ASSERT(!m_applicationCache);
- if (m_frame->settings() && m_frame->settings()->offlineWebApplicationCacheEnabled()) {
- m_applicationCache = ApplicationCacheGroup::fallbackCacheForMainRequest(request(), documentLoader());
-
- if (scheduleLoadFallbackResourceFromApplicationCache(m_applicationCache.get()))
- return;
- }
- }
+ if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForMainResponse(request(), r))
+ return;
#endif
HTTPHeaderMap::const_iterator it = r.httpHeaderFields().find(AtomicString("x-frame-options"));
@@ -353,6 +341,10 @@ void MainResourceLoader::didReceiveData(const char* data, int length, long long
ASSERT(!defersLoading());
#endif
+ #if ENABLE(OFFLINE_WEB_APPLICATIONS)
+ documentLoader()->applicationCacheHost()->mainResourceDataReceived(data, length, lengthReceived, allAtOnce);
+#endif
+
// The additional processing can do anything including possibly removing the last
// reference to this object; one example of this is 3266216.
RefPtr<MainResourceLoader> protect(this);
@@ -380,27 +372,15 @@ void MainResourceLoader::didFinishLoading()
ResourceLoader::didFinishLoading();
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
- ApplicationCacheGroup* group = dl->candidateApplicationCacheGroup();
- if (!group && dl->applicationCache() && !dl->mainResourceApplicationCache())
- group = dl->applicationCache()->group();
-
- if (group)
- group->finishedLoadingMainResource(dl.get());
+ dl->applicationCacheHost()->finishedLoadingMainResource();
#endif
}
void MainResourceLoader::didFail(const ResourceError& error)
{
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
- if (!error.isCancellation()) {
- ASSERT(!m_applicationCache);
- if (m_frame->settings() && m_frame->settings()->offlineWebApplicationCacheEnabled()) {
- m_applicationCache = ApplicationCacheGroup::fallbackCacheForMainRequest(request(), documentLoader());
-
- if (scheduleLoadFallbackResourceFromApplicationCache(m_applicationCache.get()))
- return;
- }
- }
+ if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForMainError(request(), error))
+ return;
#endif
// There is a bug in CFNetwork where callbacks can be dispatched even when loads are deferred.
@@ -495,27 +475,15 @@ bool MainResourceLoader::load(const ResourceRequest& r, const SubstituteData& su
m_substituteData = substituteData;
+ ResourceRequest request(r);
+
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
- // Check if this request should be loaded from the application cache
- if (!m_substituteData.isValid() && frameLoader()->frame()->settings() && frameLoader()->frame()->settings()->offlineWebApplicationCacheEnabled()) {
- ASSERT(!m_applicationCache);
-
- m_applicationCache = ApplicationCacheGroup::cacheForMainRequest(r, m_documentLoader.get());
-
- if (m_applicationCache) {
- // Get the resource from the application cache. By definition, cacheForMainRequest() returns a cache that contains the resource.
- ApplicationCacheResource* resource = m_applicationCache->resourceForRequest(r);
- m_substituteData = SubstituteData(resource->data(),
- resource->response().mimeType(),
- resource->response().textEncodingName(), KURL());
- }
- }
+ documentLoader()->applicationCacheHost()->maybeLoadMainResource(request, m_substituteData);
#endif
- ResourceRequest request(r);
bool defer = defersLoading();
if (defer) {
- bool shouldLoadEmpty = shouldLoadAsEmptyDocument(r.url());
+ bool shouldLoadEmpty = shouldLoadAsEmptyDocument(request.url());
if (shouldLoadEmpty)
defer = false;
}