Commit e6f2c9b1 authored by jianli@chromium.org's avatar jianli@chromium.org

[chromium] Add WebFileSystem interface and hook up with all FileSystem methods.

https://bugs.webkit.org/show_bug.cgi?id=38228

Reviewed by Darin Fisher.

WebCore:

* platform/chromium/ChromiumBridge.h:
* platform/chromium/FileSystemChromium.cpp:
(WebCore::openFile):
(WebCore::closeFile):
(WebCore::seekFile):
(WebCore::truncateFile):
(WebCore::readFromFile):
(WebCore::writeToFile):

WebKit/chromium:

* WebKit.gyp:
* public/WebFileSystem.h: Added.
* public/WebKitClient.h:
(WebKit::WebKitClient::fileSystem):
* src/ChromiumBridge.cpp:
(WebCore::ChromiumBridge::fileExists):
(WebCore::ChromiumBridge::deleteFile):
(WebCore::ChromiumBridge::deleteEmptyDirectory):
(WebCore::ChromiumBridge::getFileSize):
(WebCore::ChromiumBridge::getFileModificationTime):
(WebCore::ChromiumBridge::directoryName):
(WebCore::ChromiumBridge::pathByAppendingComponent):
(WebCore::ChromiumBridge::makeAllDirectories):
(WebCore::ChromiumBridge::getAbsolutePath):
(WebCore::ChromiumBridge::isDirectory):
(WebCore::ChromiumBridge::filePathToURL):
(WebCore::ChromiumBridge::openFile):
(WebCore::ChromiumBridge::closeFile):
(WebCore::ChromiumBridge::seekFile):
(WebCore::ChromiumBridge::truncateFile):
(WebCore::ChromiumBridge::readFromFile):
(WebCore::ChromiumBridge::writeToFile):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@58599 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2c710294
2010-04-30 Jian Li <jianli@chromium.org>
Reviewed by Darin Fisher.
[chromium] Add WebFileSystem interface and hook up with all FileSystem methods.
https://bugs.webkit.org/show_bug.cgi?id=38228
* platform/chromium/ChromiumBridge.h:
* platform/chromium/FileSystemChromium.cpp:
(WebCore::openFile):
(WebCore::closeFile):
(WebCore::seekFile):
(WebCore::truncateFile):
(WebCore::readFromFile):
(WebCore::writeToFile):
2010-04-30 Anders Carlsson <andersca@apple.com>
Reviewed by Dan Bernstein.
......@@ -109,6 +109,12 @@ namespace WebCore {
static String getAbsolutePath(const String&);
static bool isDirectory(const String&);
static KURL filePathToURL(const String&);
static PlatformFileHandle openFile(const String& path, FileOpenMode);
static void closeFile(PlatformFileHandle&);
static long long seekFile(PlatformFileHandle, long long offset, FileSeekOrigin);
static bool truncateFile(PlatformFileHandle, long long offset);
static int readFromFile(PlatformFileHandle, char* data, int length);
static int writeToFile(PlatformFileHandle, const char* data, int length);
// Font ---------------------------------------------------------------
#if OS(WINDOWS)
......
......@@ -77,4 +77,34 @@ bool fileExists(const String& path)
return ChromiumBridge::fileExists(path);
}
PlatformFileHandle openFile(const String& path, FileOpenMode mode)
{
return ChromiumBridge::openFile(path, mode);
}
void closeFile(PlatformFileHandle& handle)
{
return ChromiumBridge::closeFile(handle);
}
long long seekFile(PlatformFileHandle handle, long long offset, FileSeekOrigin origin)
{
return ChromiumBridge::seekFile(handle, offset, origin);
}
bool truncateFile(PlatformFileHandle handle, long long offset)
{
return ChromiumBridge::truncateFile(handle, offset);
}
int readFromFile(PlatformFileHandle handle, char* data, int length)
{
return ChromiumBridge::readFromFile(handle, data, length);
}
int writeToFile(PlatformFileHandle handle, const char* data, int length)
{
return ChromiumBridge::writeToFile(handle, data, length);
}
} // namespace WebCore
2010-04-30 Jian Li <jianli@chromium.org>
Reviewed by Darin Fisher.
[chromium] Add WebFileSystem interface and hook up with all FileSystem methods.
https://bugs.webkit.org/show_bug.cgi?id=38228
* WebKit.gyp:
* public/WebFileSystem.h: Added.
* public/WebKitClient.h:
(WebKit::WebKitClient::fileSystem):
* src/ChromiumBridge.cpp:
(WebCore::ChromiumBridge::fileExists):
(WebCore::ChromiumBridge::deleteFile):
(WebCore::ChromiumBridge::deleteEmptyDirectory):
(WebCore::ChromiumBridge::getFileSize):
(WebCore::ChromiumBridge::getFileModificationTime):
(WebCore::ChromiumBridge::directoryName):
(WebCore::ChromiumBridge::pathByAppendingComponent):
(WebCore::ChromiumBridge::makeAllDirectories):
(WebCore::ChromiumBridge::getAbsolutePath):
(WebCore::ChromiumBridge::isDirectory):
(WebCore::ChromiumBridge::filePathToURL):
(WebCore::ChromiumBridge::openFile):
(WebCore::ChromiumBridge::closeFile):
(WebCore::ChromiumBridge::seekFile):
(WebCore::ChromiumBridge::truncateFile):
(WebCore::ChromiumBridge::readFromFile):
(WebCore::ChromiumBridge::writeToFile):
2010-04-29 Jeremy Orlow <jorlow@chromium.org>
Reviewed by Darin Fisher.
......
......@@ -121,6 +121,7 @@
'public/WebFileChooserCompletion.h',
'public/WebFileChooserParams.h',
'public/WebFileInfo.h',
'public/WebFileSystem.h',
'public/WebFindOptions.h',
'public/WebFrame.h',
'public/WebFrameClient.h',
......
/*
* 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 WebFileSystem_h
#define WebFileSystem_h
#include "WebCommon.h"
#include "WebString.h"
#include "WebURL.h"
namespace WebKit {
class WebFileSystem {
public:
#ifdef WIN32
typedef HANDLE FileHandle;
#else
typedef int FileHandle;
#endif
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:
~WebFileSystem() {}
};
} // namespace WebKit
#endif
......@@ -49,6 +49,7 @@ class WebApplicationCacheHost;
class WebApplicationCacheHostClient;
class WebClipboard;
class WebCookieJar;
class WebFileSystem;
class WebGLES2Context;
class WebGraphicsContext3D;
class WebIndexedDatabase;
......@@ -70,6 +71,9 @@ public:
// Must return non-null.
virtual WebMimeRegistry* mimeRegistry() { return 0; }
// Must return non-null.
virtual WebFileSystem* fileSystem() { return 0; }
// May return null if sandbox support is not necessary
virtual WebSandboxSupport* sandboxSupport() { return 0; }
......
......@@ -40,6 +40,7 @@
#include "WebCookieJar.h"
#include "WebCursorInfo.h"
#include "WebData.h"
#include "WebFileSystem.h"
#include "WebFrameClient.h"
#include "WebFrameImpl.h"
#include "WebImage.h"
......@@ -270,63 +271,118 @@ void ChromiumBridge::prefetchDNS(const String& hostname)
bool ChromiumBridge::fileExists(const String& path)
{
if (webKitClient()->fileSystem())
return webKitClient()->fileSystem()->fileExists(path);
return webKitClient()->fileExists(path);
}
bool ChromiumBridge::deleteFile(const String& path)
{
if (webKitClient()->fileSystem())
return webKitClient()->fileSystem()->deleteFile(path);
return webKitClient()->deleteFile(path);
}
bool ChromiumBridge::deleteEmptyDirectory(const String& path)
{
if (webKitClient()->fileSystem())
return webKitClient()->fileSystem()->deleteEmptyDirectory(path);
return webKitClient()->deleteEmptyDirectory(path);
}
bool ChromiumBridge::getFileSize(const String& path, long long& result)
{
if (webKitClient()->fileSystem())
return webKitClient()->fileSystem()->getFileSize(path, result);
return webKitClient()->getFileSize(path, result);
}
bool ChromiumBridge::getFileModificationTime(const String& path, time_t& result)
{
double modificationTime;
if (!webKitClient()->getFileModificationTime(path, modificationTime))
return false;
if (webKitClient()->fileSystem()) {
if (!webKitClient()->fileSystem()->getFileModificationTime(path, modificationTime))
return false;
} else {
if (!webKitClient()->getFileModificationTime(path, modificationTime))
return false;
}
result = static_cast<time_t>(modificationTime);
return true;
}
String ChromiumBridge::directoryName(const String& path)
{
if (webKitClient()->fileSystem())
return webKitClient()->fileSystem()->directoryName(path);
return webKitClient()->directoryName(path);
}
String ChromiumBridge::pathByAppendingComponent(const String& path, const String& component)
{
if (webKitClient()->fileSystem())
return webKitClient()->fileSystem()->pathByAppendingComponent(path, component);
return webKitClient()->pathByAppendingComponent(path, component);
}
bool ChromiumBridge::makeAllDirectories(const String& path)
{
if (webKitClient()->fileSystem())
return webKitClient()->fileSystem()->makeAllDirectories(path);
return webKitClient()->makeAllDirectories(path);
}
String ChromiumBridge::getAbsolutePath(const String& path)
{
if (webKitClient()->fileSystem())
return webKitClient()->fileSystem()->getAbsolutePath(path);
return webKitClient()->getAbsolutePath(path);
}
bool ChromiumBridge::isDirectory(const String& path)
{
if (webKitClient()->fileSystem())
return webKitClient()->fileSystem()->isDirectory(path);
return webKitClient()->isDirectory(path);
}
KURL ChromiumBridge::filePathToURL(const String& path)
{
if (webKitClient()->fileSystem())
return webKitClient()->fileSystem()->filePathToURL(path);
return webKitClient()->filePathToURL(path);
}
PlatformFileHandle ChromiumBridge::openFile(const String& path, FileOpenMode mode)
{
return webKitClient()->fileSystem()->openFile(path, mode);
}
void ChromiumBridge::closeFile(PlatformFileHandle& handle)
{
webKitClient()->fileSystem()->closeFile(handle);
}
long long ChromiumBridge::seekFile(PlatformFileHandle handle, long long offset, FileSeekOrigin origin)
{
return webKitClient()->fileSystem()->seekFile(handle, offset, origin);
}
bool ChromiumBridge::truncateFile(PlatformFileHandle handle, long long offset)
{
return webKitClient()->fileSystem()->truncateFile(handle, offset);
}
int ChromiumBridge::readFromFile(PlatformFileHandle handle, char* data, int length)
{
return webKitClient()->fileSystem()->readFromFile(handle, data, length);
}
int ChromiumBridge::writeToFile(PlatformFileHandle handle, const char* data, int length)
{
return webKitClient()->fileSystem()->writeToFile(handle, data, length);
}
// Font -----------------------------------------------------------------------
#if OS(WINDOWS)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment