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" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 static const Info* GetTrustedInfo(); | 35 static const Info* GetTrustedInfo(); |
36 | 36 |
37 static PP_Resource CreateProxyResource(PP_Instance instance); | 37 static PP_Resource CreateProxyResource(PP_Instance instance); |
38 | 38 |
39 // URLLoader objects are normally allocated by the Create function, but | 39 // URLLoader objects are normally allocated by the Create function, but |
40 // they are also provided to PPP_Instance.OnMsgHandleDocumentLoad. This | 40 // they are also provided to PPP_Instance.OnMsgHandleDocumentLoad. This |
41 // function allows the proxy for DocumentLoad to create the correct plugin | 41 // function allows the proxy for DocumentLoad to create the correct plugin |
42 // proxied info for the given browser-supplied URLLoader resource ID. | 42 // proxied info for the given browser-supplied URLLoader resource ID. |
43 static PP_Resource TrackPluginResource( | 43 static PP_Resource TrackPluginResource( |
44 const HostResource& url_loader_resource); | 44 const ppapi::HostResource& url_loader_resource); |
45 | 45 |
46 // InterfaceProxy implementation. | 46 // InterfaceProxy implementation. |
47 virtual bool OnMessageReceived(const IPC::Message& msg); | 47 virtual bool OnMessageReceived(const IPC::Message& msg); |
48 | 48 |
49 // URLLoader objects are sent from places other than just URLLoader.Create, | 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 | 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 | 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. | 52 // time you're sending a new URLLoader that the plugin hasn't seen yet. |
53 void PrepareURLLoaderForSendingToPlugin(PP_Resource resource); | 53 void PrepareURLLoaderForSendingToPlugin(PP_Resource resource); |
54 | 54 |
55 static const ApiID kApiID = API_ID_PPB_URL_LOADER; | 55 static const ApiID kApiID = API_ID_PPB_URL_LOADER; |
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 PPB_URLRequestInfo_Data& data); | 65 const PPB_URLRequestInfo_Data& data, |
66 void OnMsgFollowRedirect(const HostResource& loader); | 66 uint32_t serialized_callback); |
67 void OnMsgGetResponseInfo(const HostResource& loader, | 67 void OnMsgFollowRedirect(const ppapi::HostResource& loader, |
68 HostResource* result); | 68 uint32_t serialized_callback); |
69 void OnMsgReadResponseBody(const HostResource& loader, | 69 void OnMsgGetResponseInfo(const ppapi::HostResource& loader, |
| 70 ppapi::HostResource* result); |
| 71 void OnMsgReadResponseBody(const ppapi::HostResource& loader, |
70 int32_t bytes_to_read); | 72 int32_t bytes_to_read); |
71 void OnMsgFinishStreamingToFile(const HostResource& loader); | 73 void OnMsgFinishStreamingToFile(const ppapi::HostResource& loader, |
72 void OnMsgClose(const HostResource& loader); | 74 uint32_t serialized_callback); |
73 void OnMsgGrantUniversalAccess(const HostResource& loader); | 75 void OnMsgClose(const ppapi::HostResource& loader); |
| 76 void OnMsgGrantUniversalAccess(const ppapi::HostResource& loader); |
74 | 77 |
75 // Renderer->plugin message handlers. | 78 // Renderer->plugin message handlers. |
76 void OnMsgUpdateProgress( | 79 void OnMsgUpdateProgress( |
77 const PPBURLLoader_UpdateProgress_Params& params); | 80 const PPBURLLoader_UpdateProgress_Params& params); |
78 void OnMsgReadResponseBodyAck(const HostResource& host_resource, | 81 void OnMsgReadResponseBodyAck(const ppapi::HostResource& pp_resource, |
79 int32_t result, | 82 int32_t result, |
80 const std::string& data); | 83 const std::string& data); |
81 void OnMsgCallbackComplete(const HostResource& host_resource, int32_t result); | |
82 | 84 |
83 // Handles callbacks for read complete messages. Takes ownership of the info | 85 // Handles callbacks for read complete messages. Takes ownership of the info |
84 // pointer. | 86 // pointer. |
85 void OnReadCallback(int32_t result, ReadCallbackInfo* info); | 87 void OnReadCallback(int32_t result, ReadCallbackInfo* info); |
86 | 88 |
87 // Handles callback for everything but reads. | |
88 void OnCallback(int32_t result, const HostResource& resource); | |
89 | |
90 pp::CompletionCallbackFactory<PPB_URLLoader_Proxy, | 89 pp::CompletionCallbackFactory<PPB_URLLoader_Proxy, |
91 ProxyNonThreadSafeRefCount> callback_factory_; | 90 ProxyNonThreadSafeRefCount> callback_factory_; |
92 | 91 |
93 // Valid only in the host, this lazily-initialized pointer indicates the | 92 // Valid only in the host, this lazily-initialized pointer indicates the |
94 // URLLoaderTrusted interface. | 93 // URLLoaderTrusted interface. |
95 const PPB_URLLoaderTrusted* host_urlloader_trusted_interface_; | 94 const PPB_URLLoaderTrusted* host_urlloader_trusted_interface_; |
96 }; | 95 }; |
97 | 96 |
98 } // namespace proxy | 97 } // namespace proxy |
99 } // namespace ppapi | 98 } // namespace ppapi |
100 | 99 |
101 #endif // PPAPI_PPB_URL_LOADER_PROXY_H_ | 100 #endif // PPAPI_PPB_URL_LOADER_PROXY_H_ |
OLD | NEW |