OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef PPAPI_PROXY_PPB_FILE_REF_PROXY_H_ | 5 #ifndef PPAPI_PROXY_PPB_FILE_REF_PROXY_H_ |
6 #define PPAPI_PROXY_PPB_FILE_REF_PROXY_H_ | 6 #define PPAPI_PROXY_PPB_FILE_REF_PROXY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "ppapi/c/pp_module.h" | 11 #include "ppapi/c/pp_module.h" |
12 #include "ppapi/c/pp_resource.h" | 12 #include "ppapi/c/pp_resource.h" |
13 #include "ppapi/c/pp_time.h" | 13 #include "ppapi/c/pp_time.h" |
14 #include "ppapi/proxy/interface_proxy.h" | 14 #include "ppapi/proxy/interface_proxy.h" |
15 | 15 |
16 struct PPB_FileRef_Dev; | 16 struct PPB_FileRef_Dev; |
17 | 17 |
18 namespace ppapi { | 18 namespace ppapi { |
19 | 19 |
20 class HostResource; | 20 class HostResource; |
| 21 struct PPB_FileRef_CreateInfo; |
21 | 22 |
22 namespace proxy { | 23 namespace proxy { |
23 | 24 |
24 struct PPBFileRef_CreateInfo; | |
25 | |
26 class PPB_FileRef_Proxy : public InterfaceProxy { | 25 class PPB_FileRef_Proxy : public InterfaceProxy { |
27 public: | 26 public: |
28 PPB_FileRef_Proxy(Dispatcher* dispatcher, const void* target_interface); | 27 PPB_FileRef_Proxy(Dispatcher* dispatcher, const void* target_interface); |
29 virtual ~PPB_FileRef_Proxy(); | 28 virtual ~PPB_FileRef_Proxy(); |
30 | 29 |
31 static const Info* GetInfo(); | 30 static const Info* GetInfo(); |
32 | 31 |
33 static PP_Resource CreateProxyResource(PP_Resource file_system, | 32 static PP_Resource CreateProxyResource(PP_Resource file_system, |
34 const char* path); | 33 const char* path); |
35 | 34 |
36 // InterfaceProxy implementation. | 35 // InterfaceProxy implementation. |
37 virtual bool OnMessageReceived(const IPC::Message& msg); | 36 virtual bool OnMessageReceived(const IPC::Message& msg); |
38 | 37 |
39 // Takes a resource in the host and converts it into a serialized file ref | 38 // Takes a resource in the host and converts it into a serialized file ref |
40 // "create info" for reconstitution in the plugin. This struct contains all | 39 // "create info" for reconstitution in the plugin. This struct contains all |
41 // the necessary information about the file ref. | 40 // the necessary information about the file ref. |
42 // | 41 // |
43 // This function is not static because it needs access to the particular | 42 // This function is not static because it needs access to the particular |
44 // dispatcher and host interface. | 43 // dispatcher and host interface. |
45 // | 44 // |
46 // Various PPAPI functions return file refs from various interfaces, so this | 45 // Various PPAPI functions return file refs from various interfaces, so this |
47 // function is public so anybody can send a file ref. | 46 // function is public so anybody can send a file ref. |
48 void SerializeFileRef(PP_Resource file_ref, | 47 void SerializeFileRef(PP_Resource file_ref, |
49 PPBFileRef_CreateInfo* result); | 48 PPB_FileRef_CreateInfo* result); |
50 | 49 |
51 // Creates a plugin resource from the given CreateInfo sent from the host. | 50 // 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. | 51 // The value will be the result of calling SerializeFileRef on the host. |
53 // This represents passing the resource ownership to the plugin. This | 52 // This represents passing the resource ownership to the plugin. This |
54 // function also checks the validity of the result and returns 0 on failure. | 53 // function also checks the validity of the result and returns 0 on failure. |
55 // | 54 // |
56 // Various PPAPI functions return file refs from various interfaces, so this | 55 // Various PPAPI functions return file refs from various interfaces, so this |
57 // function is public so anybody can receive a file ref. | 56 // function is public so anybody can receive a file ref. |
58 static PP_Resource DeserializeFileRef( | 57 static PP_Resource DeserializeFileRef( |
59 const PPBFileRef_CreateInfo& serialized); | 58 const PPB_FileRef_CreateInfo& serialized); |
60 | 59 |
61 private: | 60 private: |
62 // Message handlers. | 61 // Message handlers. |
63 void OnMsgCreate(const ppapi::HostResource& file_system, | 62 void OnMsgCreate(const ppapi::HostResource& file_system, |
64 const std::string& path, | 63 const std::string& path, |
65 PPBFileRef_CreateInfo* result); | 64 PPB_FileRef_CreateInfo* result); |
66 void OnMsgGetParent(const ppapi::HostResource& host_resource, | 65 void OnMsgGetParent(const ppapi::HostResource& host_resource, |
67 PPBFileRef_CreateInfo* result); | 66 PPB_FileRef_CreateInfo* result); |
68 void OnMsgMakeDirectory(const ppapi::HostResource& host_resource, | 67 void OnMsgMakeDirectory(const ppapi::HostResource& host_resource, |
69 PP_Bool make_ancestors, | 68 PP_Bool make_ancestors, |
70 uint32_t serialized_callback); | 69 uint32_t serialized_callback); |
71 void OnMsgTouch(const ppapi::HostResource& host_resource, | 70 void OnMsgTouch(const ppapi::HostResource& host_resource, |
72 PP_Time last_access, | 71 PP_Time last_access, |
73 PP_Time last_modified, | 72 PP_Time last_modified, |
74 uint32_t serialized_callback); | 73 uint32_t serialized_callback); |
75 void OnMsgDelete(const ppapi::HostResource& host_resource, | 74 void OnMsgDelete(const ppapi::HostResource& host_resource, |
76 uint32_t serialized_callback); | 75 uint32_t serialized_callback); |
77 void OnMsgRename(const ppapi::HostResource& file_ref, | 76 void OnMsgRename(const ppapi::HostResource& file_ref, |
78 const ppapi::HostResource& new_file_ref, | 77 const ppapi::HostResource& new_file_ref, |
79 uint32_t serialized_callback); | 78 uint32_t serialized_callback); |
80 | 79 |
81 DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Proxy); | 80 DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Proxy); |
82 }; | 81 }; |
83 | 82 |
84 } // namespace proxy | 83 } // namespace proxy |
85 } // namespace ppapi | 84 } // namespace ppapi |
86 | 85 |
87 #endif // PPAPI_PROXY_PPB_FILE_REF_PROXY_H_ | 86 #endif // PPAPI_PROXY_PPB_FILE_REF_PROXY_H_ |
OLD | NEW |