From 9bf103edf104b4e4174a3ba22da9af6816858033 Mon Sep 17 00:00:00 2001 From: "kinuko@chromium.org" Date: Wed, 18 Aug 2010 18:34:31 +0000 Subject: Rename WebFileSystem to WebFileUtilities for corresponding WebKit API changes. This change depends on an upstream change (not yet rolled): http://trac.webkit.org/changeset/65482 BUG=52355 TESTS=existing tests (like ones under fast/files) should pass Review URL: http://codereview.chromium.org/3153015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56564 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/glue/webfilesystem_impl.cc | 154 --------------------- webkit/glue/webfilesystem_impl.h | 54 -------- webkit/glue/webfileutilities_impl.cc | 155 ++++++++++++++++++++++ webkit/glue/webfileutilities_impl.h | 54 ++++++++ webkit/glue/webkit_glue.gypi | 4 +- webkit/support/test_webkit_client.cc | 6 +- webkit/support/test_webkit_client.h | 6 +- webkit/tools/test_shell/test_shell_webkit_init.cc | 2 +- webkit/tools/test_shell/test_shell_webkit_init.h | 8 +- 9 files changed, 222 insertions(+), 221 deletions(-) delete mode 100644 webkit/glue/webfilesystem_impl.cc delete mode 100644 webkit/glue/webfilesystem_impl.h create mode 100644 webkit/glue/webfileutilities_impl.cc create mode 100644 webkit/glue/webfileutilities_impl.h (limited to 'webkit') diff --git a/webkit/glue/webfilesystem_impl.cc b/webkit/glue/webfilesystem_impl.cc deleted file mode 100644 index 585287b..0000000 --- a/webkit/glue/webfilesystem_impl.cc +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this -// source code is governed by a BSD-style license that can be found in the -// LICENSE file. - -#include "webkit/glue/webfilesystem_impl.h" - -#include "base/file_path.h" -#include "base/file_util.h" -#include "base/logging.h" -#include "net/base/file_stream.h" -#include "net/base/net_util.h" -#include "third_party/WebKit/WebKit/chromium/public/WebString.h" -#include "third_party/WebKit/WebKit/chromium/public/WebURL.h" -#include "webkit/glue/webkit_glue.h" - -using WebKit::WebString; - -namespace webkit_glue { - -WebFileSystemImpl::WebFileSystemImpl() - : sandbox_enabled_(true) { -} - -bool WebFileSystemImpl::fileExists(const WebString& path) { - FilePath::StringType file_path = WebStringToFilePathString(path); - return file_util::PathExists(FilePath(file_path)); -} - -bool WebFileSystemImpl::deleteFile(const WebString& path) { - NOTREACHED(); - return false; -} - -bool WebFileSystemImpl::deleteEmptyDirectory(const WebString& path) { - NOTREACHED(); - return false; -} - -bool WebFileSystemImpl::getFileSize(const WebString& path, long long& result) { - if (sandbox_enabled_) { - NOTREACHED(); - return false; - } - return file_util::GetFileSize(WebStringToFilePath(path), - reinterpret_cast(&result)); -} - -bool WebFileSystemImpl::getFileModificationTime(const WebString& path, - double& result) { - if (sandbox_enabled_) { - NOTREACHED(); - return false; - } - file_util::FileInfo info; - if (!file_util::GetFileInfo(WebStringToFilePath(path), &info)) - return false; - result = info.last_modified.ToDoubleT(); - return true; -} - -WebString WebFileSystemImpl::directoryName(const WebString& path) { - FilePath file_path(WebStringToFilePathString(path)); - return FilePathToWebString(file_path.DirName()); -} - -WebString WebFileSystemImpl::pathByAppendingComponent( - const WebString& webkit_path, - const WebString& webkit_component) { - FilePath path(WebStringToFilePathString(webkit_path)); - FilePath component(WebStringToFilePathString(webkit_component)); - FilePath combined_path = path.Append(component); - return FilePathStringToWebString(combined_path.value()); -} - -bool WebFileSystemImpl::makeAllDirectories(const WebString& path) { - DCHECK(!sandbox_enabled_); - FilePath::StringType file_path = WebStringToFilePathString(path); - return file_util::CreateDirectory(FilePath(file_path)); -} - -WebString WebFileSystemImpl::getAbsolutePath(const WebString& path) { - FilePath file_path(WebStringToFilePathString(path)); - file_util::AbsolutePath(&file_path); - return FilePathStringToWebString(file_path.value()); -} - -bool WebFileSystemImpl::isDirectory(const WebString& path) { - FilePath file_path(WebStringToFilePathString(path)); - return file_util::DirectoryExists(file_path); -} - -WebKit::WebURL WebFileSystemImpl::filePathToURL(const WebString& path) { - return net::FilePathToFileURL(WebStringToFilePath(path)); -} - -base::PlatformFile WebFileSystemImpl::openFile(const WebString& path, - int mode) { - if (sandbox_enabled_) { - NOTREACHED(); - return base::kInvalidPlatformFileValue; - } - return base::CreatePlatformFile( - WebStringToFilePath(path), - (mode == 0) ? (base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ) - : (base::PLATFORM_FILE_CREATE_ALWAYS | - base::PLATFORM_FILE_WRITE), - NULL); -} - -void WebFileSystemImpl::closeFile(base::PlatformFile& handle) { - if (handle == base::kInvalidPlatformFileValue) - return; - if (base::ClosePlatformFile(handle)) - handle = base::kInvalidPlatformFileValue; -} - -long long WebFileSystemImpl::seekFile(base::PlatformFile handle, - long long offset, - int origin) { - if (handle == base::kInvalidPlatformFileValue) - return -1; - net::FileStream file_stream(handle, 0); - return file_stream.Seek(static_cast(origin), offset); -} - -bool WebFileSystemImpl::truncateFile(base::PlatformFile handle, - long long offset) { - if (handle == base::kInvalidPlatformFileValue || offset < 0) - return false; - net::FileStream file_stream(handle, base::PLATFORM_FILE_WRITE); - return file_stream.Truncate(offset) >= 0; -} - -int WebFileSystemImpl::readFromFile(base::PlatformFile handle, - char* data, - int length) { - if (handle == base::kInvalidPlatformFileValue || !data || length <= 0) - return -1; - std::string buffer; - buffer.resize(length); - net::FileStream file_stream(handle, base::PLATFORM_FILE_READ); - return file_stream.Read(data, length, NULL); -} - -int WebFileSystemImpl::writeToFile(base::PlatformFile handle, - const char* data, - int length) { - if (handle == base::kInvalidPlatformFileValue || !data || length <= 0) - return -1; - net::FileStream file_stream(handle, base::PLATFORM_FILE_WRITE); - return file_stream.Write(data, length, NULL); -} - -} // namespace webkit_glue diff --git a/webkit/glue/webfilesystem_impl.h b/webkit/glue/webfilesystem_impl.h deleted file mode 100644 index 875a13b..0000000 --- a/webkit/glue/webfilesystem_impl.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this -// source code is governed by a BSD-style license that can be found in the -// LICENSE file. - -#ifndef WEBFILESYSTEM_IMPL_H_ -#define WEBFILESYSTEM_IMPL_H_ - -#include "base/platform_file.h" -#include "third_party/WebKit/WebKit/chromium/public/WebFileSystem.h" - -namespace webkit_glue { - -class WebFileSystemImpl : public WebKit::WebFileSystem { - public: - WebFileSystemImpl(); - virtual ~WebFileSystemImpl() { } - - // WebFileSystem methods: - virtual bool fileExists(const WebKit::WebString& path); - virtual bool deleteFile(const WebKit::WebString& path); - virtual bool deleteEmptyDirectory(const WebKit::WebString& path); - virtual bool getFileSize(const WebKit::WebString& path, long long& result); - virtual bool getFileModificationTime( - const WebKit::WebString& path, - double& result); - virtual WebKit::WebString directoryName(const WebKit::WebString& path); - virtual WebKit::WebString pathByAppendingComponent( - const WebKit::WebString& path, const WebKit::WebString& component); - virtual bool makeAllDirectories(const WebKit::WebString& path); - virtual WebKit::WebString getAbsolutePath(const WebKit::WebString& path); - virtual bool isDirectory(const WebKit::WebString& path); - virtual WebKit::WebURL filePathToURL(const WebKit::WebString& path); - virtual base::PlatformFile openFile(const WebKit::WebString& path, int mode); - virtual void closeFile(base::PlatformFile& handle); - virtual long long seekFile(base::PlatformFile handle, - long long offset, - int origin); - virtual bool truncateFile(base::PlatformFile handle, long long offset); - virtual int readFromFile(base::PlatformFile handle, char* data, int length); - virtual int writeToFile(base::PlatformFile handle, - const char* data, - int length); - - void set_sandbox_enabled(bool sandbox_enabled) { - sandbox_enabled_ = sandbox_enabled; - } - - protected: - bool sandbox_enabled_; -}; - -} // namespace webkit_glue - -#endif // WEBFILESYSTEM_IMPL_H_ diff --git a/webkit/glue/webfileutilities_impl.cc b/webkit/glue/webfileutilities_impl.cc new file mode 100644 index 0000000..a7ba5b5 --- /dev/null +++ b/webkit/glue/webfileutilities_impl.cc @@ -0,0 +1,155 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this +// source code is governed by a BSD-style license that can be found in the +// LICENSE file. + +#include "webkit/glue/webfileutilities_impl.h" + +#include "base/file_path.h" +#include "base/file_util.h" +#include "base/logging.h" +#include "net/base/file_stream.h" +#include "net/base/net_util.h" +#include "third_party/WebKit/WebKit/chromium/public/WebString.h" +#include "third_party/WebKit/WebKit/chromium/public/WebURL.h" +#include "webkit/glue/webkit_glue.h" + +using WebKit::WebString; + +namespace webkit_glue { + +WebFileUtilitiesImpl::WebFileUtilitiesImpl() + : sandbox_enabled_(true) { +} + +bool WebFileUtilitiesImpl::fileExists(const WebString& path) { + FilePath::StringType file_path = WebStringToFilePathString(path); + return file_util::PathExists(FilePath(file_path)); +} + +bool WebFileUtilitiesImpl::deleteFile(const WebString& path) { + NOTREACHED(); + return false; +} + +bool WebFileUtilitiesImpl::deleteEmptyDirectory(const WebString& path) { + NOTREACHED(); + return false; +} + +bool WebFileUtilitiesImpl::getFileSize(const WebString& path, + long long& result) { + if (sandbox_enabled_) { + NOTREACHED(); + return false; + } + return file_util::GetFileSize(WebStringToFilePath(path), + reinterpret_cast(&result)); +} + +bool WebFileUtilitiesImpl::getFileModificationTime(const WebString& path, + double& result) { + if (sandbox_enabled_) { + NOTREACHED(); + return false; + } + file_util::FileInfo info; + if (!file_util::GetFileInfo(WebStringToFilePath(path), &info)) + return false; + result = info.last_modified.ToDoubleT(); + return true; +} + +WebString WebFileUtilitiesImpl::directoryName(const WebString& path) { + FilePath file_path(WebStringToFilePathString(path)); + return FilePathToWebString(file_path.DirName()); +} + +WebString WebFileUtilitiesImpl::pathByAppendingComponent( + const WebString& webkit_path, + const WebString& webkit_component) { + FilePath path(WebStringToFilePathString(webkit_path)); + FilePath component(WebStringToFilePathString(webkit_component)); + FilePath combined_path = path.Append(component); + return FilePathStringToWebString(combined_path.value()); +} + +bool WebFileUtilitiesImpl::makeAllDirectories(const WebString& path) { + DCHECK(!sandbox_enabled_); + FilePath::StringType file_path = WebStringToFilePathString(path); + return file_util::CreateDirectory(FilePath(file_path)); +} + +WebString WebFileUtilitiesImpl::getAbsolutePath(const WebString& path) { + FilePath file_path(WebStringToFilePathString(path)); + file_util::AbsolutePath(&file_path); + return FilePathStringToWebString(file_path.value()); +} + +bool WebFileUtilitiesImpl::isDirectory(const WebString& path) { + FilePath file_path(WebStringToFilePathString(path)); + return file_util::DirectoryExists(file_path); +} + +WebKit::WebURL WebFileUtilitiesImpl::filePathToURL(const WebString& path) { + return net::FilePathToFileURL(WebStringToFilePath(path)); +} + +base::PlatformFile WebFileUtilitiesImpl::openFile(const WebString& path, + int mode) { + if (sandbox_enabled_) { + NOTREACHED(); + return base::kInvalidPlatformFileValue; + } + return base::CreatePlatformFile( + WebStringToFilePath(path), + (mode == 0) ? (base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ) + : (base::PLATFORM_FILE_CREATE_ALWAYS | + base::PLATFORM_FILE_WRITE), + NULL); +} + +void WebFileUtilitiesImpl::closeFile(base::PlatformFile& handle) { + if (handle == base::kInvalidPlatformFileValue) + return; + if (base::ClosePlatformFile(handle)) + handle = base::kInvalidPlatformFileValue; +} + +long long WebFileUtilitiesImpl::seekFile(base::PlatformFile handle, + long long offset, + int origin) { + if (handle == base::kInvalidPlatformFileValue) + return -1; + net::FileStream file_stream(handle, 0); + return file_stream.Seek(static_cast(origin), offset); +} + +bool WebFileUtilitiesImpl::truncateFile(base::PlatformFile handle, + long long offset) { + if (handle == base::kInvalidPlatformFileValue || offset < 0) + return false; + net::FileStream file_stream(handle, base::PLATFORM_FILE_WRITE); + return file_stream.Truncate(offset) >= 0; +} + +int WebFileUtilitiesImpl::readFromFile(base::PlatformFile handle, + char* data, + int length) { + if (handle == base::kInvalidPlatformFileValue || !data || length <= 0) + return -1; + std::string buffer; + buffer.resize(length); + net::FileStream file_stream(handle, base::PLATFORM_FILE_READ); + return file_stream.Read(data, length, NULL); +} + +int WebFileUtilitiesImpl::writeToFile(base::PlatformFile handle, + const char* data, + int length) { + if (handle == base::kInvalidPlatformFileValue || !data || length <= 0) + return -1; + net::FileStream file_stream(handle, base::PLATFORM_FILE_WRITE); + return file_stream.Write(data, length, NULL); +} + +} // namespace webkit_glue diff --git a/webkit/glue/webfileutilities_impl.h b/webkit/glue/webfileutilities_impl.h new file mode 100644 index 0000000..f35293b --- /dev/null +++ b/webkit/glue/webfileutilities_impl.h @@ -0,0 +1,54 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this +// source code is governed by a BSD-style license that can be found in the +// LICENSE file. + +#ifndef WEBFILEUTILITIES_IMPL_H_ +#define WEBFILEUTILITIES_IMPL_H_ + +#include "base/platform_file.h" +#include "third_party/WebKit/WebKit/chromium/public/WebFileUtilities.h" + +namespace webkit_glue { + +class WebFileUtilitiesImpl : public WebKit::WebFileUtilities { + public: + WebFileUtilitiesImpl(); + virtual ~WebFileUtilitiesImpl() { } + + // WebFileUtilities methods: + virtual bool fileExists(const WebKit::WebString& path); + virtual bool deleteFile(const WebKit::WebString& path); + virtual bool deleteEmptyDirectory(const WebKit::WebString& path); + virtual bool getFileSize(const WebKit::WebString& path, long long& result); + virtual bool getFileModificationTime( + const WebKit::WebString& path, + double& result); + virtual WebKit::WebString directoryName(const WebKit::WebString& path); + virtual WebKit::WebString pathByAppendingComponent( + const WebKit::WebString& path, const WebKit::WebString& component); + virtual bool makeAllDirectories(const WebKit::WebString& path); + virtual WebKit::WebString getAbsolutePath(const WebKit::WebString& path); + virtual bool isDirectory(const WebKit::WebString& path); + virtual WebKit::WebURL filePathToURL(const WebKit::WebString& path); + virtual base::PlatformFile openFile(const WebKit::WebString& path, int mode); + virtual void closeFile(base::PlatformFile& handle); + virtual long long seekFile(base::PlatformFile handle, + long long offset, + int origin); + virtual bool truncateFile(base::PlatformFile handle, long long offset); + virtual int readFromFile(base::PlatformFile handle, char* data, int length); + virtual int writeToFile(base::PlatformFile handle, + const char* data, + int length); + + void set_sandbox_enabled(bool sandbox_enabled) { + sandbox_enabled_ = sandbox_enabled; + } + + protected: + bool sandbox_enabled_; +}; + +} // namespace webkit_glue + +#endif // WEBFILEUTILITIES_IMPL_H_ diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi index 02efafd..b17f5e7 100644 --- a/webkit/glue/webkit_glue.gypi +++ b/webkit/glue/webkit_glue.gypi @@ -316,8 +316,8 @@ 'webdropdata.cc', 'webdropdata_win.cc', 'webdropdata.h', - 'webfilesystem_impl.cc', - 'webfilesystem_impl.h', + 'webfileutilities_impl.cc', + 'webfileutilities_impl.h', 'webkit_glue.cc', 'webkit_glue.h', 'webkitclient_impl.cc', diff --git a/webkit/support/test_webkit_client.cc b/webkit/support/test_webkit_client.cc index a031f3f..64eef28 100644 --- a/webkit/support/test_webkit_client.cc +++ b/webkit/support/test_webkit_client.cc @@ -107,7 +107,7 @@ TestWebKitClient::TestWebKitClient(bool unit_test_mode) WebKit::WebDatabase::setObserver(&database_system_); - file_system_.set_sandbox_enabled(false); + file_utilities_.set_sandbox_enabled(false); #if defined(OS_WIN) // Ensure we pick up the default theme engine. @@ -141,8 +141,8 @@ WebKit::WebClipboard* TestWebKitClient::clipboard() { return &mock_clipboard_; } -WebKit::WebFileSystem* TestWebKitClient::fileSystem() { - return &file_system_; +WebKit::WebFileUtilities* TestWebKitClient::fileUtilities() { + return &file_utilities_; } WebKit::WebSandboxSupport* TestWebKitClient::sandboxSupport() { diff --git a/webkit/support/test_webkit_client.h b/webkit/support/test_webkit_client.h index 6a51ec4..24d2382 100644 --- a/webkit/support/test_webkit_client.h +++ b/webkit/support/test_webkit_client.h @@ -5,7 +5,7 @@ #ifndef WEBKIT_SUPPORT_TEST_WEBKIT_CLIENT_H_ #define WEBKIT_SUPPORT_TEST_WEBKIT_CLIENT_H_ -#include "webkit/glue/webfilesystem_impl.h" +#include "webkit/glue/webfileutilities_impl.h" #include "webkit/glue/webkitclient_impl.h" #include "webkit/support/weburl_loader_mock_factory.h" #include "webkit/tools/test_shell/mock_webclipboard_impl.h" @@ -22,7 +22,7 @@ class TestWebKitClient : public webkit_glue::WebKitClientImpl { virtual WebKit::WebMimeRegistry* mimeRegistry(); WebKit::WebClipboard* clipboard(); - virtual WebKit::WebFileSystem* fileSystem(); + virtual WebKit::WebFileUtilities* fileUtilities(); virtual WebKit::WebSandboxSupport* sandboxSupport(); virtual WebKit::WebCookieJar* cookieJar(); virtual bool sandboxEnabled(); @@ -65,7 +65,7 @@ class TestWebKitClient : public webkit_glue::WebKitClientImpl { private: TestShellWebMimeRegistryImpl mime_registry_; MockWebClipboardImpl mock_clipboard_; - webkit_glue::WebFileSystemImpl file_system_; + webkit_glue::WebFileUtilitiesImpl file_utilities_; ScopedTempDir appcache_dir_; SimpleAppCacheSystem appcache_system_; SimpleDatabaseSystem database_system_; diff --git a/webkit/tools/test_shell/test_shell_webkit_init.cc b/webkit/tools/test_shell/test_shell_webkit_init.cc index 538e54a..c0ac404 100644 --- a/webkit/tools/test_shell/test_shell_webkit_init.cc +++ b/webkit/tools/test_shell/test_shell_webkit_init.cc @@ -69,7 +69,7 @@ TestShellWebKitInit::TestShellWebKitInit(bool layout_test_mode) { WebKit::WebDatabase::setObserver(&database_system_); - file_system_.set_sandbox_enabled(false); + file_utilities_.set_sandbox_enabled(false); #if defined(OS_WIN) // Ensure we pick up the default theme engine. diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h index 62fdc92..4fdd1ce 100644 --- a/webkit/tools/test_shell/test_shell_webkit_init.h +++ b/webkit/tools/test_shell/test_shell_webkit_init.h @@ -10,7 +10,7 @@ #include "third_party/WebKit/WebKit/chromium/public/WebIDBFactory.h" #include "third_party/WebKit/WebKit/chromium/public/WebStorageNamespace.h" #include "webkit/glue/webclipboard_impl.h" -#include "webkit/glue/webfilesystem_impl.h" +#include "webkit/glue/webfileutilities_impl.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webkitclient_impl.h" #include "webkit/tools/test_shell/mock_webclipboard_impl.h" @@ -35,8 +35,8 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl { WebKit::WebClipboard* clipboard(); - virtual WebKit::WebFileSystem* fileSystem() { - return &file_system_; + virtual WebKit::WebFileUtilities* fileUtilities() { + return &file_utilities_; } virtual WebKit::WebSandboxSupport* sandboxSupport() { @@ -136,7 +136,7 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl { TestShellWebMimeRegistryImpl mime_registry_; MockWebClipboardImpl mock_clipboard_; webkit_glue::WebClipboardImpl real_clipboard_; - webkit_glue::WebFileSystemImpl file_system_; + webkit_glue::WebFileUtilitiesImpl file_utilities_; ScopedTempDir appcache_dir_; SimpleAppCacheSystem appcache_system_; SimpleDatabaseSystem database_system_; -- cgit v1.1