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" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 class SerializedVarReturnValue; | 25 class SerializedVarReturnValue; |
26 | 26 |
27 class PPB_FileRef_Proxy : public InterfaceProxy { | 27 class PPB_FileRef_Proxy : public InterfaceProxy { |
28 public: | 28 public: |
29 explicit PPB_FileRef_Proxy(Dispatcher* dispatcher); | 29 explicit PPB_FileRef_Proxy(Dispatcher* dispatcher); |
30 virtual ~PPB_FileRef_Proxy(); | 30 virtual ~PPB_FileRef_Proxy(); |
31 | 31 |
32 static PP_Resource CreateProxyResource(PP_Resource file_system, | 32 static PP_Resource CreateProxyResource(PP_Resource file_system, |
33 const char* path); | 33 const char* path); |
34 static PP_Resource CreateProxyResource( | |
35 const PPB_FileRef_CreateInfo& serialized); | |
36 | 34 |
37 // InterfaceProxy implementation. | 35 // InterfaceProxy implementation. |
38 virtual bool OnMessageReceived(const IPC::Message& msg); | 36 virtual bool OnMessageReceived(const IPC::Message& msg); |
39 | 37 |
40 // 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 |
41 // "create info" for reconstitution in the plugin. This struct contains all | 39 // "create info" for reconstitution in the plugin. This struct contains all |
42 // the necessary information about the file ref. | 40 // the necessary information about the file ref. |
43 // | 41 // |
44 // 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 |
45 // dispatcher and host interface. | 43 // dispatcher and host interface. |
46 // | 44 // |
47 // Various PPAPI functions return file refs from various interfaces, so this | 45 // Various PPAPI functions return file refs from various interfaces, so this |
48 // function is public so anybody can send a file ref. | 46 // function is public so anybody can send a file ref. |
49 void SerializeFileRef(PP_Resource file_ref, | 47 void SerializeFileRef(PP_Resource file_ref, |
50 PPB_FileRef_CreateInfo* result); | 48 PPB_FileRef_CreateInfo* result); |
51 | 49 |
52 // 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. |
53 // 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. |
54 // This represents passing the resource ownership to the plugin. This | 52 // This represents passing the resource ownership to the plugin. This |
55 // 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. |
56 // | 54 // |
57 // Various PPAPI functions return file refs from various interfaces, so this | 55 // Various PPAPI functions return file refs from various interfaces, so this |
58 // function is public so anybody can receive a file ref. | 56 // function is public so anybody can receive a file ref. |
59 static PP_Resource DeserializeFileRef( | 57 static PP_Resource DeserializeFileRef( |
60 const PPB_FileRef_CreateInfo& serialized); | 58 const PPB_FileRef_CreateInfo& serialized); |
61 | 59 |
62 static const ApiID kApiID = API_ID_PPB_FILE_REF; | 60 static const ApiID kApiID = API_ID_PPB_FILE_REF; |
63 | 61 |
64 private: | 62 private: |
65 // Plugin -> host message handlers. | 63 // Message handlers. |
66 void OnMsgCreate(const HostResource& file_system, | 64 void OnMsgCreate(const HostResource& file_system, |
67 const std::string& path, | 65 const std::string& path, |
68 PPB_FileRef_CreateInfo* result); | 66 PPB_FileRef_CreateInfo* result); |
69 void OnMsgGetParent(const HostResource& host_resource, | 67 void OnMsgGetParent(const HostResource& host_resource, |
70 PPB_FileRef_CreateInfo* result); | 68 PPB_FileRef_CreateInfo* result); |
71 void OnMsgMakeDirectory(const HostResource& host_resource, | 69 void OnMsgMakeDirectory(const HostResource& host_resource, |
72 PP_Bool make_ancestors, | 70 PP_Bool make_ancestors, |
73 int callback_id); | 71 int callback_id); |
74 void OnMsgTouch(const HostResource& host_resource, | 72 void OnMsgTouch(const HostResource& host_resource, |
75 PP_Time last_access, | 73 PP_Time last_access, |
(...skipping 19 matching lines...) Expand all Loading... |
95 pp::CompletionCallbackFactory<PPB_FileRef_Proxy, | 93 pp::CompletionCallbackFactory<PPB_FileRef_Proxy, |
96 ProxyNonThreadSafeRefCount> callback_factory_; | 94 ProxyNonThreadSafeRefCount> callback_factory_; |
97 | 95 |
98 DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Proxy); | 96 DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Proxy); |
99 }; | 97 }; |
100 | 98 |
101 } // namespace proxy | 99 } // namespace proxy |
102 } // namespace ppapi | 100 } // namespace ppapi |
103 | 101 |
104 #endif // PPAPI_PROXY_PPB_FILE_REF_PROXY_H_ | 102 #endif // PPAPI_PROXY_PPB_FILE_REF_PROXY_H_ |
OLD | NEW |