| 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/ppb_url_request_info.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" |
| 11 | 11 |
| 12 namespace pp { | 12 namespace pp { |
| 13 namespace proxy { | 13 namespace proxy { |
| 14 | 14 |
| 15 class URLRequestInfo : public PluginResource { | 15 class URLRequestInfo : public PluginResource { |
| 16 public: | 16 public: |
| 17 URLRequestInfo() {} | 17 URLRequestInfo() {} |
| (...skipping 19 matching lines...) Expand all Loading... |
| 37 } | 37 } |
| 38 return result; | 38 return result; |
| 39 } | 39 } |
| 40 | 40 |
| 41 PP_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 BoolToPPBool(!!object); | 43 return BoolToPPBool(!!object); |
| 44 } | 44 } |
| 45 | 45 |
| 46 PP_Bool SetProperty(PP_Resource request_id, | 46 PP_Bool SetProperty(PP_Resource request_id, |
| 47 PP_URLRequestProperty_Dev property, | 47 PP_URLRequestProperty 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 PP_TRUE; | 57 return PP_TRUE; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 77 PluginDispatcher::Get()->Send( | 77 PluginDispatcher::Get()->Send( |
| 78 new PpapiHostMsg_PPBURLRequestInfo_AppendFileToBody( | 78 new PpapiHostMsg_PPBURLRequestInfo_AppendFileToBody( |
| 79 INTERFACE_ID_PPB_URL_REQUEST_INFO, request_id, file_ref_id, | 79 INTERFACE_ID_PPB_URL_REQUEST_INFO, request_id, file_ref_id, |
| 80 start_offset, number_of_bytes, expected_last_modified_time)); | 80 start_offset, number_of_bytes, expected_last_modified_time)); |
| 81 | 81 |
| 82 // 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 |
| 83 // side whether the request will succeed or fail in the renderer. | 83 // side whether the request will succeed or fail in the renderer. |
| 84 return PP_TRUE; | 84 return PP_TRUE; |
| 85 } | 85 } |
| 86 | 86 |
| 87 const PPB_URLRequestInfo_Dev ppb_urlrequestinfo = { | 87 const PPB_URLRequestInfo ppb_urlrequestinfo = { |
| 88 &Create, | 88 &Create, |
| 89 &IsURLRequestInfo, | 89 &IsURLRequestInfo, |
| 90 &SetProperty, | 90 &SetProperty, |
| 91 &AppendDataToBody, | 91 &AppendDataToBody, |
| 92 &AppendFileToBody | 92 &AppendFileToBody |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 } // namespace | 95 } // namespace |
| 96 | 96 |
| 97 PPB_URLRequestInfo_Proxy::PPB_URLRequestInfo_Proxy( | 97 PPB_URLRequestInfo_Proxy::PPB_URLRequestInfo_Proxy( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 128 PP_Module module, | 128 PP_Module module, |
| 129 PP_Resource* result) { | 129 PP_Resource* result) { |
| 130 *result = ppb_url_request_info_target()->Create(module); | 130 *result = ppb_url_request_info_target()->Create(module); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void PPB_URLRequestInfo_Proxy::OnMsgSetProperty( | 133 void PPB_URLRequestInfo_Proxy::OnMsgSetProperty( |
| 134 PP_Resource request, | 134 PP_Resource request, |
| 135 int32_t property, | 135 int32_t property, |
| 136 SerializedVarReceiveInput value) { | 136 SerializedVarReceiveInput value) { |
| 137 ppb_url_request_info_target()->SetProperty(request, | 137 ppb_url_request_info_target()->SetProperty(request, |
| 138 static_cast<PP_URLRequestProperty_Dev>(property), | 138 static_cast<PP_URLRequestProperty>(property), |
| 139 value.Get(dispatcher())); | 139 value.Get(dispatcher())); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void PPB_URLRequestInfo_Proxy::OnMsgAppendDataToBody( | 142 void PPB_URLRequestInfo_Proxy::OnMsgAppendDataToBody( |
| 143 PP_Resource request, | 143 PP_Resource request, |
| 144 const std::string& data) { | 144 const std::string& data) { |
| 145 ppb_url_request_info_target()->AppendDataToBody(request, data.c_str(), | 145 ppb_url_request_info_target()->AppendDataToBody(request, data.c_str(), |
| 146 data.size()); | 146 data.size()); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void PPB_URLRequestInfo_Proxy::OnMsgAppendFileToBody( | 149 void PPB_URLRequestInfo_Proxy::OnMsgAppendFileToBody( |
| 150 PP_Resource request, | 150 PP_Resource request, |
| 151 PP_Resource file_ref, | 151 PP_Resource file_ref, |
| 152 int64_t start_offset, | 152 int64_t start_offset, |
| 153 int64_t number_of_bytes, | 153 int64_t number_of_bytes, |
| 154 double expected_last_modified_time) { | 154 double expected_last_modified_time) { |
| 155 ppb_url_request_info_target()->AppendFileToBody( | 155 ppb_url_request_info_target()->AppendFileToBody( |
| 156 request, file_ref, start_offset, number_of_bytes, | 156 request, file_ref, start_offset, number_of_bytes, |
| 157 expected_last_modified_time); | 157 expected_last_modified_time); |
| 158 } | 158 } |
| 159 | 159 |
| 160 } // namespace proxy | 160 } // namespace proxy |
| 161 } // namespace pp | 161 } // namespace pp |
| OLD | NEW |