Unreviewed, rolling out r146301.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Mar 2013 06:37:24 +0000 (06:37 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Mar 2013 06:37:24 +0000 (06:37 +0000)
http://trac.webkit.org/changeset/146301
https://bugs.webkit.org/show_bug.cgi?id=112776

Caused hundreds of tests to hit assertions on Windows debug
bots (Requested by rniwa on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2013-03-19

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.exp.in:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::DocumentLoader):
(WebCore::DocumentLoader::mainResourceLoader):
(WebCore::DocumentLoader::~DocumentLoader):
(WebCore::DocumentLoader::mainResourceData):
(WebCore::DocumentLoader::stopLoading):
(WebCore::DocumentLoader::finishedLoading):
(WebCore::DocumentLoader::handleSubstituteDataLoadNow):
(WebCore::DocumentLoader::continueAfterNavigationPolicy):
(WebCore::DocumentLoader::responseReceived):
(WebCore::DocumentLoader::continueAfterContentPolicy):
(WebCore::DocumentLoader::reportMemoryUsage):
(WebCore::DocumentLoader::receivedData):
(WebCore::DocumentLoader::clearMainResourceLoader):
(WebCore::DocumentLoader::setDefersLoading):
(WebCore::DocumentLoader::setMainResourceDataBufferingPolicy):
(WebCore::DocumentLoader::addSubresourceLoader):
(WebCore::DocumentLoader::isLoadingMainResource):
(WebCore):
(WebCore::DocumentLoader::maybeLoadEmpty):
(WebCore::DocumentLoader::startLoadingMainResource):
* loader/DocumentLoader.h:
(WebCore):
(DocumentLoader):
* loader/MainResourceLoader.cpp: Added.
(WebCore):
(WebCore::MainResourceLoader::MainResourceLoader):
(WebCore::MainResourceLoader::~MainResourceLoader):
(WebCore::MainResourceLoader::create):
(WebCore::MainResourceLoader::clearResource):
(WebCore::MainResourceLoader::frameLoader):
(WebCore::MainResourceLoader::request):
(WebCore::MainResourceLoader::resourceData):
(WebCore::MainResourceLoader::redirectReceived):
(WebCore::MainResourceLoader::responseReceived):
(WebCore::MainResourceLoader::dataReceived):
(WebCore::MainResourceLoader::notifyFinished):
(WebCore::MainResourceLoader::reportMemoryUsage):
(WebCore::MainResourceLoader::load):
(WebCore::MainResourceLoader::setDefersLoading):
(WebCore::MainResourceLoader::defersLoading):
(WebCore::MainResourceLoader::setDataBufferingPolicy):
(WebCore::MainResourceLoader::loader):
(WebCore::MainResourceLoader::identifier):
* loader/MainResourceLoader.h: Added.
(WebCore):
(MainResourceLoader):
(WebCore::MainResourceLoader::cachedMainResource):
(WebCore::MainResourceLoader::documentLoader):
* loader/mac/DocumentLoaderMac.cpp:
(WebCore::DocumentLoader::schedule):
(WebCore::DocumentLoader::unschedule):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@146306 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/loader/DocumentLoader.h
Source/WebCore/loader/MainResourceLoader.cpp [new file with mode: 0644]
Source/WebCore/loader/MainResourceLoader.h [new file with mode: 0644]
Source/WebCore/loader/mac/DocumentLoaderMac.cpp

index 8dee335..0a44f58 100644 (file)
@@ -1686,6 +1686,7 @@ set(WebCore_SOURCES
     loader/ImageLoader.cpp
     loader/LinkLoader.cpp
     loader/LoaderStrategy.cpp
+    loader/MainResourceLoader.cpp
     loader/MixedContentChecker.cpp
     loader/NavigationAction.cpp
     loader/NetscapePlugInStreamLoader.cpp
index 3aa28ba..7f07b07 100644 (file)
@@ -1,3 +1,74 @@
+2013-03-19  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r146301.
+        http://trac.webkit.org/changeset/146301
+        https://bugs.webkit.org/show_bug.cgi?id=112776
+
+        Caused hundreds of tests to hit assertions on Windows debug
+        bots (Requested by rniwa on #webkit).
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.exp.in:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.vcxproj/WebCore.vcxproj.filters:
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::DocumentLoader):
+        (WebCore::DocumentLoader::mainResourceLoader):
+        (WebCore::DocumentLoader::~DocumentLoader):
+        (WebCore::DocumentLoader::mainResourceData):
+        (WebCore::DocumentLoader::stopLoading):
+        (WebCore::DocumentLoader::finishedLoading):
+        (WebCore::DocumentLoader::handleSubstituteDataLoadNow):
+        (WebCore::DocumentLoader::continueAfterNavigationPolicy):
+        (WebCore::DocumentLoader::responseReceived):
+        (WebCore::DocumentLoader::continueAfterContentPolicy):
+        (WebCore::DocumentLoader::reportMemoryUsage):
+        (WebCore::DocumentLoader::receivedData):
+        (WebCore::DocumentLoader::clearMainResourceLoader):
+        (WebCore::DocumentLoader::setDefersLoading):
+        (WebCore::DocumentLoader::setMainResourceDataBufferingPolicy):
+        (WebCore::DocumentLoader::addSubresourceLoader):
+        (WebCore::DocumentLoader::isLoadingMainResource):
+        (WebCore):
+        (WebCore::DocumentLoader::maybeLoadEmpty):
+        (WebCore::DocumentLoader::startLoadingMainResource):
+        * loader/DocumentLoader.h:
+        (WebCore):
+        (DocumentLoader):
+        * loader/MainResourceLoader.cpp: Added.
+        (WebCore):
+        (WebCore::MainResourceLoader::MainResourceLoader):
+        (WebCore::MainResourceLoader::~MainResourceLoader):
+        (WebCore::MainResourceLoader::create):
+        (WebCore::MainResourceLoader::clearResource):
+        (WebCore::MainResourceLoader::frameLoader):
+        (WebCore::MainResourceLoader::request):
+        (WebCore::MainResourceLoader::resourceData):
+        (WebCore::MainResourceLoader::redirectReceived):
+        (WebCore::MainResourceLoader::responseReceived):
+        (WebCore::MainResourceLoader::dataReceived):
+        (WebCore::MainResourceLoader::notifyFinished):
+        (WebCore::MainResourceLoader::reportMemoryUsage):
+        (WebCore::MainResourceLoader::load):
+        (WebCore::MainResourceLoader::setDefersLoading):
+        (WebCore::MainResourceLoader::defersLoading):
+        (WebCore::MainResourceLoader::setDataBufferingPolicy):
+        (WebCore::MainResourceLoader::loader):
+        (WebCore::MainResourceLoader::identifier):
+        * loader/MainResourceLoader.h: Added.
+        (WebCore):
+        (MainResourceLoader):
+        (WebCore::MainResourceLoader::cachedMainResource):
+        (WebCore::MainResourceLoader::documentLoader):
+        * loader/mac/DocumentLoaderMac.cpp:
+        (WebCore::DocumentLoader::schedule):
+        (WebCore::DocumentLoader::unschedule):
+
 2013-03-19  Mike West  <mkwst@chromium.org>
 
         CSP 1.1: Stub out SecurityPolicyViolationEvent interface.
index 5fbcf64..4cd1fc3 100644 (file)
@@ -4078,6 +4078,8 @@ webcore_sources += \
        Source/WebCore/loader/LinkLoaderClient.h \
        Source/WebCore/loader/LoaderStrategy.cpp \
        Source/WebCore/loader/LoaderStrategy.h \
+       Source/WebCore/loader/MainResourceLoader.cpp \
+       Source/WebCore/loader/MainResourceLoader.h \
        Source/WebCore/loader/MixedContentChecker.cpp \
        Source/WebCore/loader/MixedContentChecker.h \
        Source/WebCore/loader/NavigationAction.cpp \
index 72b60ad..96729af 100644 (file)
@@ -884,6 +884,7 @@ SOURCES += \
     loader/ImageLoader.cpp \
     loader/LinkLoader.cpp \
     loader/LoaderStrategy.cpp \
+    loader/MainResourceLoader.cpp \
     loader/MixedContentChecker.cpp \
     loader/NavigationAction.cpp \
     loader/NetscapePlugInStreamLoader.cpp \
@@ -2081,6 +2082,7 @@ HEADERS += \
     loader/LinkLoader.h \
     loader/LinkLoaderClient.h \
     loader/LoaderStrategy.h \
+    loader/MainResourceLoader.h \
     loader/MixedContentChecker.h \
     loader/NavigationAction.h \
     loader/NetscapePlugInStreamLoader.h \
index 6afc971..e09a59f 100644 (file)
@@ -278,12 +278,8 @@ __ZN7WebCore14ClientRectListC1ERKN3WTF6VectorINS_9FloatQuadELm0EEE
 __ZN7WebCore14ClientRectListC1Ev
 __ZN7WebCore14ClientRectListD1Ev
 __ZN7WebCore14DocumentLoader10commitDataEPKcm
-__ZN7WebCore14DocumentLoader12dataReceivedEPNS_14CachedResourceEPKci
 __ZN7WebCore14DocumentLoader13attachToFrameEv
-__ZN7WebCore14DocumentLoader14notifyFinishedEPNS_14CachedResourceE
 __ZN7WebCore14DocumentLoader15detachFromFrameEv
-__ZN7WebCore14DocumentLoader16redirectReceivedEPNS_14CachedResourceERNS_15ResourceRequestERKNS_16ResourceResponseE
-__ZN7WebCore14DocumentLoader16responseReceivedEPNS_14CachedResourceERKNS_16ResourceResponseE
 __ZN7WebCore14DocumentLoader18addArchiveResourceEN3WTF10PassRefPtrINS_15ArchiveResourceEEE
 __ZN7WebCore14ResourceLoader32didCancelAuthenticationChallengeERKNS_23AuthenticationChallengeE
 __ZN7WebCore14cookiesEnabledERKNS_21NetworkStorageSessionERKNS_4KURLES5_
@@ -1296,6 +1292,7 @@ __ZNK7WebCore14DocumentLoader18mainResourceLoaderEv
 __ZNK7WebCore14DocumentLoader19isLoadingInAPISenseEv
 __ZNK7WebCore14DocumentLoader19originalRequestCopyEv
 __ZNK7WebCore14DocumentLoader21archiveResourceForURLERKNS_4KURLE
+__ZNK7WebCore14DocumentLoader21isLoadingMainResourceEv
 __ZNK7WebCore14DocumentLoader28urlForHistoryReflectsFailureEv
 __ZNK7WebCore14DocumentLoader3urlEv
 __ZNK7WebCore14DocumentMarker11descriptionEv
index 108e6d3..4ef5da7 100644 (file)
             'loader/LinkLoaderClient.h',
             'loader/LoaderStrategy.cpp',
             'loader/LoaderStrategy.h',
+            'loader/MainResourceLoader.cpp',
+            'loader/MainResourceLoader.h',
             'loader/MixedContentChecker.cpp',
             'loader/MixedContentChecker.h',
             'loader/NavigationAction.cpp',
index 31398c2..b8265d9 100755 (executable)
                                >
                        </File>
                        <File
+                               RelativePath="..\loader\MainResourceLoader.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\loader\MainResourceLoader.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\loader\MixedContentChecker.cpp"
                                >
                        </File>
index 44a9961..be6de25 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup Label="ProjectConfigurations">
     <ProjectConfiguration Include="DebugSuffix|Win32">
     <ClCompile Include="..\loader\ImageLoader.cpp" />
     <ClCompile Include="..\loader\LinkLoader.cpp" />
     <ClCompile Include="..\loader\LoaderStrategy.cpp" />
+    <ClCompile Include="..\loader\MainResourceLoader.cpp" />
     <ClCompile Include="..\loader\MixedContentChecker.cpp" />
     <ClCompile Include="..\loader\NavigationAction.cpp" />
     <ClCompile Include="..\loader\NavigationScheduler.cpp" />
     <ClInclude Include="..\loader\LinkLoader.h" />
     <ClInclude Include="..\loader\LinkLoaderClient.h" />
     <ClInclude Include="..\loader\LoaderStrategy.h" />
+    <ClInclude Include="..\loader\MainResourceLoader.h" />
     <ClInclude Include="..\loader\MixedContentChecker.h" />
     <ClInclude Include="..\loader\NavigationAction.h" />
     <ClInclude Include="..\loader\NavigationScheduler.h" />
index 3d4dd79..784c6e5 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup>
     <Filter Include="DerivedSources">
     <ClCompile Include="..\loader\LoaderStrategy.cpp">
       <Filter>loader</Filter>
     </ClCompile>
+    <ClCompile Include="..\loader\MainResourceLoader.cpp">
+      <Filter>loader</Filter>
+    </ClCompile>
     <ClCompile Include="..\loader\MixedContentChecker.cpp">
       <Filter>loader</Filter>
     </ClCompile>
     <ClInclude Include="..\loader\LoaderStrategy.h">
       <Filter>loader</Filter>
     </ClInclude>
+    <ClInclude Include="..\loader\MainResourceLoader.h">
+      <Filter>loader</Filter>
+    </ClInclude>
     <ClInclude Include="..\loader\MixedContentChecker.h">
       <Filter>loader</Filter>
     </ClInclude>
index e3b7390..d05dc55 100644 (file)
                656D373C0ADBA5DE00A4554D /* FrameLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 656D37240ADBA5DE00A4554D /* FrameLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
                656D373E0ADBA5DE00A4554D /* FrameLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 656D37260ADBA5DE00A4554D /* FrameLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
                656D373F0ADBA5DE00A4554D /* ResourceLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 656D37270ADBA5DE00A4554D /* ResourceLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               656D37410ADBA5DE00A4554D /* MainResourceLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 656D37290ADBA5DE00A4554D /* MainResourceLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
                656D37430ADBA5DE00A4554D /* NetscapePlugInStreamLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 656D372B0ADBA5DE00A4554D /* NetscapePlugInStreamLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
                656D37480ADBA5DE00A4554D /* SubresourceLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 656D37300ADBA5DE00A4554D /* SubresourceLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
                6571DCC81385E6A400702DD0 /* MemoryPressureHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 657EDA071385CB97004E0645 /* MemoryPressureHandler.h */; settings = {ATTRIBUTES = (Private, ); }; };
                93D3C17D0F97AA760053C013 /* DOMHTMLCanvasElement.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 93D3C1580F97A9D70053C013 /* DOMHTMLCanvasElement.h */; };
                93D9D53C0DA27E180077216C /* RangeBoundaryPoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 93D9D53B0DA27E180077216C /* RangeBoundaryPoint.h */; settings = {ATTRIBUTES = (Private, ); }; };
                93E227E00AF589AD00D48324 /* DocumentLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93E227DB0AF589AD00D48324 /* DocumentLoader.cpp */; };
+               93E227E10AF589AD00D48324 /* MainResourceLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93E227DC0AF589AD00D48324 /* MainResourceLoader.cpp */; };
                93E227E30AF589AD00D48324 /* ResourceLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93E227DE0AF589AD00D48324 /* ResourceLoader.cpp */; };
                93E227E40AF589AD00D48324 /* SubresourceLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93E227DF0AF589AD00D48324 /* SubresourceLoader.cpp */; };
                93E241FF0B2B4E4000C732A1 /* HTMLFrameOwnerElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E241FE0B2B4E4000C732A1 /* HTMLFrameOwnerElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
                656D37240ADBA5DE00A4554D /* FrameLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FrameLoader.h; sourceTree = "<group>"; };
                656D37260ADBA5DE00A4554D /* FrameLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FrameLoaderClient.h; sourceTree = "<group>"; };
                656D37270ADBA5DE00A4554D /* ResourceLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ResourceLoader.h; sourceTree = "<group>"; };
+               656D37290ADBA5DE00A4554D /* MainResourceLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MainResourceLoader.h; sourceTree = "<group>"; };
                656D372B0ADBA5DE00A4554D /* NetscapePlugInStreamLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NetscapePlugInStreamLoader.h; sourceTree = "<group>"; };
                656D37300ADBA5DE00A4554D /* SubresourceLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SubresourceLoader.h; sourceTree = "<group>"; };
                657EDA061385CB97004E0645 /* MemoryPressureHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryPressureHandler.cpp; sourceTree = "<group>"; };
                93D3C1580F97A9D70053C013 /* DOMHTMLCanvasElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMHTMLCanvasElement.h; sourceTree = "<group>"; };
                93D9D53B0DA27E180077216C /* RangeBoundaryPoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RangeBoundaryPoint.h; sourceTree = "<group>"; };
                93E227DB0AF589AD00D48324 /* DocumentLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentLoader.cpp; sourceTree = "<group>"; };
+               93E227DC0AF589AD00D48324 /* MainResourceLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MainResourceLoader.cpp; sourceTree = "<group>"; };
                93E227DD0AF589AD00D48324 /* NetscapePlugInStreamLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetscapePlugInStreamLoader.cpp; sourceTree = "<group>"; };
                93E227DE0AF589AD00D48324 /* ResourceLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoader.cpp; sourceTree = "<group>"; };
                93E227DF0AF589AD00D48324 /* SubresourceLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SubresourceLoader.cpp; sourceTree = "<group>"; };
                                984264EF12D5280A000D88A4 /* LinkLoaderClient.h */,
                                51ABF64C16392E2800132A7A /* LoaderStrategy.cpp */,
                                51E6820F16387302003BBF3C /* LoaderStrategy.h */,
+                               93E227DC0AF589AD00D48324 /* MainResourceLoader.cpp */,
+                               656D37290ADBA5DE00A4554D /* MainResourceLoader.h */,
                                52F10862162B6D82009AC81E /* MixedContentChecker.cpp */,
                                52F10863162B6D82009AC81E /* MixedContentChecker.h */,
                                93CCF05F0AF6CA7600018E89 /* NavigationAction.cpp */,
                                935207BE09BD410A00F2038D /* LocalizedStrings.h in Headers */,
                                BCE1C41B0D982980003B02F2 /* Location.h in Headers */,
                                A8239E0109B3CF8A00B60641 /* Logging.h in Headers */,
+                               656D37410ADBA5DE00A4554D /* MainResourceLoader.h in Headers */,
                                E187056316E54A0D00585E97 /* MainThreadTask.h in Headers */,
                                1A8F6BC60DB55CDC001DB794 /* ManifestParser.h in Headers */,
                                93309DF8099E64920056E581 /* markup.h in Headers */,
                                BCE1C41C0D982981003B02F2 /* Location.cpp in Sources */,
                                A8239E0009B3CF8A00B60641 /* Logging.cpp in Sources */,
                                1402645E0AFDC19B005919E2 /* LoggingMac.mm in Sources */,
+                               93E227E10AF589AD00D48324 /* MainResourceLoader.cpp in Sources */,
                                1A8F6BC50DB55CDC001DB794 /* ManifestParser.cpp in Sources */,
                                93309DF7099E64920056E581 /* markup.cpp in Sources */,
                                9728C3131268E4390041E89B /* MarkupAccumulator.cpp in Sources */,
index a1e595f..9dbb4fd 100644 (file)
 #include "HistoryItem.h"
 #include "InspectorInstrumentation.h"
 #include "Logging.h"
+#include "MainResourceLoader.h"
 #include "MemoryCache.h"
 #include "Page.h"
 #include "ProgressTracker.h"
 #include "ResourceBuffer.h"
 #include "SchemeRegistry.h"
 #include "Settings.h"
-#include "SubresourceLoader.h"
 #include "TextResourceDecoder.h"
 #include "WebCoreMemoryInstrumentation.h"
 #include <wtf/Assertions.h>
@@ -107,11 +107,11 @@ DocumentLoader::DocumentLoader(const ResourceRequest& req, const SubstituteData&
     , m_gotFirstByte(false)
     , m_isClientRedirect(false)
     , m_isLoadingMultipartContent(false)
+    , m_loadingEmptyDocument(false)
     , m_wasOnloadHandled(false)
     , m_stopRecordingResponses(false)
     , m_substituteResourceDeliveryTimer(this, &DocumentLoader::substituteResourceDeliveryTimerFired)
     , m_didCreateGlobalHistoryEntry(false)
-    , m_loadingMainResource(false)
     , m_timeOfLastDataReceived(0.0)
     , m_identifierForLoadWithoutResourceLoader(0)
     , m_dataLoadTimer(this, &DocumentLoader::handleSubstituteDataLoadNow)
@@ -129,7 +129,7 @@ FrameLoader* DocumentLoader::frameLoader() const
 
 ResourceLoader* DocumentLoader::mainResourceLoader() const
 {
-    return m_mainResource ? m_mainResource->loader() : 0;
+    return m_mainResourceLoader ? m_mainResourceLoader->loader() : 0;
 }
 
 DocumentLoader::~DocumentLoader()
@@ -140,19 +140,16 @@ DocumentLoader::~DocumentLoader()
     if (m_iconDataCallback)
         m_iconDataCallback->invalidate();
     m_cachedResourceLoader->clearDocumentLoader();
-    
-    if (m_mainResource) {
-        m_mainResource->removeClient(this);
-        m_mainResource = 0;
-    }
 }
 
 PassRefPtr<ResourceBuffer> DocumentLoader::mainResourceData() const
 {
+    if (m_mainResourceData)
+        return m_mainResourceData;
     if (m_substituteData.isValid())
         return ResourceBuffer::create(m_substituteData.content()->data(), m_substituteData.content()->size());
-    if (m_mainResource)
-        return m_mainResource->resourceBuffer();
+    if (m_mainResourceLoader)
+        return m_mainResourceLoader->resourceData();
     return 0;
 }
 
@@ -295,7 +292,7 @@ void DocumentLoader::stopLoading()
 
     FrameLoader* frameLoader = DocumentLoader::frameLoader();
     
-    if (isLoadingMainResource())
+    if (m_mainResourceLoader)
         // Stop the main resource loader and let it send the cancelled message.
         cancelMainResourceLoad(frameLoader->cancelledError(m_request));
     else if (!m_subresourceLoaders.isEmpty())
@@ -333,26 +330,6 @@ bool DocumentLoader::isLoading() const
     return isLoadingMainResource() || !m_subresourceLoaders.isEmpty() || !m_plugInStreamLoaders.isEmpty();
 }
 
-void DocumentLoader::notifyFinished(CachedResource* resource)
-{
-    ASSERT_UNUSED(resource, m_mainResource == resource);
-    ASSERT(m_mainResource);
-    if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) {
-        finishedLoading(m_mainResource->loadFinishTime());
-        return;
-    }
-
-    // FIXME: we should fix the design to eliminate the need for a platform ifdef here
-#if !PLATFORM(CHROMIUM)
-    if (m_request.cachePolicy() == ReturnCacheDataDontLoad && !m_mainResource->wasCanceled()) {
-        frameLoader()->retryAfterFailedCacheOnlyMainResourceLoad();
-        return;
-    }
-#endif
-
-    mainReceivedError(m_mainResource->resourceError());
-}
-
 void DocumentLoader::finishedLoading(double finishTime)
 {
     // There is a bug in CFNetwork where callbacks can be dispatched even when loads are deferred.
@@ -374,7 +351,7 @@ void DocumentLoader::finishedLoading(double finishTime)
         int length;
         const char* data = m_contentFilter->getReplacementData(length);
         if (data)
-            dataReceived(m_mainResource.get(), data, length);
+            receivedData(data, length);
     }
 #endif
 
@@ -408,9 +385,9 @@ void DocumentLoader::finishedLoading(double finishTime)
 
     // If the document specified an application cache manifest, it violates the author's intent if we store it in the memory cache
     // and deny the appcache the chance to intercept it in the future, so remove from the memory cache.
-    if (m_frame) {
-        if (m_mainResource && m_frame->document()->hasManifest())
-            memoryCache()->remove(m_mainResource.get());
+    if (frame() && m_mainResourceLoader) {
+        if (m_mainResourceLoader->cachedMainResource() && frame()->document()->hasManifest())
+            memoryCache()->remove(m_mainResourceLoader->cachedMainResource());
     }
     m_applicationCacheHost->finishedLoadingMainResource();
 }
@@ -434,7 +411,7 @@ void DocumentLoader::handleSubstituteDataLoadNow(DocumentLoaderTimer*)
     if (url.isEmpty())
         url = m_request.url();
     ResourceResponse response(url, m_substituteData.mimeType(), m_substituteData.content()->size(), m_substituteData.textEncoding(), "");
-    responseReceived(0, response);
+    responseReceived(response);
 }
 
 void DocumentLoader::startDataLoadTimer()
@@ -455,12 +432,6 @@ void DocumentLoader::handleSubstituteDataLoadSoon()
         handleSubstituteDataLoadNow(0);
 }
 
-void DocumentLoader::redirectReceived(CachedResource* resource, ResourceRequest& request, const ResourceResponse& redirectResponse)
-{
-    ASSERT_UNUSED(resource, resource == m_mainResource);
-    willSendRequest(request, redirectResponse);
-}
-
 void DocumentLoader::willSendRequest(ResourceRequest& newRequest, const ResourceResponse& redirectResponse)
 {
     // Note that there are no asserts here as there are for the other callbacks. This is due to the
@@ -544,21 +515,17 @@ void DocumentLoader::continueAfterNavigationPolicy(const ResourceRequest&, bool
         // If the ResourceLoader is indeed cancelled, it would normally send resource load callbacks.
         // However, from an API perspective, this isn't a cancellation. Therefore, sever our relationship with the network load,
         // but prevent the ResourceLoader from sending ResourceLoadNotifier callbacks.
-        RefPtr<ResourceLoader> resourceLoader = mainResourceLoader();
+        RefPtr<ResourceLoader> resourceLoader = m_mainResourceLoader->loader();
         ASSERT(resourceLoader->shouldSendResourceLoadCallbacks());
         resourceLoader->setSendCallbackPolicy(DoNotSendCallbacks);
-        if (m_mainResource) {
-            m_mainResource->removeClient(this);
-            m_mainResource = 0;
-        }
+        m_mainResourceLoader->clearResource();
         resourceLoader->setSendCallbackPolicy(SendCallbacks);
         handleSubstituteDataLoadSoon();
     }
 }
 
-void DocumentLoader::responseReceived(CachedResource* resource, const ResourceResponse& response)
+void DocumentLoader::responseReceived(const ResourceResponse& response)
 {
-    ASSERT_UNUSED(resource, m_mainResource == resource);
     RefPtr<DocumentLoader> protect(this);
     bool willLoadFallback = m_applicationCacheHost->maybeLoadFallbackForMainResponse(request(), response);
 
@@ -572,7 +539,7 @@ void DocumentLoader::responseReceived(CachedResource* resource, const ResourceRe
         shouldRemoveResourceFromCache = true;
 #endif
     if (shouldRemoveResourceFromCache)
-        memoryCache()->remove(m_mainResource.get());
+        memoryCache()->remove(m_mainResourceLoader->cachedMainResource());
 
     if (willLoadFallback)
         return;
@@ -599,7 +566,7 @@ void DocumentLoader::responseReceived(CachedResource* resource, const ResourceRe
 
     if (m_isLoadingMultipartContent) {
         setupForReplace();
-        m_mainResource->clear();
+        m_mainResourceLoader->cachedMainResource()->clear();
     } else if (response.isMultipart()) {
         FeatureObserver::observe(m_frame->document(), FeatureObserver::MultipartMainResource);
         m_isLoadingMultipartContent = true;
@@ -670,8 +637,8 @@ void DocumentLoader::continueAfterContentPolicy(PolicyAction policy)
     }
 
     case PolicyDownload: {
-        // m_mainResource can be null, e.g. when loading a substitute resource from application cache.
-        if (!m_mainResource) {
+        // The main CachedResource can be null, e.g. when loading a substitute resource from application cache.
+        if (!m_mainResourceLoader->cachedMainResource()) {
             mainReceivedError(frameLoader()->client()->cannotShowURLError(m_request));
             return;
         }
@@ -712,7 +679,7 @@ void DocumentLoader::continueAfterContentPolicy(PolicyAction policy)
 
     if (!isStopping() && m_substituteData.isValid()) {
         if (m_substituteData.content()->size())
-            dataReceived(0, m_substituteData.content()->data(), m_substituteData.content()->size());
+            receivedData(m_substituteData.content()->data(), m_substituteData.content()->size());
         if (isLoadingMainResource())
             finishedLoading(0);
     }
@@ -791,7 +758,8 @@ void DocumentLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Loader);
     info.addMember(m_frame, "frame");
     info.addMember(m_cachedResourceLoader, "cachedResourceLoader");
-    info.addMember(m_mainResource, "mainResource");
+    info.addMember(m_mainResourceLoader, "mainResourceLoader");
+    info.addMember(m_mainResourceData, "mainResourceData");
     info.addMember(m_subresourceLoaders, "subresourceLoaders");
     info.addMember(m_multipartSubresourceLoaders, "multipartSubresourceLoaders");
     info.addMember(m_plugInStreamLoaders, "plugInStreamLoaders");
@@ -820,11 +788,10 @@ void DocumentLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     info.addMember(m_applicationCacheHost, "applicationCacheHost");
 }
 
-void DocumentLoader::dataReceived(CachedResource* resource, const char* data, int length)
+void DocumentLoader::receivedData(const char* data, int length)
 {
     ASSERT(data);
     ASSERT(length);
-    ASSERT_UNUSED(resource, resource == m_mainResource);
     ASSERT(!m_response.isNull());
 
 #if USE(CFNETWORK) || PLATFORM(MAC)
@@ -934,7 +901,12 @@ void DocumentLoader::detachFromFrame()
 
 void DocumentLoader::clearMainResourceLoader()
 {
-    m_loadingMainResource = false;
+    if (m_mainResourceLoader) {
+        m_mainResourceData = m_mainResourceLoader->resourceData();
+        m_mainResourceLoader = 0;
+    }
+    m_loadingEmptyDocument = false;
+
     if (this == frameLoader()->activeDocumentLoader())
         checkLoadComplete();
 }
@@ -1271,8 +1243,8 @@ const KURL& DocumentLoader::unreachableURL() const
 
 void DocumentLoader::setDefersLoading(bool defers)
 {
-    if (mainResourceLoader())
-        mainResourceLoader()->setDefersLoading(defers);
+    if (m_mainResourceLoader)
+        m_mainResourceLoader->setDefersLoading(defers);
     setAllDefersLoading(m_subresourceLoaders, defers);
     setAllDefersLoading(m_plugInStreamLoaders, defers);
     if (!defers)
@@ -1281,8 +1253,8 @@ void DocumentLoader::setDefersLoading(bool defers)
 
 void DocumentLoader::setMainResourceDataBufferingPolicy(DataBufferingPolicy dataBufferingPolicy)
 {
-    if (m_mainResource)
-        m_mainResource->setDataBufferingPolicy(dataBufferingPolicy);
+    if (m_mainResourceLoader)
+        m_mainResourceLoader->setDataBufferingPolicy(dataBufferingPolicy);
 }
 
 void DocumentLoader::stopLoadingPlugIns()
@@ -1299,13 +1271,13 @@ void DocumentLoader::addSubresourceLoader(ResourceLoader* loader)
 {
     // The main resource's underlying ResourceLoader will ask to be added here.
     // It is much simpler to handle special casing of main resource loads if we don't
-    // let it be added. In the main resource load case, mainResourceLoader()
+    // let it be added. In the main resource load case, m_mainResourceLoader->loader()
     // will still be null at this point, but m_gotFirstByte should be false here if and only
     // if we are just starting the main resource load.
     if (!m_gotFirstByte)
         return;
     ASSERT(!m_subresourceLoaders.contains(loader));
-    ASSERT(!mainResourceLoader() || mainResourceLoader() != loader);
+    ASSERT(!m_mainResourceLoader || m_mainResourceLoader->loader() != loader);
     m_subresourceLoaders.add(loader);
 }
 
@@ -1330,6 +1302,11 @@ void DocumentLoader::removePlugInStreamLoader(ResourceLoader* loader)
     checkLoadComplete();
 }
 
+bool DocumentLoader::isLoadingMainResource() const
+{
+    return !!m_mainResourceLoader || m_loadingEmptyDocument;
+}
+
 bool DocumentLoader::isMultipartReplacingLoad() const
 {
     return isLoadingMultipartContent() && frameLoader()->isReplacing();
@@ -1341,6 +1318,7 @@ bool DocumentLoader::maybeLoadEmpty()
     if (!shouldLoadEmpty && !frameLoader()->client()->representationExistsForURLScheme(m_request.url().protocol()))
         return false;
 
+    m_loadingEmptyDocument = true;
     if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingInitialEmptyDocument())
         m_request.setURL(blankURL());
     String mimeType = shouldLoadEmpty ? "text/html" : frameLoader()->client()->generatedMIMETypeForURLScheme(m_request.url().protocol());
@@ -1353,13 +1331,13 @@ void DocumentLoader::startLoadingMainResource()
 {
     m_mainDocumentError = ResourceError();
     timing()->markNavigationStart();
-    ASSERT(!m_mainResource);
-    ASSERT(!m_loadingMainResource);
-    m_loadingMainResource = true;
+    ASSERT(!m_mainResourceLoader);
 
     if (maybeLoadEmpty())
         return;
 
+    m_mainResourceLoader = MainResourceLoader::create(this);
+
     // FIXME: Is there any way the extra fields could have not been added by now?
     // If not, it would be great to remove this line of code.
     // Note that currently, some requests may have incorrect extra fields even if this function has been called,
@@ -1386,12 +1364,10 @@ void DocumentLoader::startLoadingMainResource()
     }
 
     ResourceRequest request(m_request);
-    DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions,
-        (SendCallbacks, SniffContent, BufferData, AllowStoredCredentials, AskClientForCrossOriginCredentials, SkipSecurityCheck));
-    CachedResourceRequest cachedResourceRequest(request, mainResourceLoadOptions);
-    m_mainResource = m_cachedResourceLoader->requestMainResource(cachedResourceRequest);
-    if (!m_mainResource) {
-        setRequest(ResourceRequest());
+    m_mainResourceLoader->load(m_request);
+
+    if (m_request.isNull()) {
+        m_mainResourceLoader = 0;
         // If the load was aborted by clearing m_request, it's possible the ApplicationCacheHost
         // is now in a state where starting an empty load will be inconsistent. Replace it with
         // a new ApplicationCacheHost.
@@ -1405,7 +1381,6 @@ void DocumentLoader::startLoadingMainResource()
         frameLoader()->notifier()->assignIdentifierToInitialRequest(m_identifierForLoadWithoutResourceLoader, this, request);
         frameLoader()->notifier()->dispatchWillSendRequest(this, m_identifierForLoadWithoutResourceLoader, request, ResourceResponse());
     }
-    m_mainResource->addClient(this);
 
     // A bunch of headers are set when the underlying ResourceLoader is created, and m_request needs to include those.
     if (mainResourceLoader())
index e8a9924..c80930d 100644 (file)
@@ -30,8 +30,6 @@
 #ifndef DocumentLoader_h
 #define DocumentLoader_h
 
-#include "CachedRawResource.h"
-#include "CachedResourceHandle.h"
 #include "DocumentLoadTiming.h"
 #include "DocumentWriter.h"
 #include "IconDatabaseBase.h"
@@ -67,6 +65,7 @@ namespace WebCore {
     class FormState;
     class Frame;
     class FrameLoader;
+    class MainResourceLoader;
     class Page;
     class ResourceBuffer;
     class ResourceLoader;
@@ -76,8 +75,7 @@ namespace WebCore {
     typedef HashSet<RefPtr<ResourceLoader> > ResourceLoaderSet;
     typedef Vector<ResourceResponse> ResponseVector;
 
-    class DocumentLoader : public RefCounted<DocumentLoader>, private CachedRawResourceClient {
-        WTF_MAKE_FAST_ALLOCATED;
+    class DocumentLoader : public RefCounted<DocumentLoader> {
     public:
         static PassRefPtr<DocumentLoader> create(const ResourceRequest& request, const SubstituteData& data)
         {
@@ -216,8 +214,8 @@ namespace WebCore {
         void continueIconLoadWithDecision(IconLoadDecision);
         void getIconLoadDecisionForIconURL(const String&);
         void getIconDataForIconURL(const String&);
-
-        bool isLoadingMainResource() const { return m_loadingMainResource; }
+        
+        bool isLoadingMainResource() const;
         bool isLoadingMultipartContent() const { return m_isLoadingMultipartContent; }
 
         void stopLoadingPlugIns();
@@ -264,6 +262,9 @@ namespace WebCore {
         virtual void reportMemoryUsage(MemoryObjectInfo*) const;
         void checkLoadComplete();
 
+        // FIXME: This should be private once DocumentLoader and MainResourceLoader are merged.
+        void willSendRequest(ResourceRequest&, const ResourceResponse&);
+
     protected:
         DocumentLoader(const ResourceRequest&, const SubstituteData&);
 
@@ -280,12 +281,6 @@ namespace WebCore {
         void clearArchiveResources();
 #endif
 
-        void willSendRequest(ResourceRequest&, const ResourceResponse&);
-        virtual void redirectReceived(CachedResource*, ResourceRequest&, const ResourceResponse&) OVERRIDE;
-        virtual void responseReceived(CachedResource*, const ResourceResponse&) OVERRIDE;
-        virtual void dataReceived(CachedResource*, const char* data, int length) OVERRIDE;
-        virtual void notifyFinished(CachedResource*) OVERRIDE;
-
         bool maybeLoadEmpty();
 
         bool isMultipartReplacingLoad() const;
@@ -315,10 +310,12 @@ namespace WebCore {
         Frame* m_frame;
         RefPtr<CachedResourceLoader> m_cachedResourceLoader;
 
-        CachedResourceHandle<CachedRawResource> m_mainResource;
+        RefPtr<MainResourceLoader> m_mainResourceLoader;
         ResourceLoaderSet m_subresourceLoaders;
         ResourceLoaderSet m_multipartSubresourceLoaders;
         ResourceLoaderSet m_plugInStreamLoaders;
+
+        RefPtr<ResourceBuffer> m_mainResourceData;
         
         mutable DocumentWriter m_writer;
 
@@ -348,6 +345,7 @@ namespace WebCore {
         bool m_gotFirstByte;
         bool m_isClientRedirect;
         bool m_isLoadingMultipartContent;
+        bool m_loadingEmptyDocument;
 
         // FIXME: Document::m_processingLoadEvent and DocumentLoader::m_wasOnloadHandled are roughly the same
         // and should be merged.
@@ -387,7 +385,6 @@ namespace WebCore {
         String m_clientRedirectSourceForHistory;
         bool m_didCreateGlobalHistoryEntry;
 
-        bool m_loadingMainResource;
         DocumentLoadTiming m_documentLoadTiming;
 
         double m_timeOfLastDataReceived;
diff --git a/Source/WebCore/loader/MainResourceLoader.cpp b/Source/WebCore/loader/MainResourceLoader.cpp
new file mode 100644 (file)
index 0000000..0158e42
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "MainResourceLoader.h"
+
+#include "ApplicationCacheHost.h"
+#include "BackForwardController.h"
+#include "CachedRawResource.h"
+#include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
+#include "Console.h"
+#include "DOMWindow.h"
+#include "Document.h"
+#include "DocumentLoadTiming.h"
+#include "DocumentLoader.h"
+#include "FeatureObserver.h"
+#include "Frame.h"
+#include "FrameLoader.h"
+#include "FrameLoaderClient.h"
+#include "HTMLFormElement.h"
+#include "HistoryItem.h"
+#include "InspectorInstrumentation.h"
+#include "MemoryCache.h"
+#include "Page.h"
+#include "ProgressTracker.h"
+#include "ResourceBuffer.h"
+#include "ResourceError.h"
+#include "ResourceHandle.h"
+#include "SchemeRegistry.h"
+#include "SecurityOrigin.h"
+#include "Settings.h"
+#include "SubresourceLoader.h"
+#include <wtf/CurrentTime.h>
+
+#if PLATFORM(QT)
+#include "PluginDatabase.h"
+#endif
+
+namespace WebCore {
+
+MainResourceLoader::MainResourceLoader(DocumentLoader* documentLoader)
+    : m_documentLoader(documentLoader)
+{
+}
+
+MainResourceLoader::~MainResourceLoader()
+{
+    clearResource();
+}
+
+PassRefPtr<MainResourceLoader> MainResourceLoader::create(DocumentLoader* documentLoader)
+{
+    return adoptRef(new MainResourceLoader(documentLoader));
+}
+
+void MainResourceLoader::clearResource()
+{
+    if (m_resource) {
+        m_resource->removeClient(this);
+        m_resource = 0;
+    }
+}
+
+FrameLoader* MainResourceLoader::frameLoader() const
+{
+    return m_documentLoader->frameLoader();
+}
+
+const ResourceRequest& MainResourceLoader::request() const
+{
+    return m_resource ? m_resource->resourceRequest() : m_initialRequest;
+}
+
+PassRefPtr<ResourceBuffer> MainResourceLoader::resourceData()
+{
+    if (m_resource)
+        return m_resource->resourceBuffer();
+    return 0;
+}
+
+void MainResourceLoader::redirectReceived(CachedResource* resource, ResourceRequest& request, const ResourceResponse& redirectResponse)
+{
+    ASSERT_UNUSED(resource, resource == m_resource);
+    m_documentLoader->willSendRequest(request, redirectResponse);
+}
+
+void MainResourceLoader::responseReceived(CachedResource* resource, const ResourceResponse& r)
+{
+    ASSERT_UNUSED(resource, m_resource == resource);
+    m_documentLoader->responseReceived(r);
+}
+
+void MainResourceLoader::dataReceived(CachedResource* resource, const char* data, int length)
+{
+    ASSERT_UNUSED(resource, resource == m_resource);
+    documentLoader()->receivedData(data, length);
+}
+
+void MainResourceLoader::notifyFinished(CachedResource* resource)
+{
+    ASSERT_UNUSED(resource, m_resource == resource);
+    ASSERT(m_resource);
+    if (!m_resource->errorOccurred() && !m_resource->wasCanceled()) {
+        documentLoader()->finishedLoading(m_resource->loadFinishTime());
+        return;
+    }
+
+    // FIXME: we should fix the design to eliminate the need for a platform ifdef here
+#if !PLATFORM(CHROMIUM)
+    if (m_documentLoader->request().cachePolicy() == ReturnCacheDataDontLoad && !m_resource->wasCanceled()) {
+        frameLoader()->retryAfterFailedCacheOnlyMainResourceLoad();
+        return;
+    }
+#endif
+    m_documentLoader->mainReceivedError(m_resource->resourceError());
+}
+
+void MainResourceLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Loader);
+    info.addMember(m_resource, "resource");
+    info.addMember(m_initialRequest, "initialRequest");
+    info.addMember(m_documentLoader, "documentLoader");
+}
+
+void MainResourceLoader::load(const ResourceRequest& initialRequest)
+{
+    ResourceRequest request(initialRequest);
+
+    DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions,
+        (SendCallbacks, SniffContent, BufferData, AllowStoredCredentials, AskClientForCrossOriginCredentials, SkipSecurityCheck));
+    CachedResourceRequest cachedResourceRequest(request, mainResourceLoadOptions);
+    m_resource = documentLoader()->cachedResourceLoader()->requestMainResource(cachedResourceRequest);
+    if (!m_resource) {
+        documentLoader()->setRequest(ResourceRequest());
+        return;
+    }
+    m_resource->addClient(this);
+}
+
+void MainResourceLoader::setDefersLoading(bool defers)
+{
+    if (loader())
+        loader()->setDefersLoading(defers);
+}
+
+bool MainResourceLoader::defersLoading() const
+{
+    return loader() ? loader()->defersLoading() : false;
+}
+
+void MainResourceLoader::setDataBufferingPolicy(DataBufferingPolicy dataBufferingPolicy)
+{
+    if (m_resource)
+        m_resource->setDataBufferingPolicy(dataBufferingPolicy);
+}
+
+ResourceLoader* MainResourceLoader::loader() const
+{ 
+    return m_resource ? m_resource->loader() : 0;
+}
+
+unsigned long MainResourceLoader::identifier() const
+{
+    if (ResourceLoader* resourceLoader = loader())
+        return resourceLoader->identifier();
+    return 0;
+}
+
+}
diff --git a/Source/WebCore/loader/MainResourceLoader.h b/Source/WebCore/loader/MainResourceLoader.h
new file mode 100644 (file)
index 0000000..c014047
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MainResourceLoader_h
+#define MainResourceLoader_h
+
+#include "CachedRawResource.h"
+#include "CachedResourceHandle.h"
+#include "FrameLoaderTypes.h"
+#include "ResourceLoader.h"
+#include "SubstituteData.h"
+#include <wtf/Forward.h>
+
+namespace WebCore {
+
+class ResourceRequest;
+
+class MainResourceLoader : public RefCounted<MainResourceLoader>, public CachedRawResourceClient {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    static PassRefPtr<MainResourceLoader> create(DocumentLoader*);
+    virtual ~MainResourceLoader();
+
+    void load(const ResourceRequest&);
+    ResourceLoader* loader() const;
+    PassRefPtr<ResourceBuffer> resourceData();
+
+    void setDefersLoading(bool);
+    void setDataBufferingPolicy(DataBufferingPolicy);
+
+    CachedRawResource* cachedMainResource() { return m_resource.get(); }
+
+    unsigned long identifier() const;
+
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
+    void clearResource();
+
+private:
+    explicit MainResourceLoader(DocumentLoader*);
+
+    virtual void redirectReceived(CachedResource*, ResourceRequest&, const ResourceResponse&) OVERRIDE;
+    virtual void responseReceived(CachedResource*, const ResourceResponse&) OVERRIDE;
+    virtual void dataReceived(CachedResource*, const char* data, int dataLength) OVERRIDE;
+    virtual void notifyFinished(CachedResource*) OVERRIDE;
+
+    FrameLoader* frameLoader() const;
+    DocumentLoader* documentLoader() const { return m_documentLoader.get(); }
+
+    const ResourceRequest& request() const;
+
+    bool defersLoading() const;
+
+    CachedResourceHandle<CachedRawResource> m_resource;
+
+    ResourceRequest m_initialRequest;
+
+    RefPtr<DocumentLoader> m_documentLoader;
+};
+
+}
+
+#endif
index 8850f1e..0b53b36 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "config.h"
 #include "DocumentLoader.h"
+#include "MainResourceLoader.h"
 #include "ResourceHandle.h"
 #include "ResourceLoader.h"
 #include <wtf/UnusedParam.h>
@@ -54,8 +55,8 @@ static void unscheduleAll(const ResourceLoaderSet& loaders, SchedulePair* pair)
 
 void DocumentLoader::schedule(SchedulePair* pair)
 {
-    if (mainResourceLoader() && mainResourceLoader()->handle())
-        mainResourceLoader()->handle()->schedule(pair);
+    if (m_mainResourceLoader && m_mainResourceLoader->loader() && m_mainResourceLoader->loader()->handle())
+        m_mainResourceLoader->loader()->handle()->schedule(pair);
     scheduleAll(m_subresourceLoaders, pair);
     scheduleAll(m_plugInStreamLoaders, pair);
     scheduleAll(m_multipartSubresourceLoaders, pair);
@@ -63,8 +64,8 @@ void DocumentLoader::schedule(SchedulePair* pair)
 
 void DocumentLoader::unschedule(SchedulePair* pair)
 {
-    if (mainResourceLoader() && mainResourceLoader()->handle())
-        mainResourceLoader()->handle()->unschedule(pair);
+    if (m_mainResourceLoader && m_mainResourceLoader->loader() && m_mainResourceLoader->loader()->handle())
+        m_mainResourceLoader->loader()->handle()->unschedule(pair);
     unscheduleAll(m_subresourceLoaders, pair);
     unscheduleAll(m_plugInStreamLoaders, pair);
     unscheduleAll(m_multipartSubresourceLoaders, pair);