summaryrefslogtreecommitdiffstats
path: root/chrome/browser/file_system
diff options
context:
space:
mode:
authorericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-24 01:06:00 +0000
committerericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-24 01:06:00 +0000
commitac716267efc98d9fcdf9c3c22b10e6a9d8a9dbc8 (patch)
tree83a2b5f323ab94ae9ce25eea6f3b50c87f3b1353 /chrome/browser/file_system
parent09618270d0997bd325786d19182202ccb80fa945 (diff)
downloadchromium_src-ac716267efc98d9fcdf9c3c22b10e6a9d8a9dbc8.zip
chromium_src-ac716267efc98d9fcdf9c3c22b10e6a9d8a9dbc8.tar.gz
chromium_src-ac716267efc98d9fcdf9c3c22b10e6a9d8a9dbc8.tar.bz2
This is the IPC and bits of the browser backend for FileWriter. The rest of
it's too tied together to include a small amount; this is the most-significant chunk that I could put up without making too big a changelist. The backend isn't complete, but you can see where it's going from here. BUG=none TEST=none Review URL: http://codereview.chromium.org/3440021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60396 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/file_system')
-rw-r--r--chrome/browser/file_system/browser_file_system_callback_dispatcher.cc9
-rw-r--r--chrome/browser/file_system/browser_file_system_callback_dispatcher.h1
-rw-r--r--chrome/browser/file_system/file_system_dispatcher_host.cc36
-rw-r--r--chrome/browser/file_system/file_system_dispatcher_host.h7
4 files changed, 53 insertions, 0 deletions
diff --git a/chrome/browser/file_system/browser_file_system_callback_dispatcher.cc b/chrome/browser/file_system/browser_file_system_callback_dispatcher.cc
index 107515e..129d4a7 100644
--- a/chrome/browser/file_system/browser_file_system_callback_dispatcher.cc
+++ b/chrome/browser/file_system/browser_file_system_callback_dispatcher.cc
@@ -43,3 +43,12 @@ void BrowserFileSystemCallbackDispatcher::DidFail(
request_id_, error_code));
dispatcher_host_->RemoveCompletedOperation(request_id_);
}
+
+void BrowserFileSystemCallbackDispatcher::DidWrite(
+ int64 bytes,
+ bool complete) {
+ dispatcher_host_->Send(new ViewMsg_FileSystem_DidWrite(
+ request_id_, bytes, complete));
+ if (complete)
+ dispatcher_host_->RemoveCompletedOperation(request_id_);
+}
diff --git a/chrome/browser/file_system/browser_file_system_callback_dispatcher.h b/chrome/browser/file_system/browser_file_system_callback_dispatcher.h
index 0372e09..075ae30 100644
--- a/chrome/browser/file_system/browser_file_system_callback_dispatcher.h
+++ b/chrome/browser/file_system/browser_file_system_callback_dispatcher.h
@@ -24,6 +24,7 @@ class BrowserFileSystemCallbackDispatcher
virtual void DidOpenFileSystem(const string16& name,
const FilePath& root_path);
virtual void DidFail(base::PlatformFileError error_code);
+ virtual void DidWrite(int64 bytes, bool complete);
private:
scoped_refptr<FileSystemDispatcherHost> dispatcher_host_;
diff --git a/chrome/browser/file_system/file_system_dispatcher_host.cc b/chrome/browser/file_system/file_system_dispatcher_host.cc
index 385f2a4..5cfa5be 100644
--- a/chrome/browser/file_system/file_system_dispatcher_host.cc
+++ b/chrome/browser/file_system/file_system_dispatcher_host.cc
@@ -115,6 +115,9 @@ bool FileSystemDispatcherHost::OnMessageReceived(
IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Create, OnCreate)
IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Exists, OnExists)
IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_ReadDirectory, OnReadDirectory)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Write, OnWrite)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Truncate, OnTruncate)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_CancelWrite, OnCancel)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP_EX()
return handled;
@@ -206,6 +209,39 @@ void FileSystemDispatcherHost::OnReadDirectory(
GetNewOperation(request_id)->ReadDirectory(path);
}
+void FileSystemDispatcherHost::OnWrite(
+ int request_id,
+ const FilePath& path,
+ const GURL& blob_url,
+ int64 offset) {
+ if (!CheckValidFileSystemPath(path, request_id))
+ return;
+ GetNewOperation(request_id)->Write(path, blob_url, offset);
+}
+
+void FileSystemDispatcherHost::OnTruncate(
+ int request_id,
+ const FilePath& path,
+ int64 length) {
+ if (!CheckValidFileSystemPath(path, request_id))
+ return;
+ GetNewOperation(request_id)->Truncate(path, length);
+}
+
+void FileSystemDispatcherHost::OnCancel(
+ int request_id,
+ int request_id_to_cancel) {
+ fileapi::FileSystemOperation* write =
+ operations_.Lookup(request_id_to_cancel);
+ if (write) {
+ write->Cancel();
+ Send(new ViewMsg_FileSystem_DidSucceed(request_id));
+ } else {
+ Send(new ViewMsg_FileSystem_DidFail(
+ request_id, base::PLATFORM_FILE_ERROR_INVALID_OPERATION));
+ }
+}
+
void FileSystemDispatcherHost::Send(IPC::Message* message) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
if (!shutdown_ && message_sender_)
diff --git a/chrome/browser/file_system/file_system_dispatcher_host.h b/chrome/browser/file_system/file_system_dispatcher_host.h
index ac22255..561350c 100644
--- a/chrome/browser/file_system/file_system_dispatcher_host.h
+++ b/chrome/browser/file_system/file_system_dispatcher_host.h
@@ -17,6 +17,7 @@
#include "webkit/fileapi/file_system_operation.h"
class FileSystemHostContext;
+class GURL;
class HostContentSettingsMap;
class Receiver;
class ResourceMessageFilter;
@@ -49,6 +50,12 @@ class FileSystemDispatcherHost
bool recursive);
void OnExists(int request_id, const FilePath& path, bool is_directory);
void OnReadDirectory(int request_id, const FilePath& path);
+ void OnWrite(int request_id,
+ const FilePath& path,
+ const GURL& blob_url,
+ int64 offset);
+ void OnTruncate(int request_id, const FilePath& path, int64 length);
+ void OnCancel(int request_id, int request_to_cancel);
void Send(IPC::Message* message);
void RemoveCompletedOperation(int request_id);