2006-09-14 MorganL <morlmor@yahoo.com>
authorbdash <bdash@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Sep 2006 07:29:13 +0000 (07:29 +0000)
committerbdash <bdash@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Sep 2006 07:29:13 +0000 (07:29 +0000)
        Reviewed by Brady.

        Fixes http://bugzilla.opendarwin.org/show_bug.cgi?id=10845
        Various bugs/crashes in ResourceLoaderWin with local files.

        * platform/ResourceLoaderInternal.h:
        (WebCore::ResourceLoaderInternal::ResourceLoaderInternal):
        * platform/win/ResourceLoaderWin.cpp:
        (WebCore::ResourceLoaderInternal::~ResourceLoaderInternal):
        (WebCore::ResourceLoader::fileLoadTimer):

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

WebCore/ChangeLog
WebCore/platform/ResourceLoaderInternal.h
WebCore/platform/win/ResourceLoaderWin.cpp

index 00cea392ba1876dbf36ffb3d5ce0848e72d878f2..0f6347c3ea97528be337a23d679e883f32f14991 100644 (file)
@@ -1,3 +1,16 @@
+2006-09-14  MorganL  <morlmor@yahoo.com>
+
+        Reviewed by Brady.
+
+        Fixes http://bugzilla.opendarwin.org/show_bug.cgi?id=10845
+        Various bugs/crashes in ResourceLoaderWin with local files.
+
+        * platform/ResourceLoaderInternal.h:
+        (WebCore::ResourceLoaderInternal::ResourceLoaderInternal):
+        * platform/win/ResourceLoaderWin.cpp:
+        (WebCore::ResourceLoaderInternal::~ResourceLoaderInternal):
+        (WebCore::ResourceLoader::fileLoadTimer):
+
 2006-09-13  Brady Eidson <beidson@apple.com>
 
         Reviewed by Maciej
index b271c429bc49bb1cab1059a3d9c6cca4e90ce453..5d09666994e64c870fd4ec816ec51461745286e1 100644 (file)
@@ -37,7 +37,7 @@
 #endif
 
 #if USE(WININET)
-typedef void* HANDLE;
+#include <windows.h>
 #endif
 
 #if PLATFORM(GDK)
@@ -71,7 +71,7 @@ namespace WebCore {
             , response(nil)
 #endif
 #if USE(WININET)
-            , m_fileHandle(0)
+            , m_fileHandle(INVALID_HANDLE_VALUE)
             , m_fileLoadTimer(job, &ResourceLoader::fileLoadTimer)
             , m_resourceHandle(0)
             , m_secondaryHandle(0)
@@ -103,7 +103,7 @@ namespace WebCore {
             , response(nil)
 #endif
 #if USE(WININET)
-            , m_fileHandle(0)
+            , m_fileHandle(INVALID_HANDLE_VALUE)
             , m_fileLoadTimer(job, &ResourceLoader::fileLoadTimer)
             , m_resourceHandle(0)
             , m_secondaryHandle(0)
index e35ab42a5e1f7c913101e825a3e47051833b1ae9..67ec844349da7b1dd4cd8a58f24192f6a29cd8bc 100644 (file)
@@ -233,7 +233,7 @@ static void initializeOffScreenResourceLoaderWindow()
 
 ResourceLoaderInternal::~ResourceLoaderInternal()
 {
-    if (m_fileHandle)
+    if (m_fileHandle != INVALID_HANDLE_VALUE)
         CloseHandle(m_fileHandle);
 }
 
@@ -264,6 +264,8 @@ bool ResourceLoader::start(DocLoader* docLoader)
             path = path.mid(1);
         d->m_fileHandle = CreateFileA(path.ascii(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
 
+        // FIXME: perhaps this error should be reported asynchronously for
+        // consistency.
         if (d->m_fileHandle == INVALID_HANDLE_VALUE) {
             delete this;
             return false;
@@ -330,12 +332,15 @@ void ResourceLoader::fileLoadTimer(Timer<ResourceLoader>* timer)
         const int bufferSize = 8192;
         char buffer[bufferSize];
         result = ReadFile(d->m_fileHandle, &buffer, bufferSize, &bytesRead, NULL); 
-        d->client->receivedData(this, buffer, bytesRead);
+        if (result && bytesRead)
+            d->client->receivedData(this, buffer, bytesRead);
         // Check for end of file. 
     } while (result && bytesRead);
 
+    // FIXME: handle errors better
+
     CloseHandle(d->m_fileHandle);
-    d->m_fileHandle = 0;
+    d->m_fileHandle = INVALID_HANDLE_VALUE;
 
     PlatformDataStruct platformData;
     platformData.errorString = 0;