[Chromium] Move fileUtilities to Platform.h
authorpilgrim@chromium.org <pilgrim@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 May 2012 01:12:35 +0000 (01:12 +0000)
committerpilgrim@chromium.org <pilgrim@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 May 2012 01:12:35 +0000 (01:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=86777

Reviewed by Adam Barth.

Part of a refactoring series. See tracking bug 82948.

Source/Platform:

* Platform.gypi:
* chromium/public/Platform.h:
(WebKit):
(Platform):
(WebKit::Platform::fileUtilities):
* chromium/public/WebFileUtilities.h: Added.
(WebKit):
(WebFileUtilities):
(WebKit::WebFileUtilities::revealFolderInOS):
(WebKit::WebFileUtilities::fileExists):
(WebKit::WebFileUtilities::deleteFile):
(WebKit::WebFileUtilities::deleteEmptyDirectory):
(WebKit::WebFileUtilities::getFileSize):
(WebKit::WebFileUtilities::getFileModificationTime):
(WebKit::WebFileUtilities::directoryName):
(WebKit::WebFileUtilities::pathByAppendingComponent):
(WebKit::WebFileUtilities::makeAllDirectories):
(WebKit::WebFileUtilities::getAbsolutePath):
(WebKit::WebFileUtilities::isDirectory):
(WebKit::WebFileUtilities::filePathToURL):
(WebKit::WebFileUtilities::openFile):
(WebKit::WebFileUtilities::closeFile):
(WebKit::WebFileUtilities::seekFile):
(WebKit::WebFileUtilities::truncateFile):
(WebKit::WebFileUtilities::readFromFile):
(WebKit::WebFileUtilities::writeToFile):
(WebKit::WebFileUtilities::~WebFileUtilities):

Source/WebKit/chromium:

* WebKit.gyp:
* public/WebFileUtilities.h:
* public/platform/WebKitPlatformSupport.h:
(WebKit):
(WebKitPlatformSupport):
* src/PlatformSupport.cpp:
(WebCore::PlatformSupport::fileExists):
(WebCore::PlatformSupport::deleteFile):
(WebCore::PlatformSupport::deleteEmptyDirectory):
(WebCore::PlatformSupport::getFileSize):
(WebCore::PlatformSupport::revealFolderInOS):
(WebCore::PlatformSupport::getFileModificationTime):
(WebCore::PlatformSupport::directoryName):
(WebCore::PlatformSupport::pathByAppendingComponent):
(WebCore::PlatformSupport::makeAllDirectories):
(WebCore::PlatformSupport::getAbsolutePath):
(WebCore::PlatformSupport::isDirectory):
(WebCore::PlatformSupport::filePathToURL):
(WebCore::PlatformSupport::openFile):
(WebCore::PlatformSupport::closeFile):
(WebCore::PlatformSupport::seekFile):
(WebCore::PlatformSupport::truncateFile):
(WebCore::PlatformSupport::readFromFile):
(WebCore::PlatformSupport::writeToFile):

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

Source/Platform/ChangeLog
Source/Platform/Platform.gypi
Source/Platform/chromium/public/Platform.h
Source/Platform/chromium/public/WebFileUtilities.h [new file with mode: 0644]
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/WebKit.gyp
Source/WebKit/chromium/public/WebFileUtilities.h
Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h
Source/WebKit/chromium/src/PlatformSupport.cpp

index 23f9dca..36da1ae 100644 (file)
@@ -1,3 +1,40 @@
+2012-05-17  Mark Pilgrim  <pilgrim@chromium.org>
+
+        [Chromium] Move fileUtilities to Platform.h
+        https://bugs.webkit.org/show_bug.cgi?id=86777
+
+        Reviewed by Adam Barth.
+
+        Part of a refactoring series. See tracking bug 82948.
+
+        * Platform.gypi:
+        * chromium/public/Platform.h:
+        (WebKit):
+        (Platform):
+        (WebKit::Platform::fileUtilities):
+        * chromium/public/WebFileUtilities.h: Added.
+        (WebKit):
+        (WebFileUtilities):
+        (WebKit::WebFileUtilities::revealFolderInOS):
+        (WebKit::WebFileUtilities::fileExists):
+        (WebKit::WebFileUtilities::deleteFile):
+        (WebKit::WebFileUtilities::deleteEmptyDirectory):
+        (WebKit::WebFileUtilities::getFileSize):
+        (WebKit::WebFileUtilities::getFileModificationTime):
+        (WebKit::WebFileUtilities::directoryName):
+        (WebKit::WebFileUtilities::pathByAppendingComponent):
+        (WebKit::WebFileUtilities::makeAllDirectories):
+        (WebKit::WebFileUtilities::getAbsolutePath):
+        (WebKit::WebFileUtilities::isDirectory):
+        (WebKit::WebFileUtilities::filePathToURL):
+        (WebKit::WebFileUtilities::openFile):
+        (WebKit::WebFileUtilities::closeFile):
+        (WebKit::WebFileUtilities::seekFile):
+        (WebKit::WebFileUtilities::truncateFile):
+        (WebKit::WebFileUtilities::readFromFile):
+        (WebKit::WebFileUtilities::writeToFile):
+        (WebKit::WebFileUtilities::~WebFileUtilities):
+
 2012-05-11  James Robinson  <jamesr@chromium.org>
 
         [chromium] Convert GraphicsLayerChromium to use WebLayer types
index 59cafb5..091eb98 100644 (file)
@@ -47,6 +47,7 @@
             'chromium/public/WebDragData.h',
             'chromium/public/WebExternalTextureLayer.h',
             'chromium/public/WebFileSystem.h',
+            'chromium/public/WebFileUtilities.h',
             'chromium/public/WebFilterOperation.h',
             'chromium/public/WebFilterOperations.h',
             'chromium/public/WebFloatPoint.h',
index 7bc8523..678fcbb 100644 (file)
@@ -44,6 +44,7 @@ class WebAudioBus;
 class WebBlobRegistry;
 class WebClipboard;
 class WebFileSystem;
+class WebFileUtilities;
 class WebMediaStreamCenter;
 class WebMediaStreamCenterClient;
 class WebMimeRegistry;
@@ -66,6 +67,9 @@ public:
     virtual WebClipboard* clipboard() { return 0; }
 
     // Must return non-null.
+    virtual WebFileUtilities* fileUtilities() { return 0; }
+
+    // Must return non-null.
     virtual WebMimeRegistry* mimeRegistry() { return 0; }
 
 
diff --git a/Source/Platform/chromium/public/WebFileUtilities.h b/Source/Platform/chromium/public/WebFileUtilities.h
new file mode 100644 (file)
index 0000000..67dc4a8
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2010 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 WebFileUtilities_h
+#define WebFileUtilities_h
+
+#include "WebCommon.h"
+#include "WebString.h"
+#include "WebURL.h"
+
+#ifdef WIN32
+typedef void *HANDLE;
+#endif
+
+namespace WebKit {
+
+class WebFileUtilities {
+public:
+#ifdef WIN32
+    typedef HANDLE FileHandle;
+#else
+    typedef int FileHandle;
+#endif
+    virtual void revealFolderInOS(const WebString& path) { }
+    virtual bool fileExists(const WebString& path) { return false; }
+    virtual bool deleteFile(const WebString& path) { return false; }
+    virtual bool deleteEmptyDirectory(const WebString& path) { return false; }
+    virtual bool getFileSize(const WebString& path, long long& result) { return false; }
+    virtual bool getFileModificationTime(const WebString& path, double& result) { return false; }
+    virtual WebString directoryName(const WebString& path)  { return WebString(); }
+    virtual WebString pathByAppendingComponent(const WebString& path, const WebString& component)  { return WebString(); }
+    virtual bool makeAllDirectories(const WebString& path) { return false; }
+    virtual WebString getAbsolutePath(const WebString& path)  { return WebString(); }
+    virtual bool isDirectory(const WebString& path) { return false; }
+    virtual WebURL filePathToURL(const WebString& path)  { return WebURL(); }
+    virtual FileHandle openFile(const WebString& path, int mode)  { return FileHandle(); }
+    // Should set the FileHandle to a invalid value if the file is closed successfully.
+    virtual void closeFile(FileHandle&) { }
+    virtual long long seekFile(FileHandle, long long offset, int origin) { return 0; }
+    virtual bool truncateFile(FileHandle, long long offset) { return false; }
+    virtual int readFromFile(FileHandle, char* data, int length) { return 0; }
+    virtual int writeToFile(FileHandle, const char* data, int length) { return 0; }
+
+protected:
+    ~WebFileUtilities() { }
+};
+
+} // namespace WebKit
+
+#endif
index 44549cd..75d85fd 100644 (file)
@@ -1,3 +1,37 @@
+2012-05-17  Mark Pilgrim  <pilgrim@chromium.org>
+
+        [Chromium] Move fileUtilities to Platform.h
+        https://bugs.webkit.org/show_bug.cgi?id=86777
+
+        Reviewed by Adam Barth.
+
+        Part of a refactoring series. See tracking bug 82948.
+
+        * WebKit.gyp:
+        * public/WebFileUtilities.h:
+        * public/platform/WebKitPlatformSupport.h:
+        (WebKit):
+        (WebKitPlatformSupport):
+        * src/PlatformSupport.cpp:
+        (WebCore::PlatformSupport::fileExists):
+        (WebCore::PlatformSupport::deleteFile):
+        (WebCore::PlatformSupport::deleteEmptyDirectory):
+        (WebCore::PlatformSupport::getFileSize):
+        (WebCore::PlatformSupport::revealFolderInOS):
+        (WebCore::PlatformSupport::getFileModificationTime):
+        (WebCore::PlatformSupport::directoryName):
+        (WebCore::PlatformSupport::pathByAppendingComponent):
+        (WebCore::PlatformSupport::makeAllDirectories):
+        (WebCore::PlatformSupport::getAbsolutePath):
+        (WebCore::PlatformSupport::isDirectory):
+        (WebCore::PlatformSupport::filePathToURL):
+        (WebCore::PlatformSupport::openFile):
+        (WebCore::PlatformSupport::closeFile):
+        (WebCore::PlatformSupport::seekFile):
+        (WebCore::PlatformSupport::truncateFile):
+        (WebCore::PlatformSupport::readFromFile):
+        (WebCore::PlatformSupport::writeToFile):
+
 2012-05-17  Joshua Bell  <jsbell@chromium.org>
 
         IndexedDB: Remove IDBIndex.storeName
index 62cb816..c656777 100644 (file)
                 'public/WebFileInfo.h',
                 'public/WebFileSystemCallbacks.h',
                 'public/WebFileSystemEntry.h',
-                'public/WebFileUtilities.h',
                 'public/WebFileWriter.h',
                 'public/WebFileWriterClient.h',
                 'public/WebFindOptions.h',
index 8b3b7b2..b2cca5f 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WebFileUtilities_h
-#define WebFileUtilities_h
-
-#include "platform/WebCommon.h"
-#include "platform/WebString.h"
-#include "platform/WebURL.h"
-
-#ifdef WIN32
-typedef void *HANDLE;
-#endif
-
-namespace WebKit {
-
-class WebFileUtilities {
-public:
-#ifdef WIN32
-    typedef HANDLE FileHandle;
-#else
-    typedef int FileHandle;
-#endif
-    virtual void revealFolderInOS(const WebString& path) { }
-    virtual bool fileExists(const WebString& path) { return false; }
-    virtual bool deleteFile(const WebString& path) { return false; }
-    virtual bool deleteEmptyDirectory(const WebString& path) { return false; }
-    virtual bool getFileSize(const WebString& path, long long& result) { return false; }
-    virtual bool getFileModificationTime(const WebString& path, double& result) { return false; }
-    virtual WebString directoryName(const WebString& path)  { return WebString(); }
-    virtual WebString pathByAppendingComponent(const WebString& path, const WebString& component)  { return WebString(); }
-    virtual bool makeAllDirectories(const WebString& path) { return false; }
-    virtual WebString getAbsolutePath(const WebString& path)  { return WebString(); }
-    virtual bool isDirectory(const WebString& path) { return false; }
-    virtual WebURL filePathToURL(const WebString& path)  { return WebURL(); }
-    virtual FileHandle openFile(const WebString& path, int mode)  { return FileHandle(); }
-    // Should set the FileHandle to a invalid value if the file is closed successfully.
-    virtual void closeFile(FileHandle&) { }
-    virtual long long seekFile(FileHandle, long long offset, int origin) { return 0; }
-    virtual bool truncateFile(FileHandle, long long offset) { return false; }
-    virtual int readFromFile(FileHandle, char* data, int length) { return 0; }
-    virtual int writeToFile(FileHandle, const char* data, int length) { return 0; }
-
-protected:
-    ~WebFileUtilities() {}
-};
-
-} // namespace WebKit
-
-#endif
+#include "../../../Platform/chromium/public/WebFileUtilities.h"
index 874cb95..3d3d4ce 100644 (file)
@@ -51,7 +51,6 @@ namespace WebKit {
 class WebApplicationCacheHost; // FIXME: Does this belong in platform?
 class WebApplicationCacheHostClient; // FIXME: Does this belong in platform?
 class WebCookieJar;
-class WebFileUtilities;
 class WebIDBFactory; // FIXME: Does this belong in platform?
 class WebIDBKey; // FIXME: Does this belong in platform?
 class WebMessagePortChannel; // FIXME: Does this belong in platform?
@@ -65,9 +64,6 @@ class WebWorkerRunLoop;
 // FIXME: Eventually all these API will need to move to WebKit::Platform.
 class WebKitPlatformSupport : public Platform {
 public:
-    // Must return non-null.
-    virtual WebFileUtilities* fileUtilities() { return 0; }
-
     // May return null if sandbox support is not necessary
     virtual WebSandboxSupport* sandboxSupport() { return 0; }
 
index e067857..e348011 100644 (file)
@@ -301,33 +301,33 @@ bool PlatformSupport::cookiesEnabled(const Document* document)
 
 bool PlatformSupport::fileExists(const String& path)
 {
-    return webKitPlatformSupport()->fileUtilities()->fileExists(path);
+    return WebKit::Platform::current()->fileUtilities()->fileExists(path);
 }
 
 bool PlatformSupport::deleteFile(const String& path)
 {
-    return webKitPlatformSupport()->fileUtilities()->deleteFile(path);
+    return WebKit::Platform::current()->fileUtilities()->deleteFile(path);
 }
 
 bool PlatformSupport::deleteEmptyDirectory(const String& path)
 {
-    return webKitPlatformSupport()->fileUtilities()->deleteEmptyDirectory(path);
+    return WebKit::Platform::current()->fileUtilities()->deleteEmptyDirectory(path);
 }
 
 bool PlatformSupport::getFileSize(const String& path, long long& result)
 {
-    return webKitPlatformSupport()->fileUtilities()->getFileSize(path, result);
+    return WebKit::Platform::current()->fileUtilities()->getFileSize(path, result);
 }
 
 void PlatformSupport::revealFolderInOS(const String& path)
 {
-    webKitPlatformSupport()->fileUtilities()->revealFolderInOS(path);
+    WebKit::Platform::current()->fileUtilities()->revealFolderInOS(path);
 }
 
 bool PlatformSupport::getFileModificationTime(const String& path, time_t& result)
 {
     double modificationTime;
-    if (!webKitPlatformSupport()->fileUtilities()->getFileModificationTime(path, modificationTime))
+    if (!WebKit::Platform::current()->fileUtilities()->getFileModificationTime(path, modificationTime))
         return false;
     result = static_cast<time_t>(modificationTime);
     return true;
@@ -335,62 +335,62 @@ bool PlatformSupport::getFileModificationTime(const String& path, time_t& result
 
 String PlatformSupport::directoryName(const String& path)
 {
-    return webKitPlatformSupport()->fileUtilities()->directoryName(path);
+    return WebKit::Platform::current()->fileUtilities()->directoryName(path);
 }
 
 String PlatformSupport::pathByAppendingComponent(const String& path, const String& component)
 {
-    return webKitPlatformSupport()->fileUtilities()->pathByAppendingComponent(path, component);
+    return WebKit::Platform::current()->fileUtilities()->pathByAppendingComponent(path, component);
 }
 
 bool PlatformSupport::makeAllDirectories(const String& path)
 {
-    return webKitPlatformSupport()->fileUtilities()->makeAllDirectories(path);
+    return WebKit::Platform::current()->fileUtilities()->makeAllDirectories(path);
 }
 
 String PlatformSupport::getAbsolutePath(const String& path)
 {
-    return webKitPlatformSupport()->fileUtilities()->getAbsolutePath(path);
+    return WebKit::Platform::current()->fileUtilities()->getAbsolutePath(path);
 }
 
 bool PlatformSupport::isDirectory(const String& path)
 {
-    return webKitPlatformSupport()->fileUtilities()->isDirectory(path);
+    return WebKit::Platform::current()->fileUtilities()->isDirectory(path);
 }
 
 KURL PlatformSupport::filePathToURL(const String& path)
 {
-    return webKitPlatformSupport()->fileUtilities()->filePathToURL(path);
+    return WebKit::Platform::current()->fileUtilities()->filePathToURL(path);
 }
 
 PlatformFileHandle PlatformSupport::openFile(const String& path, FileOpenMode mode)
 {
-    return webKitPlatformSupport()->fileUtilities()->openFile(path, mode);
+    return WebKit::Platform::current()->fileUtilities()->openFile(path, mode);
 }
 
 void PlatformSupport::closeFile(PlatformFileHandle& handle)
 {
-    webKitPlatformSupport()->fileUtilities()->closeFile(handle);
+    WebKit::Platform::current()->fileUtilities()->closeFile(handle);
 }
 
 long long PlatformSupport::seekFile(PlatformFileHandle handle, long long offset, FileSeekOrigin origin)
 {
-    return webKitPlatformSupport()->fileUtilities()->seekFile(handle, offset, origin);
+    return WebKit::Platform::current()->fileUtilities()->seekFile(handle, offset, origin);
 }
 
 bool PlatformSupport::truncateFile(PlatformFileHandle handle, long long offset)
 {
-    return webKitPlatformSupport()->fileUtilities()->truncateFile(handle, offset);
+    return WebKit::Platform::current()->fileUtilities()->truncateFile(handle, offset);
 }
 
 int PlatformSupport::readFromFile(PlatformFileHandle handle, char* data, int length)
 {
-    return webKitPlatformSupport()->fileUtilities()->readFromFile(handle, data, length);
+    return WebKit::Platform::current()->fileUtilities()->readFromFile(handle, data, length);
 }
 
 int PlatformSupport::writeToFile(PlatformFileHandle handle, const char* data, int length)
 {
-    return webKitPlatformSupport()->fileUtilities()->writeToFile(handle, data, length);
+    return WebKit::Platform::current()->fileUtilities()->writeToFile(handle, data, length);
 }
 
 #if ENABLE(FILE_SYSTEM)