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

Unified Diff: chrome/common/file_system/webfilesystem_callback_dispatcher.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
Index: chrome/common/file_system/webfilesystem_callback_dispatcher.cc
diff --git a/chrome/common/file_system/webfilesystem_callback_dispatcher.cc b/chrome/common/file_system/webfilesystem_callback_dispatcher.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c68ff188ddf2a686b33f807abc9c7296d09b321f
--- /dev/null
+++ b/chrome/common/file_system/webfilesystem_callback_dispatcher.cc
@@ -0,0 +1,82 @@
+// 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 "chrome/common/file_system/webfilesystem_callback_dispatcher.h"
+
+#include "base/file_util_proxy.h"
+#include "base/utf_string_conversions.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebFileInfo.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebFileSystem.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebFileSystemCallbacks.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
+#include "webkit/glue/webkit_glue.h"
+
+using WebKit::WebFileInfo;
+using WebKit::WebFileSystemCallbacks;
+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;
+ }
+}
+
+}
+
+WebFileSystemCallbackDispatcher::WebFileSystemCallbackDispatcher(
+ WebFileSystemCallbacks* callbacks)
+ : callbacks_(callbacks) {
+ DCHECK(callbacks_);
+}
+
+void WebFileSystemCallbackDispatcher::DidSucceed() {
+ callbacks_->didSucceed();
+}
+
+void WebFileSystemCallbackDispatcher::DidReadMetadata(
+ const base::PlatformFileInfo& file_info) {
+ WebFileInfo web_file_info;
+ web_file_info.modificationTime = file_info.last_modified.ToDoubleT();
+ callbacks_->didReadMetadata(web_file_info);
+}
+
+void WebFileSystemCallbackDispatcher::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);
+}
+
+void WebFileSystemCallbackDispatcher::DidOpenFileSystem(
+ const std::string& name, const FilePath& root_path) {
+ callbacks_->didOpenFileSystem(UTF8ToUTF16(name),
+ webkit_glue::FilePathToWebString(root_path));
+}
+
+void WebFileSystemCallbackDispatcher::DidFail(
+ base::PlatformFileError error_code) {
+ callbacks_->didFail(PlatformFileErrorToWebFileError(error_code));
+}
« no previous file with comments | « chrome/common/file_system/webfilesystem_callback_dispatcher.h ('k') | chrome/common/file_system/webfilesystem_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698