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..882a21c59063b8fc12dc8250f5b882f27d0d3e5c 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,23 @@ 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, |
+ ppapi::FileRefDetailedInfo file_info, |
yzshen1
2013/08/08 23:16:21
const &?
teravest
2013/08/09 02:00:08
Done.
|
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); |
- |
base::FilePath platform_path; |
- switch (file_ref->GetFileSystemType()) { |
+ switch (file_info.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(file_info.file_system_url_spec), &platform_path)); |
break; |
case PP_FILESYSTEMTYPE_EXTERNAL: |
- platform_path = file_ref->GetSystemPath(); |
+ platform_path = file_info.external_path; |
break; |
default: |
NOTREACHED(); |
@@ -94,33 +87,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(); |
@@ -145,19 +121,41 @@ bool CreateWebURLRequest(::ppapi::URLRequestInfoData* data, |
} |
} |
+ // Get file information for FileRefs inside BodyItems. |
+ std::vector<PP_Resource> resources; |
+ for (size_t i = 0; i < data->body.size(); ++i) { |
+ const URLRequestInfoData::BodyItem& item = data->body[i]; |
+ if (item.is_file) |
+ resources.push_back(item.file_ref_pp_resource); |
+ } |
+ std::vector<ppapi::FileRefDetailedInfo> infos; |
+ if (!resources.empty()) { |
+ 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)); |
yzshen1
2013/08/08 23:16:21
What does rounting ID 0 mean here?
teravest
2013/08/09 02:00:08
Added a comment.
|
+ } |
+ |
+ |
// Append the upload data. |
if (!data->body.empty()) { |
WebHTTPBody http_body; |
http_body.initialize(); |
+ int file_index = 0; |
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 (item.file_ref_pp_resource != infos[file_index].resource) |
+ return false; |
yzshen1
2013/08/08 23:16:21
- What if line 136 failed and |infos| is an empty
teravest
2013/08/09 02:00:08
Thanks, now I check that the sizes of infos and re
|
+ if (!AppendFileRefToBody(infos[file_index], |
item.start_offset, |
item.number_of_bytes, |
item.expected_last_modified_time, |
&http_body)) |
return false; |
+ file_index++; |
} else { |
DCHECK(!item.data.empty()); |
http_body.appendData(WebData(item.data)); |