Reviewed by Anders.

        - fixed <rdar://problem/4963871> REGRESSION: Crash occurs at WebCore::Frame::loader() when attempting to open a saved archive file

        * loader/DocumentLoader.cpp:
        (WebCore::DocumentLoader::request): Removed obsolete FIXME.
        (WebCore::DocumentLoader::initialRequest): Ditto.
        * loader/MainResourceLoader.cpp:
        (WebCore::MainResourceLoader::MainResourceLoader): Handle data loads from a timer, otherwise bad things happen.
        (WebCore::MainResourceLoader::handleDataLoadNow):
        (WebCore::MainResourceLoader::handleDataLoadSoon):
        (WebCore::MainResourceLoader::loadNow):
        (WebCore::MainResourceLoader::didCancel): cancel data load timer
        * loader/MainResourceLoader.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@19281 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/loader/MainResourceLoader.cpp b/WebCore/loader/MainResourceLoader.cpp
index 4b67744..6f28003 100644
--- a/WebCore/loader/MainResourceLoader.cpp
+++ b/WebCore/loader/MainResourceLoader.cpp
@@ -42,6 +42,7 @@
 
 MainResourceLoader::MainResourceLoader(Frame* frame)
     : ResourceLoader(frame)
+    , m_dataLoadTimer(this, &MainResourceLoader::handleDataLoadNow)
     , m_loadingMultipartContent(false)
     , m_waitingForContentPolicy(false)
 {
@@ -76,6 +77,8 @@
 
 void MainResourceLoader::didCancel(const ResourceError& error)
 {
+    m_dataLoadTimer.stop();
+
     // Calling receivedMainResourceError will likely result in the last reference to this object to go away.
     RefPtr<MainResourceLoader> protect(this);
 
@@ -318,14 +321,20 @@
     didReceiveResponse(response);
 }
 
-void MainResourceLoader::handleDataLoad(ResourceRequest& r)
+void MainResourceLoader::handleDataLoadNow(Timer<MainResourceLoader>*)
 {
     RefPtr<MainResourceLoader> protect(this);
 
-    ResourceResponse response(r.url(), m_substituteData.mimeType(), m_substituteData.content()->size(), m_substituteData.textEncoding(), "");
+    ResourceResponse response(m_initialRequest.url(), m_substituteData.mimeType(), m_substituteData.content()->size(), m_substituteData.textEncoding(), "");
     didReceiveResponse(response);
 }
 
+void MainResourceLoader::handleDataLoadSoon(ResourceRequest& r)
+{
+    m_initialRequest = r;
+    m_dataLoadTimer.startOneShot(0);
+}
+
 bool MainResourceLoader::loadNow(ResourceRequest& r)
 {
     bool shouldLoadEmptyBeforeRedirect = shouldLoadAsEmptyDocument(r.url());
@@ -350,7 +359,7 @@
         return true;
 
     if (m_substituteData.isValid())
-        handleDataLoad(r);
+        handleDataLoadSoon(r);
     else if (shouldLoadEmpty || frameLoader()->representationExistsForURLScheme(url.protocol()))
         handleEmptyLoad(url, !shouldLoadEmpty);
     else