[SCM] WebKit Debian packaging branch, debian/experimental, updated. debian/1.3.8-1-1049-g2e11a8e

mrobinson at webkit.org mrobinson at webkit.org
Fri Jan 21 14:49:59 UTC 2011


The following commit has been merged in the debian/experimental branch:
commit fa5135b5d3b4e5758284416d143e946fd3c76048
Author: mrobinson at webkit.org <mrobinson at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Jan 1 02:17:26 2011 +0000

    2010-12-31  Martin Robinson  <mrobinson at igalia.com>
    
            Reviewed by Xan Lopez.
    
            [GTK] Use GLib/GIO API for FileSystemGtk implementation
            https://bugs.webkit.org/show_bug.cgi?id=51617
    
            Complete implementation of FileSystem platform code for GLib. This
            converts remaining API points using POSIX calls to platform-independent
            GLib calls and fixes other compilation errors.
    
            No new tests. This code will be tested when an implementation
            of beginDragWithFiles is complete.
    
            (WebCore::JSDirectoryEntry::getFile):
            (WebCore::JSDirectoryEntry::getDirectory):
            * platform/FileSystem.h: Added forward declarations for GLib types to
            avoid GLib includes and changed the PlatformFileHandle to be a GIOStream.
            * platform/gtk/FileSystemGtk.cpp:
            (WebCore::openTemporaryFile): Reimplement using only GLib calls.
            (WebCore::openFile): Ditto.
            (WebCore::closeFile): Ditto.
            (WebCore::seekFile): Added implementation.
            (WebCore::writeToFile): Reimplement using only GLib calls.
            (WebCore::readFromFile): Ditto.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74842 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ca98498..d06cbf8 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,29 @@
+2010-12-31  Martin Robinson  <mrobinson at igalia.com>
+
+        Reviewed by Xan Lopez.
+
+        [GTK] Use GLib/GIO API for FileSystemGtk implementation
+        https://bugs.webkit.org/show_bug.cgi?id=51617
+
+        Complete implementation of FileSystem platform code for GLib. This
+        converts remaining API points using POSIX calls to platform-independent
+        GLib calls and fixes other compilation errors.
+
+        No new tests. This code will be tested when an implementation
+        of beginDragWithFiles is complete.
+
+        (WebCore::JSDirectoryEntry::getFile):
+        (WebCore::JSDirectoryEntry::getDirectory):
+        * platform/FileSystem.h: Added forward declarations for GLib types to
+        avoid GLib includes and changed the PlatformFileHandle to be a GIOStream.
+        * platform/gtk/FileSystemGtk.cpp:
+        (WebCore::openTemporaryFile): Reimplement using only GLib calls.
+        (WebCore::openFile): Ditto.
+        (WebCore::closeFile): Ditto.
+        (WebCore::seekFile): Added implementation.
+        (WebCore::writeToFile): Reimplement using only GLib calls.
+        (WebCore::readFromFile): Ditto.
+
 2010-12-31  Darin Adler  <darin at apple.com>
 
         Reviewed by Dan Bernstein.
diff --git a/WebCore/platform/FileSystem.h b/WebCore/platform/FileSystem.h
index 32ab417..3b65d34 100644
--- a/WebCore/platform/FileSystem.h
+++ b/WebCore/platform/FileSystem.h
@@ -30,9 +30,6 @@
 #ifndef FileSystem_h
 #define FileSystem_h
 
-#if PLATFORM(GTK)
-#include <gmodule.h>
-#endif
 #if PLATFORM(QT)
 #include <QFile>
 #include <QLibrary>
@@ -64,6 +61,11 @@ typedef HINSTANCE HMODULE;
 typedef struct _IFile IFile;
 #endif
 
+#if PLATFORM(GTK)
+typedef struct _GFileIOStream GFileIOStream;
+typedef struct _GModule GModule;
+#endif
+
 namespace WebCore {
 
 // PlatformModule
@@ -122,6 +124,9 @@ typedef IFile* PlatformFileHandle;
 const PlatformFileHandle invalidPlatformFileHandle = 0;
 typedef void* PlatformModule;
 typedef unsigned PlatformModuleVersion;
+#elif PLATFORM(GTK)
+typedef GFileIOStream* PlatformFileHandle;
+const PlatformFileHandle invalidPlatformFileHandle = 0;
 #else
 typedef int PlatformFileHandle;
 const PlatformFileHandle invalidPlatformFileHandle = -1;
diff --git a/WebCore/platform/gtk/FileSystemGtk.cpp b/WebCore/platform/gtk/FileSystemGtk.cpp
index 4424f0a..1f6c953 100644
--- a/WebCore/platform/gtk/FileSystemGtk.cpp
+++ b/WebCore/platform/gtk/FileSystemGtk.cpp
@@ -24,12 +24,11 @@
 
 #include "GOwnPtr.h"
 #include "PlatformString.h"
-
-#include <errno.h>
-#include <fcntl.h>
+#include "UUID.h"
+#include <gio/gio.h>
 #include <glib.h>
 #include <glib/gstdio.h>
-#include <unistd.h>
+#include <wtf/gobject/GRefPtr.h>
 #include <wtf/text/CString.h>
 
 namespace WebCore {
@@ -216,75 +215,86 @@ Vector<String> listDirectory(const String& path, const String& filter)
 
 CString openTemporaryFile(const char* prefix, PlatformFileHandle& handle)
 {
-    gchar* filename = g_strdup_printf("%sXXXXXX", prefix);
-    gchar* tempPath = g_build_filename(g_get_tmp_dir(), filename, NULL);
-    g_free(filename);
+    GOwnPtr<gchar> filename(g_strdup_printf("%s%s", prefix, createCanonicalUUIDString().utf8().data()));
+    GOwnPtr<gchar> tempPath(g_build_filename(g_get_tmp_dir(), filename.get(), NULL));
+    PlatformRefPtr<GFile> file = adoptPlatformRef(g_file_new_for_path(tempPath.get()));
 
-    int fileDescriptor = g_mkstemp(tempPath);
-    if (!isHandleValid(fileDescriptor)) {
-        LOG_ERROR("Can't create a temporary file.");
-        g_free(tempPath);
+    handle = g_file_create_readwrite(file.get(), G_FILE_CREATE_NONE, 0, 0);
+    if (!isHandleValid(handle))
         return CString();
-    }
-    CString tempFilePath = tempPath;
-    g_free(tempPath);
-
-    handle = fileDescriptor;
-    return tempFilePath;
+    return tempPath.get();
 }
 
 PlatformFileHandle openFile(const String& path, FileOpenMode mode)
 {
     CString fsRep = fileSystemRepresentation(path);
-
     if (fsRep.isNull())
         return invalidPlatformFileHandle;
 
-    int platformFlag = 0;
+    PlatformRefPtr<GFile> file = adoptPlatformRef(g_file_new_for_path(fsRep.data()));
+    GFileIOStream* ioStream = 0;
     if (mode == OpenForRead)
-        platformFlag |= O_RDONLY;
-    else if (mode == OpenForWrite)
-        platformFlag |= (O_WRONLY | O_CREAT | O_TRUNC);
+        ioStream = g_file_open_readwrite(file.get(), 0, 0);
+    else if (mode == OpenForWrite) {
+        if (g_file_test(fsRep.data(), static_cast<GFileTest>(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)))
+            ioStream = g_file_open_readwrite(file.get(), 0, 0);
+        else
+            ioStream = g_file_create_readwrite(file.get(), G_FILE_CREATE_NONE, 0, 0);
+    }
 
-    return g_open(fsRep.data(), platformFlag, 0666);
+    return ioStream;
 }
 
 void closeFile(PlatformFileHandle& handle)
 {
-    if (isHandleValid(handle)) {
-        close(handle);
-        handle = invalidPlatformFileHandle;
-    }
+    if (!isHandleValid(handle))
+        return;
+
+    g_io_stream_close(G_IO_STREAM(handle), 0, 0);
+    g_object_unref(handle);
+    handle = invalidPlatformFileHandle;
 }
 
 long long seekFile(PlatformFileHandle handle, long long offset, FileSeekOrigin origin)
 {
-    // FIXME - Awaiting implementation, see https://bugs.webkit.org/show_bug.cgi?id=43878
-    return -1;
+    GSeekType seekType = G_SEEK_SET;
+    switch (origin) {
+    case SeekFromBeginning:
+        seekType = G_SEEK_SET;
+        break;
+    case SeekFromCurrent:
+        seekType = G_SEEK_CUR;
+        break;
+    case SeekFromEnd:
+        seekType = G_SEEK_END;
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+    }
+
+    if (!g_seekable_seek(G_SEEKABLE(g_io_stream_get_input_stream(G_IO_STREAM(handle))),
+                         offset, seekType, 0, 0))
+        return -1;
+    return g_seekable_tell(G_SEEKABLE(g_io_stream_get_input_stream(G_IO_STREAM(handle))));
 }
 
 int writeToFile(PlatformFileHandle handle, const char* data, int length)
 {
-    int totalBytesWritten = 0;
-    while (totalBytesWritten < length) {
-        int bytesWritten = write(handle, data, length - totalBytesWritten);
-        if (bytesWritten < 0)
-            return -1;
-        totalBytesWritten += bytesWritten;
-        data += bytesWritten;
-    }
-
-    return totalBytesWritten;
+    gsize bytesWritten;
+    g_output_stream_write_all(g_io_stream_get_output_stream(G_IO_STREAM(handle)),
+                              data, length, &bytesWritten, 0, 0);
+    return bytesWritten;
 }
 
 int readFromFile(PlatformFileHandle handle, char* data, int length)
 {
+    GOwnPtr<GError> error;
     do {
-        int bytesRead = read(handle, data, static_cast<size_t>(length));
+        gssize bytesRead = g_input_stream_read(g_io_stream_get_input_stream(G_IO_STREAM(handle)),
+                                               data, length, 0, &error.outPtr());
         if (bytesRead >= 0)
             return bytesRead;
-    } while (errno == EINTR);
-
+    } while (error && error->code == G_FILE_ERROR_INTR);
     return -1;
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list