1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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_completion_callback_factory.h"
#include "ppapi/utility/completion_callback_factory.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);
ProxyCompletionCallbackFactory<PPB_FileIO_Proxy> callback_factory_;
DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Proxy);
};
} // namespace proxy
} // namespace ppapi
#endif // PPAPI_PROXY_PPB_FILE_IO_PROXY_H_
|