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_completion_callback_factory.h" | |
14 #include "ppapi/utility/completion_callback_factory.h" | |
15 | |
16 namespace ppapi { | |
17 | |
18 class HostResource; | |
19 namespace proxy { | |
20 | |
21 class PPB_FileIO_Proxy : public InterfaceProxy { | |
22 public: | |
23 explicit PPB_FileIO_Proxy(Dispatcher* dispatcher); | |
24 virtual ~PPB_FileIO_Proxy(); | |
25 | |
26 static PP_Resource CreateProxyResource(PP_Instance instance); | |
27 | |
28 // InterfaceProxy implementation. | |
29 virtual bool OnMessageReceived(const IPC::Message& msg); | |
30 | |
31 static const ApiID kApiID = API_ID_PPB_FILE_IO; | |
32 | |
33 private: | |
34 // Plugin -> Host message handlers. | |
35 void OnHostMsgCreate(PP_Instance instance, HostResource* result); | |
36 void OnHostMsgOpen(const HostResource& host_resource, | |
37 const HostResource& file_ref_resource, | |
38 int32_t open_flags); | |
39 void OnHostMsgClose(const HostResource& host_resource); | |
40 void OnHostMsgQuery(const HostResource& host_resource); | |
41 void OnHostMsgTouch(const HostResource& host_resource, | |
42 PP_Time last_access_time, | |
43 PP_Time last_modified_time); | |
44 void OnHostMsgRead(const HostResource& host_resource, | |
45 int64_t offset, | |
46 int32_t bytes_to_read); | |
47 void OnHostMsgWrite(const HostResource& host_resource, | |
48 int64_t offset, | |
49 const std::string& data); | |
50 void OnHostMsgSetLength(const HostResource& host_resource, | |
51 int64_t length); | |
52 void OnHostMsgFlush(const HostResource& host_resource); | |
53 void OnHostMsgWillWrite(const HostResource& host_resource, | |
54 int64_t offset, | |
55 int32_t bytes_to_write); | |
56 void OnHostMsgWillSetLength(const HostResource& host_resource, | |
57 int64_t length); | |
58 | |
59 // Host -> Plugin message handlers. | |
60 void OnPluginMsgGeneralComplete(const HostResource& host_resource, | |
61 int32_t result); | |
62 void OnPluginMsgOpenFileComplete(const HostResource& host_resource, | |
63 int32_t result); | |
64 void OnPluginMsgQueryComplete(const HostResource& host_resource, | |
65 int32_t result, | |
66 const PP_FileInfo& info); | |
67 void OnPluginMsgReadComplete(const HostResource& host_resource, | |
68 int32_t result, | |
69 const std::string& data); | |
70 void OnPluginMsgWriteComplete(const HostResource& host_resource, | |
71 int32_t result); | |
72 | |
73 // Host-side callback handlers. These convert the callbacks to an IPC message | |
74 // to the plugin. | |
75 void GeneralCallbackCompleteInHost(int32_t pp_error, | |
76 const HostResource& host_resource); | |
77 void OpenFileCallbackCompleteInHost(int32_t pp_error, | |
78 const HostResource& host_resource); | |
79 void QueryCallbackCompleteInHost(int32_t pp_error, | |
80 const HostResource& host_resource, | |
81 PP_FileInfo* info); | |
82 void ReadCallbackCompleteInHost(int32_t pp_error, | |
83 const HostResource& host_resource, | |
84 std::string* data); | |
85 ProxyCompletionCallbackFactory<PPB_FileIO_Proxy> 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 |