| 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_PPB_URL_LOADER_PROXY_H_ | 5 #ifndef PPAPI_PPB_URL_LOADER_PROXY_H_ |
| 6 #define PPAPI_PPB_URL_LOADER_PROXY_H_ | 6 #define PPAPI_PPB_URL_LOADER_PROXY_H_ |
| 7 | 7 |
| 8 #include "ppapi/c/pp_completion_callback.h" | 8 #include "ppapi/c/pp_completion_callback.h" |
| 9 #include "ppapi/c/pp_instance.h" | 9 #include "ppapi/c/pp_instance.h" |
| 10 #include "ppapi/c/pp_module.h" | 10 #include "ppapi/c/pp_module.h" |
| 11 #include "ppapi/c/pp_resource.h" | 11 #include "ppapi/c/pp_resource.h" |
| 12 #include "ppapi/c/pp_size.h" | 12 #include "ppapi/c/pp_size.h" |
| 13 #include "ppapi/c/pp_var.h" | 13 #include "ppapi/c/pp_var.h" |
| 14 #include "ppapi/cpp/completion_callback.h" | 14 #include "ppapi/cpp/completion_callback.h" |
| 15 #include "ppapi/proxy/host_resource.h" | |
| 16 #include "ppapi/proxy/interface_proxy.h" | 15 #include "ppapi/proxy/interface_proxy.h" |
| 17 #include "ppapi/proxy/proxy_non_thread_safe_ref_count.h" | 16 #include "ppapi/proxy/proxy_non_thread_safe_ref_count.h" |
| 17 #include "ppapi/shared_impl/host_resource.h" |
| 18 | 18 |
| 19 struct PPB_URLLoader; | 19 struct PPB_URLLoader; |
| 20 struct PPB_URLLoaderTrusted; | 20 struct PPB_URLLoaderTrusted; |
| 21 | 21 |
| 22 namespace pp { | 22 namespace pp { |
| 23 namespace proxy { | 23 namespace proxy { |
| 24 | 24 |
| 25 struct PPBURLLoader_UpdateProgress_Params; | 25 struct PPBURLLoader_UpdateProgress_Params; |
| 26 | 26 |
| 27 class PPB_URLLoader_Proxy : public InterfaceProxy { | 27 class PPB_URLLoader_Proxy : public InterfaceProxy { |
| 28 public: | 28 public: |
| 29 PPB_URLLoader_Proxy(Dispatcher* dispatcher, const void* target_interface); | 29 PPB_URLLoader_Proxy(Dispatcher* dispatcher, const void* target_interface); |
| 30 virtual ~PPB_URLLoader_Proxy(); | 30 virtual ~PPB_URLLoader_Proxy(); |
| 31 | 31 |
| 32 static const Info* GetInfo(); | 32 static const Info* GetInfo(); |
| 33 static const Info* GetTrustedInfo(); | 33 static const Info* GetTrustedInfo(); |
| 34 | 34 |
| 35 static PP_Resource CreateProxyResource(PP_Instance instance); | 35 static PP_Resource CreateProxyResource(PP_Instance instance); |
| 36 | 36 |
| 37 // URLLoader objects are normally allocated by the Create function, but | 37 // URLLoader objects are normally allocated by the Create function, but |
| 38 // they are also provided to PPP_Instance.OnMsgHandleDocumentLoad. This | 38 // they are also provided to PPP_Instance.OnMsgHandleDocumentLoad. This |
| 39 // function allows the proxy for DocumentLoad to create the correct plugin | 39 // function allows the proxy for DocumentLoad to create the correct plugin |
| 40 // proxied info for the given browser-supplied URLLoader resource ID. | 40 // proxied info for the given browser-supplied URLLoader resource ID. |
| 41 static PP_Resource TrackPluginResource( | 41 static PP_Resource TrackPluginResource( |
| 42 const HostResource& url_loader_resource); | 42 const ppapi::HostResource& url_loader_resource); |
| 43 | 43 |
| 44 const PPB_URLLoader* ppb_url_loader_target() const { | 44 const PPB_URLLoader* ppb_url_loader_target() const { |
| 45 return reinterpret_cast<const PPB_URLLoader*>(target_interface()); | 45 return reinterpret_cast<const PPB_URLLoader*>(target_interface()); |
| 46 } | 46 } |
| 47 | 47 |
| 48 // InterfaceProxy implementation. | 48 // InterfaceProxy implementation. |
| 49 virtual bool OnMessageReceived(const IPC::Message& msg); | 49 virtual bool OnMessageReceived(const IPC::Message& msg); |
| 50 | 50 |
| 51 // URLLoader objects are sent from places other than just URLLoader.Create, | 51 // URLLoader objects are sent from places other than just URLLoader.Create, |
| 52 // in particular when doing a full-frame plugin. This function does the | 52 // in particular when doing a full-frame plugin. This function does the |
| 53 // necessary setup in the host before the resource is sent. Call this any | 53 // necessary setup in the host before the resource is sent. Call this any |
| 54 // time you're sending a new URLLoader that the plugin hasn't seen yet. | 54 // time you're sending a new URLLoader that the plugin hasn't seen yet. |
| 55 void PrepareURLLoaderForSendingToPlugin(PP_Resource resource); | 55 void PrepareURLLoaderForSendingToPlugin(PP_Resource resource); |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 // Data associated with callbacks for ReadResponseBody. | 58 // Data associated with callbacks for ReadResponseBody. |
| 59 struct ReadCallbackInfo; | 59 struct ReadCallbackInfo; |
| 60 | 60 |
| 61 // Plugin->renderer message handlers. | 61 // Plugin->renderer message handlers. |
| 62 void OnMsgCreate(PP_Instance instance, | 62 void OnMsgCreate(PP_Instance instance, |
| 63 HostResource* result); | 63 ppapi::HostResource* result); |
| 64 void OnMsgOpen(const HostResource& loader, | 64 void OnMsgOpen(const ppapi::HostResource& loader, |
| 65 const HostResource& request_info, | 65 const ppapi::HostResource& request_info, |
| 66 uint32_t serialized_callback); | 66 uint32_t serialized_callback); |
| 67 void OnMsgFollowRedirect(const HostResource& loader, | 67 void OnMsgFollowRedirect(const ppapi::HostResource& loader, |
| 68 uint32_t serialized_callback); | 68 uint32_t serialized_callback); |
| 69 void OnMsgGetResponseInfo(const HostResource& loader, | 69 void OnMsgGetResponseInfo(const ppapi::HostResource& loader, |
| 70 HostResource* result); | 70 ppapi::HostResource* result); |
| 71 void OnMsgReadResponseBody(const HostResource& loader, | 71 void OnMsgReadResponseBody(const ppapi::HostResource& loader, |
| 72 int32_t bytes_to_read); | 72 int32_t bytes_to_read); |
| 73 void OnMsgFinishStreamingToFile(const HostResource& loader, | 73 void OnMsgFinishStreamingToFile(const ppapi::HostResource& loader, |
| 74 uint32_t serialized_callback); | 74 uint32_t serialized_callback); |
| 75 void OnMsgClose(const HostResource& loader); | 75 void OnMsgClose(const ppapi::HostResource& loader); |
| 76 void OnMsgGrantUniversalAccess(const HostResource& loader); | 76 void OnMsgGrantUniversalAccess(const ppapi::HostResource& loader); |
| 77 | 77 |
| 78 // Renderer->plugin message handlers. | 78 // Renderer->plugin message handlers. |
| 79 void OnMsgUpdateProgress( | 79 void OnMsgUpdateProgress( |
| 80 const PPBURLLoader_UpdateProgress_Params& params); | 80 const PPBURLLoader_UpdateProgress_Params& params); |
| 81 void OnMsgReadResponseBodyAck(const HostResource& pp_resource, | 81 void OnMsgReadResponseBodyAck(const ppapi::HostResource& pp_resource, |
| 82 int32_t result, | 82 int32_t result, |
| 83 const std::string& data); | 83 const std::string& data); |
| 84 | 84 |
| 85 // Handles callbacks for read complete messages. Takes ownership of the info | 85 // Handles callbacks for read complete messages. Takes ownership of the info |
| 86 // pointer. | 86 // pointer. |
| 87 void OnReadCallback(int32_t result, ReadCallbackInfo* info); | 87 void OnReadCallback(int32_t result, ReadCallbackInfo* info); |
| 88 | 88 |
| 89 CompletionCallbackFactory<PPB_URLLoader_Proxy, | 89 CompletionCallbackFactory<PPB_URLLoader_Proxy, |
| 90 ProxyNonThreadSafeRefCount> callback_factory_; | 90 ProxyNonThreadSafeRefCount> callback_factory_; |
| 91 | 91 |
| 92 // Valid only in the host, this lazily-initialized pointer indicates the | 92 // Valid only in the host, this lazily-initialized pointer indicates the |
| 93 // URLLoaderTrusted interface. | 93 // URLLoaderTrusted interface. |
| 94 const PPB_URLLoaderTrusted* host_urlloader_trusted_interface_; | 94 const PPB_URLLoaderTrusted* host_urlloader_trusted_interface_; |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 } // namespace proxy | 97 } // namespace proxy |
| 98 } // namespace pp | 98 } // namespace pp |
| 99 | 99 |
| 100 #endif // PPAPI_PPB_URL_LOADER_PROXY_H_ | 100 #endif // PPAPI_PPB_URL_LOADER_PROXY_H_ |
| OLD | NEW |