diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-10 16:54:22 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-10 16:54:22 +0000 |
commit | cc6db92524420397e246af1ed1b07258ded14e30 (patch) | |
tree | 5cd8ffb89c17dece4d2a4ba4fd7e137fff6ece1c /ppapi/proxy/ppb_file_io_proxy.h | |
parent | 854f39b3dd8619365ee75abdd9d9e25d4397f14a (diff) | |
download | chromium_src-cc6db92524420397e246af1ed1b07258ded14e30.zip chromium_src-cc6db92524420397e246af1ed1b07258ded14e30.tar.gz chromium_src-cc6db92524420397e246af1ed1b07258ded14e30.tar.bz2 |
Implement a proxy for Pepper FileIO.
[ Reland of 113565 http://codereview.chromium.org/8764003 ]
This splits apart the old in-process implementation into a new object in shared_impl that does most of the general tracking. This alllows that code to be shared by the proxy.
BUG=http://crbug.com/101154
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113953 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/ppb_file_io_proxy.h')
-rw-r--r-- | ppapi/proxy/ppb_file_io_proxy.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/ppapi/proxy/ppb_file_io_proxy.h b/ppapi/proxy/ppb_file_io_proxy.h new file mode 100644 index 0000000..fbc8a16 --- /dev/null +++ b/ppapi/proxy/ppb_file_io_proxy.h @@ -0,0 +1,93 @@ +// Copyright (c) 2011 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 PPAPI_PROXY_PPB_FILE_IO_PROXY_H_ +#define PPAPI_PROXY_PPB_FILE_IO_PROXY_H_ + +#include <string> + +#include "base/basictypes.h" +#include "ppapi/c/pp_file_info.h" +#include "ppapi/proxy/interface_proxy.h" +#include "ppapi/proxy/proxy_non_thread_safe_ref_count.h" + +namespace ppapi { + +class HostResource; +namespace proxy { + +class PPB_FileIO_Proxy : public InterfaceProxy { + public: + explicit PPB_FileIO_Proxy(Dispatcher* dispatcher); + virtual ~PPB_FileIO_Proxy(); + + static PP_Resource CreateProxyResource(PP_Instance instance); + + // InterfaceProxy implementation. + virtual bool OnMessageReceived(const IPC::Message& msg); + + static const ApiID kApiID = API_ID_PPB_FILE_IO; + + private: + // Plugin -> Host message handlers. + void OnHostMsgCreate(PP_Instance instance, HostResource* result); + void OnHostMsgOpen(const HostResource& host_resource, + const HostResource& file_ref_resource, + int32_t open_flags); + void OnHostMsgClose(const HostResource& host_resource); + void OnHostMsgQuery(const HostResource& host_resource); + void OnHostMsgTouch(const HostResource& host_resource, + PP_Time last_access_time, + PP_Time last_modified_time); + void OnHostMsgRead(const HostResource& host_resource, + int64_t offset, + int32_t bytes_to_read); + void OnHostMsgWrite(const HostResource& host_resource, + int64_t offset, + const std::string& data); + void OnHostMsgSetLength(const HostResource& host_resource, + int64_t length); + void OnHostMsgFlush(const HostResource& host_resource); + void OnHostMsgWillWrite(const HostResource& host_resource, + int64_t offset, + int32_t bytes_to_write); + void OnHostMsgWillSetLength(const HostResource& host_resource, + int64_t length); + + // Host -> Plugin message handlers. + void OnPluginMsgGeneralComplete(const HostResource& host_resource, + int32_t result); + void OnPluginMsgOpenFileComplete(const HostResource& host_resource, + int32_t result); + void OnPluginMsgQueryComplete(const HostResource& host_resource, + int32_t result, + const PP_FileInfo& info); + void OnPluginMsgReadComplete(const HostResource& host_resource, + int32_t result, + const std::string& data); + void OnPluginMsgWriteComplete(const HostResource& host_resource, + int32_t result); + + // Host-side callback handlers. These convert the callbacks to an IPC message + // to the plugin. + void GeneralCallbackCompleteInHost(int32_t pp_error, + const HostResource& host_resource); + void OpenFileCallbackCompleteInHost(int32_t pp_error, + const HostResource& host_resource); + void QueryCallbackCompleteInHost(int32_t pp_error, + const HostResource& host_resource, + PP_FileInfo* info); + void ReadCallbackCompleteInHost(int32_t pp_error, + const HostResource& host_resource, + std::string* data); + pp::CompletionCallbackFactory<PPB_FileIO_Proxy, + ProxyNonThreadSafeRefCount> callback_factory_; + + DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Proxy); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_PPB_FILE_IO_PROXY_H_ |