OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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. | |
4 | |
5 #ifndef PPAPI_PPB_URL_LOADER_PROXY_H_ | |
6 #define PPAPI_PPB_URL_LOADER_PROXY_H_ | |
7 | |
8 #include "ppapi/c/pp_completion_callback.h" | |
9 #include "ppapi/c/pp_instance.h" | |
10 #include "ppapi/c/pp_module.h" | |
11 #include "ppapi/c/pp_resource.h" | |
12 #include "ppapi/c/pp_size.h" | |
13 #include "ppapi/c/pp_var.h" | |
14 #include "ppapi/c/ppb_url_loader.h" | |
15 #include "ppapi/c/trusted/ppb_url_loader_trusted.h" | |
16 #include "ppapi/proxy/interface_proxy.h" | |
17 #include "ppapi/proxy/proxy_completion_callback_factory.h" | |
18 #include "ppapi/shared_impl/host_resource.h" | |
19 #include "ppapi/utility/completion_callback_factory.h" | |
20 | |
21 namespace ppapi { | |
22 | |
23 struct URLRequestInfoData; | |
24 struct URLResponseInfoData; | |
25 | |
26 namespace proxy { | |
27 | |
28 struct PPBURLLoader_UpdateProgress_Params; | |
29 | |
30 class PPB_URLLoader_Proxy : public InterfaceProxy { | |
31 public: | |
32 PPB_URLLoader_Proxy(Dispatcher* dispatcher); | |
33 virtual ~PPB_URLLoader_Proxy(); | |
34 | |
35 static const Info* GetTrustedInfo(); | |
36 | |
37 static PP_Resource CreateProxyResource(PP_Instance instance); | |
38 | |
39 // URLLoader objects are normally allocated by the Create function, but | |
40 // they are also provided to PPP_Instance.OnMsgHandleDocumentLoad. This | |
41 // function allows the proxy for DocumentLoad to create the correct plugin | |
42 // proxied info for the given browser-supplied URLLoader resource ID. | |
43 static PP_Resource TrackPluginResource( | |
44 const HostResource& url_loader_resource); | |
45 | |
46 // InterfaceProxy implementation. | |
47 virtual bool OnMessageReceived(const IPC::Message& msg); | |
48 | |
49 // URLLoader objects are sent from places other than just URLLoader.Create, | |
50 // in particular when doing a full-frame plugin. This function does the | |
51 // necessary setup in the host before the resource is sent. Call this any | |
52 // time you're sending a new URLLoader that the plugin hasn't seen yet. | |
53 void PrepareURLLoaderForSendingToPlugin(PP_Resource resource); | |
54 | |
55 static const ApiID kApiID = API_ID_PPB_URL_LOADER; | |
56 | |
57 private: | |
58 // Plugin->renderer message handlers. | |
59 void OnMsgCreate(PP_Instance instance, | |
60 HostResource* result); | |
61 void OnMsgOpen(const HostResource& loader, | |
62 const URLRequestInfoData& data); | |
63 void OnMsgFollowRedirect(const HostResource& loader); | |
64 void OnMsgGetResponseInfo(const HostResource& loader, | |
65 bool* success, | |
66 URLResponseInfoData* result); | |
67 void OnMsgReadResponseBody(const HostResource& loader, | |
68 int32_t bytes_to_read); | |
69 void OnMsgFinishStreamingToFile(const HostResource& loader); | |
70 void OnMsgClose(const HostResource& loader); | |
71 void OnMsgGrantUniversalAccess(const HostResource& loader); | |
72 | |
73 // Renderer->plugin message handlers. | |
74 void OnMsgUpdateProgress( | |
75 const PPBURLLoader_UpdateProgress_Params& params); | |
76 void OnMsgReadResponseBodyAck(const IPC::Message& message); | |
77 void OnMsgCallbackComplete(const HostResource& host_resource, int32_t result); | |
78 | |
79 // Handles callbacks for read complete messages. Takes ownership of the | |
80 // message pointer. | |
81 void OnReadCallback(int32_t result, IPC::Message* message); | |
82 | |
83 // Handles callback for everything but reads. | |
84 void OnCallback(int32_t result, const HostResource& resource); | |
85 | |
86 ProxyCompletionCallbackFactory<PPB_URLLoader_Proxy> callback_factory_; | |
87 }; | |
88 | |
89 } // namespace proxy | |
90 } // namespace ppapi | |
91 | |
92 #endif // PPAPI_PPB_URL_LOADER_PROXY_H_ | |
OLD | NEW |