Merge MainResourceLoader into DocumentLoader
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2013 09:05:45 +0000 (09:05 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2013 09:05:45 +0000 (09:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=104969

Patch by Nate Chapin <japhet@chromium.org> on 2013-03-21
Reviewed by Adam Barth.

No new tests, refactor only.

* 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): Move main resource clearing from
    ~MainResourceLoader.
(WebCore::DocumentLoader::mainResourceData):
(WebCore::DocumentLoader::stopLoading):
(WebCore::DocumentLoader::notifyFinished): Moved from MainResourceLoader::notifyFinished.
(WebCore):
(WebCore::DocumentLoader::finishedLoading):
(WebCore::DocumentLoader::handleSubstituteDataLoadNow):
(WebCore::DocumentLoader::redirectReceived):
(WebCore::DocumentLoader::continueAfterNavigationPolicy):
(WebCore::DocumentLoader::responseReceived):
(WebCore::DocumentLoader::continueAfterContentPolicy):
(WebCore::DocumentLoader::reportMemoryUsage):
(WebCore::DocumentLoader::dataReceived):
(WebCore::DocumentLoader::clearMainResourceLoader):
(WebCore::DocumentLoader::setDefersLoading):
(WebCore::DocumentLoader::setMainResourceDataBufferingPolicy):
(WebCore::DocumentLoader::addSubresourceLoader):
(WebCore::DocumentLoader::maybeLoadEmpty):
(WebCore::DocumentLoader::startLoadingMainResource): Don't keep separate checks
     for normal and empty loads, just use a single boolean.
* loader/DocumentLoader.h:
(WebCore::DocumentLoader::isLoadingMainResource):
* loader/MainResourceLoader.cpp: Removed.
* loader/MainResourceLoader.h: Removed.
* loader/mac/DocumentLoaderMac.cpp:
(WebCore::DocumentLoader::schedule):
(WebCore::DocumentLoader::unschedule):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@146449 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 [deleted file]
Source/WebCore/loader/MainResourceLoader.h [deleted file]
Source/WebCore/loader/mac/DocumentLoaderMac.cpp

index 0a44f58..8dee335 100644 (file)
@@ -1686,7 +1686,6 @@ 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 1f98675..4c3c077 100644 (file)
@@ -1,3 +1,53 @@
+2013-03-21  Nate Chapin  <japhet@chromium.org>
+
+        Merge MainResourceLoader into DocumentLoader
+        https://bugs.webkit.org/show_bug.cgi?id=104969
+
+        Reviewed by Adam Barth.
+
+        No new tests, refactor only.
+
+        * 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): Move main resource clearing from
+            ~MainResourceLoader.
+        (WebCore::DocumentLoader::mainResourceData):
+        (WebCore::DocumentLoader::stopLoading):
+        (WebCore::DocumentLoader::notifyFinished): Moved from MainResourceLoader::notifyFinished.
+        (WebCore):
+        (WebCore::DocumentLoader::finishedLoading):
+        (WebCore::DocumentLoader::handleSubstituteDataLoadNow):
+        (WebCore::DocumentLoader::redirectReceived):
+        (WebCore::DocumentLoader::continueAfterNavigationPolicy):
+        (WebCore::DocumentLoader::responseReceived):
+        (WebCore::DocumentLoader::continueAfterContentPolicy):
+        (WebCore::DocumentLoader::reportMemoryUsage):
+        (WebCore::DocumentLoader::dataReceived):
+        (WebCore::DocumentLoader::clearMainResourceLoader):
+        (WebCore::DocumentLoader::setDefersLoading):
+        (WebCore::DocumentLoader::setMainResourceDataBufferingPolicy):
+        (WebCore::DocumentLoader::addSubresourceLoader):
+        (WebCore::DocumentLoader::maybeLoadEmpty):
+        (WebCore::DocumentLoader::startLoadingMainResource): Don't keep separate checks
+             for normal and empty loads, just use a single boolean.
+        * loader/DocumentLoader.h:
+        (WebCore::DocumentLoader::isLoadingMainResource):
+        * loader/MainResourceLoader.cpp: Removed.
+        * loader/MainResourceLoader.h: Removed.
+        * loader/mac/DocumentLoaderMac.cpp:
+        (WebCore::DocumentLoader::schedule):
+        (WebCore::DocumentLoader::unschedule):
+
 2013-03-20  Ilya Tikhonovsky  <loislo@chromium.org>
 
         Web Inspector: Flame Chart. draw background for the FlameChart overview pane with the CPU aggregated data.
index 4ed5c40..61f66e9 100644 (file)
@@ -4078,8 +4078,6 @@ 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 96729af..72b60ad 100644 (file)
@@ -884,7 +884,6 @@ SOURCES += \
     loader/ImageLoader.cpp \
     loader/LinkLoader.cpp \
     loader/LoaderStrategy.cpp \
-    loader/MainResourceLoader.cpp \
     loader/MixedContentChecker.cpp \
     loader/NavigationAction.cpp \
     loader/NetscapePlugInStreamLoader.cpp \
@@ -2082,7 +2081,6 @@ HEADERS += \
     loader/LinkLoader.h \
     loader/LinkLoaderClient.h \
     loader/LoaderStrategy.h \
-    loader/MainResourceLoader.h \
     loader/MixedContentChecker.h \
     loader/NavigationAction.h \
     loader/NetscapePlugInStreamLoader.h \
index 6ff9892..bd903ea 100644 (file)
@@ -278,8 +278,12 @@ __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,7 +1300,6 @@ __ZNK7WebCore14DocumentLoader18mainResourceLoaderEv
 __ZNK7WebCore14DocumentLoader19isLoadingInAPISenseEv
 __ZNK7WebCore14DocumentLoader19originalRequestCopyEv
 __ZNK7WebCore14DocumentLoader21archiveResourceForURLERKNS_4KURLE
-__ZNK7WebCore14DocumentLoader21isLoadingMainResourceEv
 __ZNK7WebCore14DocumentLoader28urlForHistoryReflectsFailureEv
 __ZNK7WebCore14DocumentLoader3urlEv
 __ZNK7WebCore14DocumentMarker11descriptionEv
index 4ef5da7..108e6d3 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 b8265d9..31398c2 100755 (executable)
                                >
                        </File>
                        <File
-                               RelativePath="..\loader\MainResourceLoader.cpp"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\loader\MainResourceLoader.h"
-                               >
-                       </File>
-                       <File
                                RelativePath="..\loader\MixedContentChecker.cpp"
                                >
                        </File>
index 78378cd..7280693 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 a2178c7..80a655f 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 d05dc55..e3b7390 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 9dbb4fd..a1e595f 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_mainResourceLoader ? m_mainResourceLoader->loader() : 0;
+    return m_mainResource ? m_mainResource->loader() : 0;
 }
 
 DocumentLoader::~DocumentLoader()
@@ -140,16 +140,19 @@ 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_mainResourceLoader)
-        return m_mainResourceLoader->resourceData();
+    if (m_mainResource)
+        return m_mainResource->resourceBuffer();
     return 0;
 }
 
@@ -292,7 +295,7 @@ void DocumentLoader::stopLoading()
 
     FrameLoader* frameLoader = DocumentLoader::frameLoader();
     
-    if (m_mainResourceLoader)
+    if (isLoadingMainResource())
         // Stop the main resource loader and let it send the cancelled message.
         cancelMainResourceLoad(frameLoader->cancelledError(m_request));
     else if (!m_subresourceLoaders.isEmpty())
@@ -330,6 +333,26 @@ 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.
@@ -351,7 +374,7 @@ void DocumentLoader::finishedLoading(double finishTime)
         int length;
         const char* data = m_contentFilter->getReplacementData(length);
         if (data)
-            receivedData(data, length);
+            dataReceived(m_mainResource.get(), data, length);
     }
 #endif
 
@@ -385,9 +408,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 (frame() && m_mainResourceLoader) {
-        if (m_mainResourceLoader->cachedMainResource() && frame()->document()->hasManifest())
-            memoryCache()->remove(m_mainResourceLoader->cachedMainResource());
+    if (m_frame) {
+        if (m_mainResource && m_frame->document()->hasManifest())
+            memoryCache()->remove(m_mainResource.get());
     }
     m_applicationCacheHost->finishedLoadingMainResource();
 }
@@ -411,7 +434,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(response);
+    responseReceived(0, response);
 }
 
 void DocumentLoader::startDataLoadTimer()
@@ -432,6 +455,12 @@ 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
@@ -515,17 +544,21 @@ 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 = m_mainResourceLoader->loader();
+        RefPtr<ResourceLoader> resourceLoader = mainResourceLoader();
         ASSERT(resourceLoader->shouldSendResourceLoadCallbacks());
         resourceLoader->setSendCallbackPolicy(DoNotSendCallbacks);
-        m_mainResourceLoader->clearResource();
+        if (m_mainResource) {
+            m_mainResource->removeClient(this);
+            m_mainResource = 0;
+        }
         resourceLoader->setSendCallbackPolicy(SendCallbacks);
         handleSubstituteDataLoadSoon();
     }
 }
 
-void DocumentLoader::responseReceived(const ResourceResponse& response)
+void DocumentLoader::responseReceived(CachedResource* resource, const ResourceResponse& response)
 {
+    ASSERT_UNUSED(resource, m_mainResource == resource);
     RefPtr<DocumentLoader> protect(this);
     bool willLoadFallback = m_applicationCacheHost->maybeLoadFallbackForMainResponse(request(), response);
 
@@ -539,7 +572,7 @@ void DocumentLoader::responseReceived(const ResourceResponse& response)
         shouldRemoveResourceFromCache = true;
 #endif
     if (shouldRemoveResourceFromCache)
-        memoryCache()->remove(m_mainResourceLoader->cachedMainResource());
+        memoryCache()->remove(m_mainResource.get());
 
     if (willLoadFallback)
         return;
@@ -566,7 +599,7 @@ void DocumentLoader::responseReceived(const ResourceResponse& response)
 
     if (m_isLoadingMultipartContent) {
         setupForReplace();
-        m_mainResourceLoader->cachedMainResource()->clear();
+        m_mainResource->clear();
     } else if (response.isMultipart()) {
         FeatureObserver::observe(m_frame->document(), FeatureObserver::MultipartMainResource);
         m_isLoadingMultipartContent = true;
@@ -637,8 +670,8 @@ void DocumentLoader::continueAfterContentPolicy(PolicyAction policy)
     }
 
     case PolicyDownload: {
-        // The main CachedResource can be null, e.g. when loading a substitute resource from application cache.
-        if (!m_mainResourceLoader->cachedMainResource()) {
+        // m_mainResource can be null, e.g. when loading a substitute resource from application cache.
+        if (!m_mainResource) {
             mainReceivedError(frameLoader()->client()->cannotShowURLError(m_request));
             return;
         }
@@ -679,7 +712,7 @@ void DocumentLoader::continueAfterContentPolicy(PolicyAction policy)
 
     if (!isStopping() && m_substituteData.isValid()) {
         if (m_substituteData.content()->size())
-            receivedData(m_substituteData.content()->data(), m_substituteData.content()->size());
+            dataReceived(0, m_substituteData.content()->data(), m_substituteData.content()->size());
         if (isLoadingMainResource())
             finishedLoading(0);
     }
@@ -758,8 +791,7 @@ 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_mainResourceLoader, "mainResourceLoader");
-    info.addMember(m_mainResourceData, "mainResourceData");
+    info.addMember(m_mainResource, "mainResource");
     info.addMember(m_subresourceLoaders, "subresourceLoaders");
     info.addMember(m_multipartSubresourceLoaders, "multipartSubresourceLoaders");
     info.addMember(m_plugInStreamLoaders, "plugInStreamLoaders");
@@ -788,10 +820,11 @@ void DocumentLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     info.addMember(m_applicationCacheHost, "applicationCacheHost");
 }
 
-void DocumentLoader::receivedData(const char* data, int length)
+void DocumentLoader::dataReceived(CachedResource* resource, const char* data, int length)
 {
     ASSERT(data);
     ASSERT(length);
+    ASSERT_UNUSED(resource, resource == m_mainResource);
     ASSERT(!m_response.isNull());
 
 #if USE(CFNETWORK) || PLATFORM(MAC)
@@ -901,12 +934,7 @@ void DocumentLoader::detachFromFrame()
 
 void DocumentLoader::clearMainResourceLoader()
 {
-    if (m_mainResourceLoader) {
-        m_mainResourceData = m_mainResourceLoader->resourceData();
-        m_mainResourceLoader = 0;
-    }
-    m_loadingEmptyDocument = false;
-
+    m_loadingMainResource = false;
     if (this == frameLoader()->activeDocumentLoader())
         checkLoadComplete();
 }
@@ -1243,8 +1271,8 @@ const KURL& DocumentLoader::unreachableURL() const
 
 void DocumentLoader::setDefersLoading(bool defers)
 {
-    if (m_mainResourceLoader)
-        m_mainResourceLoader->setDefersLoading(defers);
+    if (mainResourceLoader())
+        mainResourceLoader()->setDefersLoading(defers);
     setAllDefersLoading(m_subresourceLoaders, defers);
     setAllDefersLoading(m_plugInStreamLoaders, defers);
     if (!defers)
@@ -1253,8 +1281,8 @@ void DocumentLoader::setDefersLoading(bool defers)
 
 void DocumentLoader::setMainResourceDataBufferingPolicy(DataBufferingPolicy dataBufferingPolicy)
 {
-    if (m_mainResourceLoader)
-        m_mainResourceLoader->setDataBufferingPolicy(dataBufferingPolicy);
+    if (m_mainResource)
+        m_mainResource->setDataBufferingPolicy(dataBufferingPolicy);
 }
 
 void DocumentLoader::stopLoadingPlugIns()
@@ -1271,13 +1299,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, m_mainResourceLoader->loader()
+    // let it be added. In the main resource load case, mainResourceLoader()
     // 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(!m_mainResourceLoader || m_mainResourceLoader->loader() != loader);
+    ASSERT(!mainResourceLoader() || mainResourceLoader() != loader);
     m_subresourceLoaders.add(loader);
 }
 
@@ -1302,11 +1330,6 @@ void DocumentLoader::removePlugInStreamLoader(ResourceLoader* loader)
     checkLoadComplete();
 }
 
-bool DocumentLoader::isLoadingMainResource() const
-{
-    return !!m_mainResourceLoader || m_loadingEmptyDocument;
-}
-
 bool DocumentLoader::isMultipartReplacingLoad() const
 {
     return isLoadingMultipartContent() && frameLoader()->isReplacing();
@@ -1318,7 +1341,6 @@ 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());
@@ -1331,13 +1353,13 @@ void DocumentLoader::startLoadingMainResource()
 {
     m_mainDocumentError = ResourceError();
     timing()->markNavigationStart();
-    ASSERT(!m_mainResourceLoader);
+    ASSERT(!m_mainResource);
+    ASSERT(!m_loadingMainResource);
+    m_loadingMainResource = true;
 
     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,
@@ -1364,10 +1386,12 @@ void DocumentLoader::startLoadingMainResource()
     }
 
     ResourceRequest request(m_request);
-    m_mainResourceLoader->load(m_request);
-
-    if (m_request.isNull()) {
-        m_mainResourceLoader = 0;
+    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());
         // 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.
@@ -1381,6 +1405,7 @@ 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 92d7117..47e7359 100644 (file)
@@ -30,6 +30,8 @@
 #ifndef DocumentLoader_h
 #define DocumentLoader_h
 
+#include "CachedRawResource.h"
+#include "CachedResourceHandle.h"
 #include "DocumentLoadTiming.h"
 #include "DocumentWriter.h"
 #include "IconDatabaseBase.h"
@@ -65,7 +67,6 @@ namespace WebCore {
     class FormState;
     class Frame;
     class FrameLoader;
-    class MainResourceLoader;
     class Page;
     class ResourceBuffer;
     class ResourceLoader;
@@ -75,7 +76,8 @@ namespace WebCore {
     typedef HashSet<RefPtr<ResourceLoader> > ResourceLoaderSet;
     typedef Vector<ResourceResponse> ResponseVector;
 
-    class DocumentLoader : public RefCounted<DocumentLoader> {
+    class DocumentLoader : public RefCounted<DocumentLoader>, private CachedRawResourceClient {
+        WTF_MAKE_FAST_ALLOCATED;
     public:
         static PassRefPtr<DocumentLoader> create(const ResourceRequest& request, const SubstituteData& data)
         {
@@ -214,8 +216,8 @@ namespace WebCore {
         void continueIconLoadWithDecision(IconLoadDecision);
         void getIconLoadDecisionForIconURL(const String&);
         void getIconDataForIconURL(const String&);
-        
-        bool isLoadingMainResource() const;
+
+        bool isLoadingMainResource() const { return m_loadingMainResource; }
         bool isLoadingMultipartContent() const { return m_isLoadingMultipartContent; }
 
         void stopLoadingPlugIns();
@@ -262,9 +264,6 @@ 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&);
 
@@ -281,6 +280,12 @@ 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;
@@ -310,12 +315,10 @@ namespace WebCore {
         Frame* m_frame;
         RefPtr<CachedResourceLoader> m_cachedResourceLoader;
 
-        RefPtr<MainResourceLoader> m_mainResourceLoader;
+        CachedResourceHandle<CachedRawResource> m_mainResource;
         ResourceLoaderSet m_subresourceLoaders;
         ResourceLoaderSet m_multipartSubresourceLoaders;
         ResourceLoaderSet m_plugInStreamLoaders;
-
-        RefPtr<ResourceBuffer> m_mainResourceData;
         
         mutable DocumentWriter m_writer;
 
@@ -345,7 +348,6 @@ 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.
@@ -385,6 +387,7 @@ 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
deleted file mode 100644 (file)
index 0158e42..0000000
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * 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
deleted file mode 100644 (file)
index c014047..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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 0b53b36..8850f1e 100644 (file)
@@ -28,7 +28,6 @@
 
 #include "config.h"
 #include "DocumentLoader.h"
-#include "MainResourceLoader.h"
 #include "ResourceHandle.h"
 #include "ResourceLoader.h"
 #include <wtf/UnusedParam.h>
@@ -55,8 +54,8 @@ static void unscheduleAll(const ResourceLoaderSet& loaders, SchedulePair* pair)
 
 void DocumentLoader::schedule(SchedulePair* pair)
 {
-    if (m_mainResourceLoader && m_mainResourceLoader->loader() && m_mainResourceLoader->loader()->handle())
-        m_mainResourceLoader->loader()->handle()->schedule(pair);
+    if (mainResourceLoader() && mainResourceLoader()->handle())
+        mainResourceLoader()->handle()->schedule(pair);
     scheduleAll(m_subresourceLoaders, pair);
     scheduleAll(m_plugInStreamLoaders, pair);
     scheduleAll(m_multipartSubresourceLoaders, pair);
@@ -64,8 +63,8 @@ void DocumentLoader::schedule(SchedulePair* pair)
 
 void DocumentLoader::unschedule(SchedulePair* pair)
 {
-    if (m_mainResourceLoader && m_mainResourceLoader->loader() && m_mainResourceLoader->loader()->handle())
-        m_mainResourceLoader->loader()->handle()->unschedule(pair);
+    if (mainResourceLoader() && mainResourceLoader()->handle())
+        mainResourceLoader()->handle()->unschedule(pair);
     unscheduleAll(m_subresourceLoaders, pair);
     unscheduleAll(m_plugInStreamLoaders, pair);
     unscheduleAll(m_multipartSubresourceLoaders, pair);