OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "ppapi/proxy/ppb_url_request_info_proxy.h" | 5 #include "ppapi/proxy/ppb_url_request_info_proxy.h" |
6 | 6 |
7 #include "ppapi/c/dev/ppb_url_request_info_dev.h" | 7 #include "ppapi/c/dev/ppb_url_request_info_dev.h" |
8 #include "ppapi/proxy/plugin_dispatcher.h" | 8 #include "ppapi/proxy/plugin_dispatcher.h" |
9 #include "ppapi/proxy/plugin_resource.h" | 9 #include "ppapi/proxy/plugin_resource.h" |
10 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBURLRequestInfo_Create( | 31 PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBURLRequestInfo_Create( |
32 INTERFACE_ID_PPB_URL_REQUEST_INFO, module_id, &result)); | 32 INTERFACE_ID_PPB_URL_REQUEST_INFO, module_id, &result)); |
33 if (result) { | 33 if (result) { |
34 linked_ptr<URLRequestInfo> object(new URLRequestInfo); | 34 linked_ptr<URLRequestInfo> object(new URLRequestInfo); |
35 PluginDispatcher::Get()->plugin_resource_tracker()->AddResource( | 35 PluginDispatcher::Get()->plugin_resource_tracker()->AddResource( |
36 result, object); | 36 result, object); |
37 } | 37 } |
38 return result; | 38 return result; |
39 } | 39 } |
40 | 40 |
41 bool IsURLRequestInfo(PP_Resource resource) { | 41 PP_Bool IsURLRequestInfo(PP_Resource resource) { |
42 URLRequestInfo* object = PluginResource::GetAs<URLRequestInfo>(resource); | 42 URLRequestInfo* object = PluginResource::GetAs<URLRequestInfo>(resource); |
43 return !!object; | 43 return BoolToPPBool(!!object); |
44 } | 44 } |
45 | 45 |
46 bool SetProperty(PP_Resource request_id, | 46 PP_Bool SetProperty(PP_Resource request_id, |
47 PP_URLRequestProperty_Dev property, | 47 PP_URLRequestProperty_Dev property, |
48 PP_Var var) { | 48 PP_Var var) { |
49 Dispatcher* dispatcher = PluginDispatcher::Get(); | 49 Dispatcher* dispatcher = PluginDispatcher::Get(); |
50 dispatcher->Send(new PpapiHostMsg_PPBURLRequestInfo_SetProperty( | 50 dispatcher->Send(new PpapiHostMsg_PPBURLRequestInfo_SetProperty( |
51 INTERFACE_ID_PPB_URL_REQUEST_INFO, request_id, | 51 INTERFACE_ID_PPB_URL_REQUEST_INFO, request_id, |
52 static_cast<int32_t>(property), | 52 static_cast<int32_t>(property), |
53 SerializedVarSendInput(dispatcher, var))); | 53 SerializedVarSendInput(dispatcher, var))); |
54 | 54 |
55 // TODO(brettw) do some validation on the types. We should be able to tell on | 55 // TODO(brettw) do some validation on the types. We should be able to tell on |
56 // the plugin side whether the request will succeed or fail in the renderer. | 56 // the plugin side whether the request will succeed or fail in the renderer. |
57 return true; | 57 return PP_TRUE; |
58 } | 58 } |
59 | 59 |
60 bool AppendDataToBody(PP_Resource request_id, const char* data, uint32_t len) { | 60 PP_Bool AppendDataToBody(PP_Resource request_id, |
| 61 const char* data, uint32_t len) { |
61 PluginDispatcher::Get()->Send( | 62 PluginDispatcher::Get()->Send( |
62 new PpapiHostMsg_PPBURLRequestInfo_AppendDataToBody( | 63 new PpapiHostMsg_PPBURLRequestInfo_AppendDataToBody( |
63 INTERFACE_ID_PPB_URL_REQUEST_INFO, request_id, | 64 INTERFACE_ID_PPB_URL_REQUEST_INFO, request_id, |
64 std::string(data, len))); | 65 std::string(data, len))); |
65 | 66 |
66 // TODO(brettw) do some validation. We should be able to tell on the plugin | 67 // TODO(brettw) do some validation. We should be able to tell on the plugin |
67 // side whether the request will succeed or fail in the renderer. | 68 // side whether the request will succeed or fail in the renderer. |
68 return true; | 69 return PP_TRUE; |
69 } | 70 } |
70 | 71 |
71 bool AppendFileToBody(PP_Resource request_id, | 72 PP_Bool AppendFileToBody(PP_Resource request_id, |
72 PP_Resource file_ref_id, | 73 PP_Resource file_ref_id, |
73 int64_t start_offset, | 74 int64_t start_offset, |
74 int64_t number_of_bytes, | 75 int64_t number_of_bytes, |
75 PP_Time expected_last_modified_time) { | 76 PP_Time expected_last_modified_time) { |
76 PluginDispatcher::Get()->Send( | 77 PluginDispatcher::Get()->Send( |
77 new PpapiHostMsg_PPBURLRequestInfo_AppendFileToBody( | 78 new PpapiHostMsg_PPBURLRequestInfo_AppendFileToBody( |
78 INTERFACE_ID_PPB_URL_REQUEST_INFO, request_id, file_ref_id, | 79 INTERFACE_ID_PPB_URL_REQUEST_INFO, request_id, file_ref_id, |
79 start_offset, number_of_bytes, expected_last_modified_time)); | 80 start_offset, number_of_bytes, expected_last_modified_time)); |
80 | 81 |
81 // TODO(brettw) do some validation. We should be able to tell on the plugin | 82 // TODO(brettw) do some validation. We should be able to tell on the plugin |
82 // side whether the request will succeed or fail in the renderer. | 83 // side whether the request will succeed or fail in the renderer. |
83 return true; | 84 return PP_TRUE; |
84 } | 85 } |
85 | 86 |
86 const PPB_URLRequestInfo_Dev ppb_urlrequestinfo = { | 87 const PPB_URLRequestInfo_Dev ppb_urlrequestinfo = { |
87 &Create, | 88 &Create, |
88 &IsURLRequestInfo, | 89 &IsURLRequestInfo, |
89 &SetProperty, | 90 &SetProperty, |
90 &AppendDataToBody, | 91 &AppendDataToBody, |
91 &AppendFileToBody | 92 &AppendFileToBody |
92 }; | 93 }; |
93 | 94 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 int64_t start_offset, | 152 int64_t start_offset, |
152 int64_t number_of_bytes, | 153 int64_t number_of_bytes, |
153 double expected_last_modified_time) { | 154 double expected_last_modified_time) { |
154 ppb_url_request_info_target()->AppendFileToBody( | 155 ppb_url_request_info_target()->AppendFileToBody( |
155 request, file_ref, start_offset, number_of_bytes, | 156 request, file_ref, start_offset, number_of_bytes, |
156 expected_last_modified_time); | 157 expected_last_modified_time); |
157 } | 158 } |
158 | 159 |
159 } // namespace proxy | 160 } // namespace proxy |
160 } // namespace pp | 161 } // namespace pp |
OLD | NEW |