| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef PPAPI_PROXY_PPB_FILE_IO_PROXY_H_ | |
| 6 #define PPAPI_PROXY_PPB_FILE_IO_PROXY_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "ppapi/c/pp_file_info.h" | |
| 12 #include "ppapi/proxy/interface_proxy.h" | |
| 13 #include "ppapi/proxy/proxy_non_thread_safe_ref_count.h" | |
| 14 | |
| 15 namespace ppapi { | |
| 16 | |
| 17 class HostResource; | |
| 18 namespace proxy { | |
| 19 | |
| 20 class PPB_FileIO_Proxy : public InterfaceProxy { | |
| 21 public: | |
| 22 explicit PPB_FileIO_Proxy(Dispatcher* dispatcher); | |
| 23 virtual ~PPB_FileIO_Proxy(); | |
| 24 | |
| 25 static PP_Resource CreateProxyResource(PP_Instance instance); | |
| 26 | |
| 27 // InterfaceProxy implementation. | |
| 28 virtual bool OnMessageReceived(const IPC::Message& msg); | |
| 29 | |
| 30 static const ApiID kApiID = API_ID_PPB_FILE_IO; | |
| 31 | |
| 32 private: | |
| 33 // Plugin -> Host message handlers. | |
| 34 void OnHostMsgCreate(PP_Instance instance, HostResource* result); | |
| 35 void OnHostMsgOpen(const HostResource& host_resource, | |
| 36 const HostResource& file_ref_resource, | |
| 37 int32_t open_flags); | |
| 38 void OnHostMsgClose(const HostResource& host_resource); | |
| 39 void OnHostMsgQuery(const HostResource& host_resource); | |
| 40 void OnHostMsgTouch(const HostResource& host_resource, | |
| 41 PP_Time last_access_time, | |
| 42 PP_Time last_modified_time); | |
| 43 void OnHostMsgRead(const HostResource& host_resource, | |
| 44 int64_t offset, | |
| 45 int32_t bytes_to_read); | |
| 46 void OnHostMsgWrite(const HostResource& host_resource, | |
| 47 int64_t offset, | |
| 48 const std::string& data); | |
| 49 void OnHostMsgSetLength(const HostResource& host_resource, | |
| 50 int64_t length); | |
| 51 void OnHostMsgFlush(const HostResource& host_resource); | |
| 52 void OnHostMsgWillWrite(const HostResource& host_resource, | |
| 53 int64_t offset, | |
| 54 int32_t bytes_to_write); | |
| 55 void OnHostMsgWillSetLength(const HostResource& host_resource, | |
| 56 int64_t length); | |
| 57 | |
| 58 // Host -> Plugin message handlers. | |
| 59 void OnPluginMsgGeneralComplete(const HostResource& host_resource, | |
| 60 int32_t result); | |
| 61 void OnPluginMsgOpenFileComplete(const HostResource& host_resource, | |
| 62 int32_t result); | |
| 63 void OnPluginMsgQueryComplete(const HostResource& host_resource, | |
| 64 int32_t result, | |
| 65 const PP_FileInfo& info); | |
| 66 void OnPluginMsgReadComplete(const HostResource& host_resource, | |
| 67 int32_t result, | |
| 68 const std::string& data); | |
| 69 void OnPluginMsgWriteComplete(const HostResource& host_resource, | |
| 70 int32_t result); | |
| 71 | |
| 72 // Host-side callback handlers. These convert the callbacks to an IPC message | |
| 73 // to the plugin. | |
| 74 void GeneralCallbackCompleteInHost(int32_t pp_error, | |
| 75 const HostResource& host_resource); | |
| 76 void OpenFileCallbackCompleteInHost(int32_t pp_error, | |
| 77 const HostResource& host_resource); | |
| 78 void QueryCallbackCompleteInHost(int32_t pp_error, | |
| 79 const HostResource& host_resource, | |
| 80 PP_FileInfo* info); | |
| 81 void ReadCallbackCompleteInHost(int32_t pp_error, | |
| 82 const HostResource& host_resource, | |
| 83 std::string* data); | |
| 84 pp::CompletionCallbackFactory<PPB_FileIO_Proxy, | |
| 85 ProxyNonThreadSafeRefCount> callback_factory_; | |
| 86 | |
| 87 DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Proxy); | |
| 88 }; | |
| 89 | |
| 90 } // namespace proxy | |
| 91 } // namespace ppapi | |
| 92 | |
| 93 #endif // PPAPI_PROXY_PPB_FILE_IO_PROXY_H_ | |
| OLD | NEW |