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.
5 #ifndef PPAPI_PROXY_PPB_FILE_IO_PROXY_H_
6 #define PPAPI_PROXY_PPB_FILE_IO_PROXY_H_
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"
21 class PPB_FileIO_Proxy
: public InterfaceProxy
{
23 explicit PPB_FileIO_Proxy(Dispatcher
* dispatcher
);
24 virtual ~PPB_FileIO_Proxy();
26 static PP_Resource
CreateProxyResource(PP_Instance instance
);
28 // InterfaceProxy implementation.
29 virtual bool OnMessageReceived(const IPC::Message
& msg
);
31 static const ApiID kApiID
= API_ID_PPB_FILE_IO
;
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
,
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
,
46 int32_t bytes_to_read
);
47 void OnHostMsgWrite(const HostResource
& host_resource
,
49 const std::string
& data
);
50 void OnHostMsgSetLength(const HostResource
& host_resource
,
52 void OnHostMsgFlush(const HostResource
& host_resource
);
53 void OnHostMsgWillWrite(const HostResource
& host_resource
,
55 int32_t bytes_to_write
);
56 void OnHostMsgWillSetLength(const HostResource
& host_resource
,
59 // Host -> Plugin message handlers.
60 void OnPluginMsgGeneralComplete(const HostResource
& host_resource
,
62 void OnPluginMsgOpenFileComplete(const HostResource
& host_resource
,
64 void OnPluginMsgQueryComplete(const HostResource
& host_resource
,
66 const PP_FileInfo
& info
);
67 void OnPluginMsgReadComplete(const HostResource
& host_resource
,
69 const std::string
& data
);
70 void OnPluginMsgWriteComplete(const HostResource
& host_resource
,
73 // Host-side callback handlers. These convert the callbacks to an IPC message
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
,
82 void ReadCallbackCompleteInHost(int32_t pp_error
,
83 const HostResource
& host_resource
,
85 ProxyCompletionCallbackFactory
<PPB_FileIO_Proxy
> callback_factory_
;
87 DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Proxy
);
93 #endif // PPAPI_PROXY_PPB_FILE_IO_PROXY_H_