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