Fix iOS build for XCode 4.6.
[chromium-blink-merge.git] / ppapi / proxy / ppb_file_ref_proxy.h
blobe4a412e9674f24dbd1a017c65e8838dfb9594133
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_REF_PROXY_H_
6 #define PPAPI_PROXY_PPB_FILE_REF_PROXY_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "ppapi/c/pp_module.h"
12 #include "ppapi/c/pp_resource.h"
13 #include "ppapi/c/pp_time.h"
14 #include "ppapi/proxy/interface_proxy.h"
15 #include "ppapi/proxy/ppapi_proxy_export.h"
16 #include "ppapi/proxy/proxy_completion_callback_factory.h"
17 #include "ppapi/utility/completion_callback_factory.h"
19 namespace ppapi {
21 class HostResource;
22 struct PPB_FileRef_CreateInfo;
24 namespace proxy {
26 class SerializedVarReturnValue;
28 class PPAPI_PROXY_EXPORT PPB_FileRef_Proxy
29 : public NON_EXPORTED_BASE(InterfaceProxy) {
30 public:
31 explicit PPB_FileRef_Proxy(Dispatcher* dispatcher);
32 virtual ~PPB_FileRef_Proxy();
34 static PP_Resource CreateProxyResource(PP_Resource file_system,
35 const char* path);
36 static PP_Resource CreateProxyResource(
37 const PPB_FileRef_CreateInfo& serialized);
39 // InterfaceProxy implementation.
40 virtual bool OnMessageReceived(const IPC::Message& msg);
42 // Takes a resource in the host and converts it into a serialized file ref
43 // "create info" for reconstitution in the plugin. This struct contains all
44 // the necessary information about the file ref.
46 // Various PPAPI functions return file refs from various interfaces, so this
47 // function is public so anybody can send a file ref.
48 static void SerializeFileRef(PP_Resource file_ref,
49 PPB_FileRef_CreateInfo* result);
51 // Creates a plugin resource from the given CreateInfo sent from the host.
52 // The value will be the result of calling SerializeFileRef on the host.
53 // This represents passing the resource ownership to the plugin. This
54 // function also checks the validity of the result and returns 0 on failure.
56 // Various PPAPI functions return file refs from various interfaces, so this
57 // function is public so anybody can receive a file ref.
58 static PP_Resource DeserializeFileRef(
59 const PPB_FileRef_CreateInfo& serialized);
61 static const ApiID kApiID = API_ID_PPB_FILE_REF;
63 private:
64 // Plugin -> host message handlers.
65 void OnMsgCreate(const HostResource& file_system,
66 const std::string& path,
67 PPB_FileRef_CreateInfo* result);
68 void OnMsgGetParent(const HostResource& host_resource,
69 PPB_FileRef_CreateInfo* result);
70 void OnMsgMakeDirectory(const HostResource& host_resource,
71 PP_Bool make_ancestors,
72 int callback_id);
73 void OnMsgTouch(const HostResource& host_resource,
74 PP_Time last_access,
75 PP_Time last_modified,
76 int callback_id);
77 void OnMsgDelete(const HostResource& host_resource,
78 int callback_id);
79 void OnMsgRename(const HostResource& file_ref,
80 const HostResource& new_file_ref,
81 int callback_id);
82 void OnMsgGetAbsolutePath(const HostResource& host_resource,
83 SerializedVarReturnValue result);
85 // Host -> Plugin message handlers.
86 void OnMsgCallbackComplete(const HostResource& host_resource,
87 int callback_id,
88 int32_t result);
90 void OnCallbackCompleteInHost(int32_t result,
91 const HostResource& host_resource,
92 int callback_id);
94 ProxyCompletionCallbackFactory<PPB_FileRef_Proxy> callback_factory_;
96 DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Proxy);
99 } // namespace proxy
100 } // namespace ppapi
102 #endif // PPAPI_PROXY_PPB_FILE_REF_PROXY_H_