diff options
author | ericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-16 00:02:53 +0000 |
---|---|---|
committer | ericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-16 00:02:53 +0000 |
commit | 07c3d212963a1638659c4130f05bd5196957b2f6 (patch) | |
tree | f9fcfd54a7e26b443b1b941f80475725cb4d79cd /content/common | |
parent | 5800f19aa9967928eca31752678ac7d8e4e0cd1d (diff) | |
download | chromium_src-07c3d212963a1638659c4130f05bd5196957b2f6.zip chromium_src-07c3d212963a1638659c4130f05bd5196957b2f6.tar.gz chromium_src-07c3d212963a1638659c4130f05bd5196957b2f6.tar.bz2 |
Let Pepper open FileSystem files again.
TEST=none [existing tests, but they're not currently run automatically]
BUG=none
Review URL: http://codereview.chromium.org/6850027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81837 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common')
-rw-r--r-- | content/common/file_system/file_system_dispatcher.cc | 27 | ||||
-rw-r--r-- | content/common/file_system/file_system_dispatcher.h | 10 | ||||
-rw-r--r-- | content/common/file_system_messages.h | 10 |
3 files changed, 47 insertions, 0 deletions
diff --git a/content/common/file_system/file_system_dispatcher.cc b/content/common/file_system/file_system_dispatcher.cc index c4fe701..eed8f10 100644 --- a/content/common/file_system/file_system_dispatcher.cc +++ b/content/common/file_system/file_system_dispatcher.cc @@ -5,6 +5,7 @@ #include "content/common/file_system/file_system_dispatcher.h" #include "base/file_util.h" +#include "base/process.h" #include "content/common/child_thread.h" #include "content/common/file_system_messages.h" @@ -32,6 +33,7 @@ bool FileSystemDispatcher::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(FileSystemMsg_DidReadMetadata, OnDidReadMetadata) IPC_MESSAGE_HANDLER(FileSystemMsg_DidFail, OnDidFail) IPC_MESSAGE_HANDLER(FileSystemMsg_DidWrite, OnDidWrite) + IPC_MESSAGE_HANDLER(FileSystemMsg_DidOpenFile, OnDidOpenFile) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; @@ -213,6 +215,21 @@ bool FileSystemDispatcher::TouchFile( return true; } +bool FileSystemDispatcher::OpenFile( + const GURL& file_path, + int file_flags, + fileapi::FileSystemCallbackDispatcher* dispatcher) { + int request_id = dispatchers_.Add(dispatcher); + if (!ChildThread::current()->Send( + new FileSystemHostMsg_OpenFile( + request_id, file_path, file_flags))) { + dispatchers_.Remove(request_id); // destroys |dispatcher| + return false; + } + + return true; +} + void FileSystemDispatcher::OnOpenComplete( int request_id, bool accepted, const std::string& name, const GURL& root) { @@ -273,3 +290,13 @@ void FileSystemDispatcher::OnDidWrite( if (complete) dispatchers_.Remove(request_id); } + +void FileSystemDispatcher::OnDidOpenFile( + int request_id, IPC::PlatformFileForTransit file) { + fileapi::FileSystemCallbackDispatcher* dispatcher = + dispatchers_.Lookup(request_id); + DCHECK(dispatcher); + dispatcher->DidOpenFile(IPC::PlatformFileForTransitToPlatformFile(file), + base::kNullProcessHandle); + dispatchers_.Remove(request_id); +} diff --git a/content/common/file_system/file_system_dispatcher.h b/content/common/file_system/file_system_dispatcher.h index b898eae..b480ce8 100644 --- a/content/common/file_system/file_system_dispatcher.h +++ b/content/common/file_system/file_system_dispatcher.h @@ -10,8 +10,10 @@ #include "base/basictypes.h" #include "base/file_util_proxy.h" #include "base/id_map.h" +#include "base/process.h" #include "ipc/ipc_channel.h" #include "ipc/ipc_message.h" +#include "ipc/ipc_platform_file.h" #include "webkit/fileapi/file_system_callback_dispatcher.h" #include "webkit/fileapi/file_system_types.h" @@ -75,6 +77,11 @@ class FileSystemDispatcher : public IPC::Channel::Listener { const base::Time& last_modified_time, fileapi::FileSystemCallbackDispatcher* dispatcher); + // This returns a raw open PlatformFile, unlike the above, which are + // self-contained operations. + bool OpenFile(const GURL& file_path, + int file_flags, // passed to FileUtilProxy::CreateOrOpen + fileapi::FileSystemCallbackDispatcher* dispatcher); private: // Message handlers. void OnOpenComplete( @@ -92,6 +99,9 @@ class FileSystemDispatcher : public IPC::Channel::Listener { bool has_more); void OnDidFail(int request_id, base::PlatformFileError error_code); void OnDidWrite(int request_id, int64 bytes, bool complete); + void OnDidOpenFile( + int request_id, + IPC::PlatformFileForTransit file); IDMap<fileapi::FileSystemCallbackDispatcher, IDMapOwnPointer> dispatchers_; diff --git a/content/common/file_system_messages.h b/content/common/file_system_messages.h index d91a7a6..0df4b0ce 100644 --- a/content/common/file_system_messages.h +++ b/content/common/file_system_messages.h @@ -7,6 +7,7 @@ #include "base/file_util_proxy.h" #include "ipc/ipc_message_macros.h" +#include "ipc/ipc_platform_file.h" #include "webkit/fileapi/file_system_types.h" #define IPC_MESSAGE_START FileSystemMsgStart @@ -42,6 +43,9 @@ IPC_MESSAGE_CONTROL3(FileSystemMsg_DidWrite, int /* request_id */, int64 /* byte count */, bool /* complete */) +IPC_MESSAGE_CONTROL2(FileSystemMsg_DidOpenFile, + int /* request_id */, + IPC::PlatformFileForTransit) IPC_MESSAGE_CONTROL2(FileSystemMsg_DidFail, int /* request_id */, base::PlatformFileError /* error_code */) @@ -122,3 +126,9 @@ IPC_MESSAGE_CONTROL4(FileSystemHostMsg_TouchFile, IPC_MESSAGE_CONTROL2(FileSystemHostMsg_CancelWrite, int /* request id */, int /* id of request to cancel */) + +// Pepper's OpenFile message. +IPC_MESSAGE_CONTROL3(FileSystemHostMsg_OpenFile, + int /* request id */, + GURL /* file path */, + int /* file flags */) |