Chromium Code Reviews| Index: content/renderer/pepper/url_request_info_util.cc |
| diff --git a/content/renderer/pepper/url_request_info_util.cc b/content/renderer/pepper/url_request_info_util.cc |
| index 9f13fe0586e27080dd18eb066b3954d89b03eaed..704c8617c3800552ebaad11c399e84d626b597e1 100644 |
| --- a/content/renderer/pepper/url_request_info_util.cc |
| +++ b/content/renderer/pepper/url_request_info_util.cc |
| @@ -8,10 +8,13 @@ |
| #include "base/strings/string_util.h" |
| #include "content/common/fileapi/file_system_messages.h" |
| #include "content/renderer/pepper/common.h" |
| +#include "content/renderer/pepper/host_globals.h" |
| +#include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| #include "content/renderer/pepper/plugin_module.h" |
| -#include "content/renderer/pepper/ppb_file_ref_impl.h" |
| #include "content/renderer/render_thread_impl.h" |
| #include "net/http/http_util.h" |
| +#include "ppapi/proxy/ppapi_messages.h" |
| +#include "ppapi/shared_impl/file_ref_detailed_info.h" |
| #include "ppapi/shared_impl/url_request_info_data.h" |
| #include "ppapi/shared_impl/var.h" |
| #include "ppapi/thunk/enter.h" |
| @@ -28,7 +31,6 @@ |
| using ppapi::URLRequestInfoData; |
| using ppapi::Resource; |
| using ppapi::thunk::EnterResourceNoLock; |
| -using ppapi::thunk::PPB_FileRef_API; |
| using WebKit::WebData; |
| using WebKit::WebHTTPBody; |
| using WebKit::WebString; |
| @@ -43,32 +45,37 @@ namespace { |
| // Appends the file ref given the Resource pointer associated with it to the |
| // given HTTP body, returning true on success. |
| bool AppendFileRefToBody( |
| - Resource* file_ref_resource, |
| + PP_Instance instance, |
| + PP_Resource resource, |
|
dmichael (off chromium)
2013/08/07 22:19:13
s/resouce/file_ref_resource
|
| int64_t start_offset, |
| int64_t number_of_bytes, |
| PP_Time expected_last_modified_time, |
| WebHTTPBody *http_body) { |
| - // Get the underlying file ref impl. |
| - if (!file_ref_resource) |
| - return false; |
| - PPB_FileRef_API* file_ref_api = file_ref_resource->AsPPB_FileRef_API(); |
| - if (!file_ref_api) |
| - return false; |
| - const PPB_FileRef_Impl* file_ref = |
| - static_cast<PPB_FileRef_Impl*>(file_ref_api); |
| + std::vector<PP_Resource> resources; |
| + resources.push_back(resource); |
| + std::vector<ppapi::FileRef_DetailedInfo> infos; |
| + // FIXME(teravest): Pull this sync operation out of the loop and only do it |
| + // once for the vector of FileRefs. |
| base::FilePath platform_path; |
| - switch (file_ref->GetFileSystemType()) { |
| + PepperPluginInstanceImpl* instance_impl = |
| + HostGlobals::Get()->GetInstance(instance); |
| + int child_process_id = instance_impl->module()->GetPluginChildId(); |
| + RenderThreadImpl::current()->Send( |
| + new PpapiHostMsg_FileRef_SyncGetInfoForRenderer( |
| + 0, child_process_id, resources, &infos)); |
| + |
| + switch (infos[0].file_system_type) { |
| case PP_FILESYSTEMTYPE_LOCALTEMPORARY: |
| case PP_FILESYSTEMTYPE_LOCALPERSISTENT: |
| // TODO(kinuko): remove this sync IPC when we fully support |
| // AppendURLRange for FileSystem URL. |
| RenderThreadImpl::current()->Send( |
| new FileSystemHostMsg_SyncGetPlatformPath( |
| - file_ref->GetFileSystemURL(), &platform_path)); |
| + GURL(infos[0].file_system_url_spec), &platform_path)); |
| break; |
| case PP_FILESYSTEMTYPE_EXTERNAL: |
| - platform_path = file_ref->GetSystemPath(); |
| + platform_path = infos[0].external_path; |
| break; |
| default: |
| NOTREACHED(); |
| @@ -94,33 +101,16 @@ bool ValidateURLRequestData(const ::ppapi::URLRequestInfoData& data) { |
| return true; |
| } |
| -// Ensures that the file_ref members of the given request info data are |
| -// populated from the resource IDs. Returns true on success. |
| -bool EnsureFileRefObjectsPopulated(::ppapi::URLRequestInfoData* data) { |
| - // Get the Resource objects for any file refs with only host resource (this |
| - // is the state of the request as it comes off IPC). |
| - for (size_t i = 0; i < data->body.size(); ++i) { |
| - URLRequestInfoData::BodyItem& item = data->body[i]; |
| - if (item.is_file && !item.file_ref.get()) { |
| - EnterResourceNoLock<PPB_FileRef_API> enter( |
| - item.file_ref_host_resource.host_resource(), false); |
| - if (!enter.succeeded()) |
| - return false; |
| - item.file_ref = enter.resource(); |
| - } |
| - } |
| - return true; |
| -} |
| - |
| } // namespace |
| -bool CreateWebURLRequest(::ppapi::URLRequestInfoData* data, |
| +bool CreateWebURLRequest(PP_Instance instance, |
| + ::ppapi::URLRequestInfoData* data, |
| WebFrame* frame, |
| WebURLRequest* dest) { |
| // In the out-of-process case, we've received the URLRequestInfoData |
| // from the untrusted plugin and done no validation on it. We need to be |
| // sure it's not being malicious by checking everything for consistency. |
| - if (!ValidateURLRequestData(*data) || !EnsureFileRefObjectsPopulated(data)) |
| + if (!ValidateURLRequestData(*data)) |
| return false; |
| dest->initialize(); |
| @@ -152,7 +142,8 @@ bool CreateWebURLRequest(::ppapi::URLRequestInfoData* data, |
| for (size_t i = 0; i < data->body.size(); ++i) { |
| const URLRequestInfoData::BodyItem& item = data->body[i]; |
| if (item.is_file) { |
| - if (!AppendFileRefToBody(item.file_ref.get(), |
| + if (!AppendFileRefToBody(instance, |
| + item.file_ref_pp_resource, |
| item.start_offset, |
| item.number_of_bytes, |
| item.expected_last_modified_time, |