Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Unified Diff: chrome/common/file_system/webfilesystem_impl.cc

Issue 3394003: Add Worker support for FileSystem API. (Closed)
Patch Set: '' Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/file_system/webfilesystem_callback_dispatcher.cc ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/file_system/webfilesystem_impl.cc
diff --git a/chrome/common/file_system/webfilesystem_impl.cc b/chrome/common/file_system/webfilesystem_impl.cc
index 546ed25604a0c8d48d92df9b3689ea43d74f6a8b..b7940c89505413d6f57eadbeabe053ce8c0d900c 100644
--- a/chrome/common/file_system/webfilesystem_impl.cc
+++ b/chrome/common/file_system/webfilesystem_impl.cc
@@ -5,6 +5,7 @@
#include "chrome/common/file_system/webfilesystem_impl.h"
#include "chrome/common/file_system/file_system_dispatcher.h"
+#include "chrome/common/file_system/webfilesystem_callback_dispatcher.h"
#include "chrome/common/child_thread.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFileInfo.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFileSystemCallbacks.h"
@@ -17,76 +18,6 @@ using WebKit::WebFileSystemEntry;
using WebKit::WebString;
using WebKit::WebVector;
-namespace {
-
-WebKit::WebFileError PlatformFileErrorToWebFileError(
- base::PlatformFileError error_code) {
- switch (error_code) {
- case base::PLATFORM_FILE_ERROR_NOT_FOUND:
- return WebKit::WebFileErrorNotFound;
- case base::PLATFORM_FILE_ERROR_INVALID_OPERATION:
- case base::PLATFORM_FILE_ERROR_EXISTS:
- case base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY:
- return WebKit::WebFileErrorInvalidModification;
- case base::PLATFORM_FILE_ERROR_ACCESS_DENIED:
- return WebKit::WebFileErrorNoModificationAllowed;
- case base::PLATFORM_FILE_ERROR_FAILED:
- return WebKit::WebFileErrorInvalidState;
- case base::PLATFORM_FILE_ERROR_ABORT:
- return WebKit::WebFileErrorAbort;
- default:
- return WebKit::WebFileErrorInvalidModification;
- }
-}
-
-class WebFileSystemCallbackDispatcherImpl
- : public fileapi::FileSystemCallbackDispatcher {
- public:
- explicit WebFileSystemCallbackDispatcherImpl(
- WebFileSystemCallbacks* callbacks)
- : callbacks_(callbacks) {
- DCHECK(callbacks_);
- }
-
- virtual ~WebFileSystemCallbackDispatcherImpl() {
- }
-
- // FileSystemCallbackDispatcher implementation
- virtual void DidSucceed() {
- callbacks_->didSucceed();
- }
-
- virtual void DidReadMetadata(const base::PlatformFileInfo& file_info) {
- WebFileInfo web_file_info;
- web_file_info.modificationTime = file_info.last_modified.ToDoubleT();
- callbacks_->didReadMetadata(web_file_info);
- }
-
- virtual void DidReadDirectory(
- const std::vector<base::file_util_proxy::Entry>& entries, bool has_more) {
- WebVector<WebFileSystemEntry> file_system_entries(entries.size());
- for (size_t i = 0; i < entries.size(); i++) {
- file_system_entries[i].name =
- webkit_glue::FilePathStringToWebString(entries[i].name);
- file_system_entries[i].isDirectory = entries[i].is_directory;
- }
- callbacks_->didReadDirectory(file_system_entries, has_more);
- }
-
- virtual void DidOpenFileSystem(const string16&, const FilePath&) {
- NOTREACHED();
- }
-
- virtual void DidFail(base::PlatformFileError error_code) {
- callbacks_->didFail(PlatformFileErrorToWebFileError(error_code));
- }
-
- private:
- WebFileSystemCallbacks* callbacks_;
-};
-
-} // namespace
-
WebFileSystemImpl::WebFileSystemImpl() {
}
@@ -97,7 +28,7 @@ void WebFileSystemImpl::move(const WebString& src_path,
ChildThread::current()->file_system_dispatcher();
dispatcher->Move(webkit_glue::WebStringToFilePath(src_path),
webkit_glue::WebStringToFilePath(dest_path),
- new WebFileSystemCallbackDispatcherImpl(callbacks));
+ new WebFileSystemCallbackDispatcher(callbacks));
}
void WebFileSystemImpl::copy(const WebString& src_path,
@@ -107,7 +38,7 @@ void WebFileSystemImpl::copy(const WebString& src_path,
ChildThread::current()->file_system_dispatcher();
dispatcher->Copy(webkit_glue::WebStringToFilePath(src_path),
webkit_glue::WebStringToFilePath(dest_path),
- new WebFileSystemCallbackDispatcherImpl(callbacks));
+ new WebFileSystemCallbackDispatcher(callbacks));
}
void WebFileSystemImpl::remove(const WebString& path,
@@ -115,7 +46,7 @@ void WebFileSystemImpl::remove(const WebString& path,
FileSystemDispatcher* dispatcher =
ChildThread::current()->file_system_dispatcher();
dispatcher->Remove(webkit_glue::WebStringToFilePath(path),
- new WebFileSystemCallbackDispatcherImpl(callbacks));
+ new WebFileSystemCallbackDispatcher(callbacks));
}
void WebFileSystemImpl::readMetadata(const WebString& path,
@@ -123,7 +54,7 @@ void WebFileSystemImpl::readMetadata(const WebString& path,
FileSystemDispatcher* dispatcher =
ChildThread::current()->file_system_dispatcher();
dispatcher->ReadMetadata(webkit_glue::WebStringToFilePath(path),
- new WebFileSystemCallbackDispatcherImpl(callbacks));
+ new WebFileSystemCallbackDispatcher(callbacks));
}
void WebFileSystemImpl::createFile(const WebString& path,
@@ -132,7 +63,7 @@ void WebFileSystemImpl::createFile(const WebString& path,
FileSystemDispatcher* dispatcher =
ChildThread::current()->file_system_dispatcher();
dispatcher->Create(webkit_glue::WebStringToFilePath(path), exclusive, false,
- false, new WebFileSystemCallbackDispatcherImpl(callbacks));
+ false, new WebFileSystemCallbackDispatcher(callbacks));
}
void WebFileSystemImpl::createDirectory(const WebString& path,
@@ -141,7 +72,7 @@ void WebFileSystemImpl::createDirectory(const WebString& path,
FileSystemDispatcher* dispatcher =
ChildThread::current()->file_system_dispatcher();
dispatcher->Create(webkit_glue::WebStringToFilePath(path), exclusive, true,
- false, new WebFileSystemCallbackDispatcherImpl(callbacks));
+ false, new WebFileSystemCallbackDispatcher(callbacks));
}
void WebFileSystemImpl::fileExists(const WebString& path,
@@ -149,7 +80,7 @@ void WebFileSystemImpl::fileExists(const WebString& path,
FileSystemDispatcher* dispatcher =
ChildThread::current()->file_system_dispatcher();
dispatcher->Exists(webkit_glue::WebStringToFilePath(path), false,
- new WebFileSystemCallbackDispatcherImpl(callbacks));
+ new WebFileSystemCallbackDispatcher(callbacks));
}
void WebFileSystemImpl::directoryExists(const WebString& path,
@@ -157,7 +88,7 @@ void WebFileSystemImpl::directoryExists(const WebString& path,
FileSystemDispatcher* dispatcher =
ChildThread::current()->file_system_dispatcher();
dispatcher->Exists(webkit_glue::WebStringToFilePath(path), true,
- new WebFileSystemCallbackDispatcherImpl(callbacks));
+ new WebFileSystemCallbackDispatcher(callbacks));
}
void WebFileSystemImpl::readDirectory(const WebString& path,
@@ -165,5 +96,5 @@ void WebFileSystemImpl::readDirectory(const WebString& path,
FileSystemDispatcher* dispatcher =
ChildThread::current()->file_system_dispatcher();
dispatcher->ReadDirectory(webkit_glue::WebStringToFilePath(path),
- new WebFileSystemCallbackDispatcherImpl(callbacks));
+ new WebFileSystemCallbackDispatcher(callbacks));
}
« no previous file with comments | « chrome/common/file_system/webfilesystem_callback_dispatcher.cc ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698