2006-10-18 Steve Falkenburg <sfalken@apple.com>
authorsfalken <sfalken@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Oct 2006 23:28:27 +0000 (23:28 +0000)
committersfalken <sfalken@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Oct 2006 23:28:27 +0000 (23:28 +0000)
        Reviewed by Adam, Brady.

        Loader tweaks.

        * platform/cf/ResourceLoaderCFNet.cpp:
        (WebCore::didFinishLoading):
        (WebCore::didFail):
        (WebCore::didReceiveChallenge):
        (WebCore::runLoaderThread):
        (WebCore::ResourceLoader::start):
        (WebCore::ResourceLoader::cancel):

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

WebCore/ChangeLog
WebCore/platform/cf/ResourceLoaderCFNet.cpp

index 25d52e6bd8563934258e746f80a5cc8c2cfce100..2fc053f0dc7e667fe643665be1feb6e4bcef56bd 100644 (file)
@@ -1,3 +1,17 @@
+2006-10-18  Steve Falkenburg  <sfalken@apple.com>
+
+        Reviewed by Adam, Brady.
+
+        Loader tweaks.
+
+        * platform/cf/ResourceLoaderCFNet.cpp:
+        (WebCore::didFinishLoading):
+        (WebCore::didFail):
+        (WebCore::didReceiveChallenge):
+        (WebCore::runLoaderThread):
+        (WebCore::ResourceLoader::start):
+        (WebCore::ResourceLoader::cancel):
+
 2006-10-18  Timothy Hatcher  <timothy@apple.com>
 
         Reviewed by Darin.
index 8e9c799b2f01915064b92afd58431c1f60389ce4..ff746a2f42fe3c6766a0fd6dca1b3bbd7ec15efa 100644 (file)
@@ -76,20 +76,6 @@ CFURLRequestRef willSendRequest(CFURLConnectionRef conn, CFURLRequestRef request
     return request;
 }
 
-void didReceiveChallenge(CFURLConnectionRef conn, CFURLAuthChallengeRef challenge, const void* clientInfo) 
-{
-    ResourceLoader* job = (ResourceLoader*)clientInfo;
-
-    // Do nothing right now
-}
-
-void didCancelChallenge(CFURLConnectionRef conn, CFURLAuthChallengeRef challenge, const void* clientInfo) 
-{
-    ResourceLoader* job = (ResourceLoader*)clientInfo;
-    
-    // Do nothing right now
-}
-
 void didReceiveResponse(CFURLConnectionRef conn, CFURLResponseRef response, const void* clientInfo) 
 {
     ResourceLoader* job = (ResourceLoader*)clientInfo;
@@ -130,6 +116,7 @@ void didFinishLoading(CFURLConnectionRef conn, const void* clientInfo)
 
     job->client()->receivedAllData(job, 0);
     job->client()->receivedAllData(job);
+    job->kill();
 }
 
 void didFail(CFURLConnectionRef conn, CFStreamError error, const void* clientInfo) 
@@ -145,6 +132,7 @@ void didFail(CFURLConnectionRef conn, CFStreamError error, const void* clientInf
     job->setError(1);
     job->client()->receivedAllData(job, 0);
     job->client()->receivedAllData(job);
+    job->kill();
 }
 
 CFCachedURLResponseRef willCacheResponse(CFURLConnectionRef conn, CFCachedURLResponseRef cachedResponse, const void* clientInfo) 
@@ -153,6 +141,13 @@ CFCachedURLResponseRef willCacheResponse(CFURLConnectionRef conn, CFCachedURLRes
     return cachedResponse;
 }
 
+void didReceiveChallenge(CFURLConnectionRef conn, CFURLAuthChallengeRef challenge, const void* clientInfo)
+{
+    ResourceLoader* job = (ResourceLoader*)clientInfo;
+
+    // Do nothing right now
+}
+
 const unsigned BUF_LENGTH = 500;
 const char* dummyBytes = "GET / HTTP/1.1\r\n";
 void addHeadersFromString(CFHTTPMessageRef request, CFStringRef headerString) 
@@ -233,7 +228,6 @@ void emptyPerform(void* unused)
 {
 }
 
-#if defined(LOADER_THREAD)
 static CFRunLoopRef loaderRL = 0;
 void runLoaderThread(void *unused)
 {
@@ -246,7 +240,6 @@ void runLoaderThread(void *unused)
 
     CFRunLoopRun();
 }
-#endif
 
 bool ResourceLoader::start(DocLoader* docLoader)
 {
@@ -257,6 +250,8 @@ bool ResourceLoader::start(DocLoader* docLoader)
     CFHTTPMessageRef httpRequest = CFHTTPMessageCreateRequest(0, requestMethod, url, kCFHTTPVersion1_1);
     CFRelease(requestMethod);
     
+    ref();
+    d->m_loading = true;
     str = queryMetaData("customHTTPHeader");
     CFStringRef headerString = CFStringCreateWithCharacters(0, (const UniChar *)str.characters(), str.length());
     if (headerString) {
@@ -326,24 +321,19 @@ bool ResourceLoader::start(DocLoader* docLoader)
     }
 
     CFURLRequestRef request = CFURLRequestCreateHTTPRequest(0, httpRequest, bodyStream, kCFURLRequestCachePolicyProtocolDefault, 30.0, 0);
-    CFURLConnectionClient client = {0, this, 0, 0, 0, willSendRequest, didReceiveChallenge, didCancelChallenge, didReceiveResponse, didReceiveData, didFinishLoading, didFail};
+    CFURLConnectionClient client = {0, this, 0, 0, 0, willSendRequest, didReceiveResponse, didReceiveData, NULL, didFinishLoading, didFail, willCacheResponse, didReceiveChallenge};
     d->m_connection = CFURLConnectionCreate(0, request, &client);
     CFRelease(request);
-    CFURLConnectionSetMaximumBufferSize(d->m_connection, 32*1024); // Buffer up to 32K at a time
 
-#if defined(LOADER_THREAD)
     if (!loaderRL) {
         _beginthread(runLoaderThread, 0, 0);
         while (loaderRL == 0) {
             Sleep(10);
         }
     }
-#endif
 
-    CFURLConnectionScheduleWithRunLoop(d->m_connection, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
-#if defined(LOADER_THREAD)
+    CFURLConnectionScheduleWithCurrentMessageQueue(d->m_connection);
     CFURLConnectionScheduleDownloadWithRunLoop(d->m_connection, loaderRL, kCFRunLoopDefaultMode);
-#endif
     CFURLConnectionStart(d->m_connection);
 
 #if defined(LOG_RESOURCELOADER_EVENTS)
@@ -362,6 +352,11 @@ void ResourceLoader::cancel()
         CFRelease(d->m_connection);
         d->m_connection = 0;
     }
+
+    // Copied directly from ResourceLoaderWin.cpp
+    setError(1);
+    d->client->receivedAllData(this, 0);
+    d->client->receivedAllData(this);
 }
 
 } // namespace WebCore