| Index: components/nacl/browser/nacl_host_message_filter.cc
|
| diff --git a/components/nacl/browser/nacl_host_message_filter.cc b/components/nacl/browser/nacl_host_message_filter.cc
|
| index 9da3fe51726b73a3082b190a47e3cf2ddb617f2f..3df436a9505e25c4a2c3c412e5c8f88ae04cac44 100644
|
| --- a/components/nacl/browser/nacl_host_message_filter.cc
|
| +++ b/components/nacl/browser/nacl_host_message_filter.cc
|
| @@ -25,17 +25,6 @@ namespace nacl {
|
|
|
| namespace {
|
|
|
| -// The maximum number of resource file handles NaClProcessMsg_Start message
|
| -// can have. Currently IPC::MessageAttachmentSet::kMaxDescriptorsPerMessage
|
| -// is 128 and NaCl sends 5 handles for other purposes, hence 123.
|
| -const size_t kMaxPreOpenResourceFiles = 123;
|
| -
|
| -#if defined(OS_POSIX)
|
| -static_assert(kMaxPreOpenResourceFiles ==
|
| - IPC::MessageAttachmentSet::kMaxDescriptorsPerMessage - 5,
|
| - "kMaxPreOpenResourceFiles is not up to date");
|
| -#endif
|
| -
|
| ppapi::PpapiPermissions GetNaClPermissions(
|
| uint32 permission_bits,
|
| content::BrowserContext* browser_context,
|
| @@ -137,20 +126,19 @@ void NaClHostMessageFilter::OnLaunchNaCl(
|
| LaunchNaClContinuationOnIOThread(
|
| launch_params,
|
| reply_msg,
|
| - std::vector<nacl::NaClResourceFileInfo>(),
|
| ppapi::PpapiPermissions(perms));
|
| return;
|
| }
|
| content::BrowserThread::PostTask(
|
| content::BrowserThread::UI,
|
| FROM_HERE,
|
| - base::Bind(&NaClHostMessageFilter::LaunchNaClContinuation,
|
| + base::Bind(&NaClHostMessageFilter::LaunchNaClContinuationOnUIThread,
|
| this,
|
| launch_params,
|
| reply_msg));
|
| }
|
|
|
| -void NaClHostMessageFilter::LaunchNaClContinuation(
|
| +void NaClHostMessageFilter::LaunchNaClContinuationOnUIThread(
|
| const nacl::NaClLaunchParams& launch_params,
|
| IPC::Message* reply_msg) {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| @@ -168,11 +156,13 @@ void NaClHostMessageFilter::LaunchNaClContinuation(
|
| }
|
|
|
| nacl::NaClLaunchParams safe_launch_params(launch_params);
|
| - safe_launch_params.resource_files_to_prefetch.clear();
|
| + safe_launch_params.resource_prefetch_info_list.clear();
|
|
|
| content::SiteInstance* site_instance = rvh->GetSiteInstance();
|
| - for (size_t i = 0; i < launch_params.resource_files_to_prefetch.size(); ++i) {
|
| - GURL gurl(launch_params.resource_files_to_prefetch[i].second);
|
| + for (size_t i = 0;
|
| + i < launch_params.resource_prefetch_info_list.size();
|
| + ++i) {
|
| + GURL gurl(launch_params.resource_prefetch_info_list[i].resource_url);
|
| // Important security check: Do the same check as OpenNaClExecutable()
|
| // in nacl_file_host.cc.
|
| if (!content::SiteInstance::IsSameWebSite(
|
| @@ -181,50 +171,8 @@ void NaClHostMessageFilter::LaunchNaClContinuation(
|
| gurl)) {
|
| continue;
|
| }
|
| - safe_launch_params.resource_files_to_prefetch.push_back(
|
| - launch_params.resource_files_to_prefetch[i]);
|
| - }
|
| -
|
| - // Process a list of resource file URLs in
|
| - // |launch_params.resource_files_to_prefetch|.
|
| - content::BrowserThread::PostBlockingPoolTask(
|
| - FROM_HERE,
|
| - base::Bind(&NaClHostMessageFilter::BatchOpenResourceFiles,
|
| - this,
|
| - safe_launch_params,
|
| - reply_msg,
|
| - permissions));
|
| -}
|
| -
|
| -void NaClHostMessageFilter::BatchOpenResourceFiles(
|
| - const nacl::NaClLaunchParams& launch_params,
|
| - IPC::Message* reply_msg,
|
| - ppapi::PpapiPermissions permissions) {
|
| - std::vector<nacl::NaClResourceFileInfo> prefetched_resource_files_info;
|
| - for (size_t i = 0; i < launch_params.resource_files_to_prefetch.size(); ++i) {
|
| - nacl::NaClResourceFileInfo prefetched_resource_file;
|
| - GURL gurl(launch_params.resource_files_to_prefetch[i].second);
|
| - if (!nacl::NaClBrowser::GetDelegate()->MapUrlToLocalFilePath(
|
| - gurl,
|
| - true, // use_blocking_api
|
| - profile_directory_,
|
| - &prefetched_resource_file.file_path_metadata)) {
|
| - continue;
|
| - }
|
| - base::File file = nacl::OpenNaClReadExecImpl(
|
| - prefetched_resource_file.file_path_metadata,
|
| - true /* is_executable */);
|
| - if (!file.IsValid())
|
| - continue;
|
| -
|
| - prefetched_resource_file.file =
|
| - IPC::TakeFileHandleForProcess(file.Pass(), PeerHandle());
|
| - prefetched_resource_file.file_key =
|
| - launch_params.resource_files_to_prefetch[i].first;
|
| -
|
| - prefetched_resource_files_info.push_back(prefetched_resource_file);
|
| - if (prefetched_resource_files_info.size() >= kMaxPreOpenResourceFiles)
|
| - break;
|
| + safe_launch_params.resource_prefetch_info_list.push_back(
|
| + launch_params.resource_prefetch_info_list[i]);
|
| }
|
|
|
| content::BrowserThread::PostTask(
|
| @@ -232,17 +180,14 @@ void NaClHostMessageFilter::BatchOpenResourceFiles(
|
| FROM_HERE,
|
| base::Bind(&NaClHostMessageFilter::LaunchNaClContinuationOnIOThread,
|
| this,
|
| - launch_params,
|
| + safe_launch_params,
|
| reply_msg,
|
| - prefetched_resource_files_info,
|
| permissions));
|
| }
|
|
|
| void NaClHostMessageFilter::LaunchNaClContinuationOnIOThread(
|
| const nacl::NaClLaunchParams& launch_params,
|
| IPC::Message* reply_msg,
|
| - const std::vector<
|
| - nacl::NaClResourceFileInfo>& prefetched_resource_files_info,
|
| ppapi::PpapiPermissions permissions) {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
|
|
| @@ -273,14 +218,14 @@ void NaClHostMessageFilter::LaunchNaClContinuationOnIOThread(
|
| nexe_file =
|
| IPC::PlatformFileForTransitToPlatformFile(launch_params.nexe_file);
|
| #else
|
| -#error Unsupported platform.
|
| +# error Unsupported platform.
|
| #endif
|
|
|
| NaClProcessHost* host = new NaClProcessHost(
|
| GURL(launch_params.manifest_url),
|
| base::File(nexe_file),
|
| nexe_token,
|
| - prefetched_resource_files_info,
|
| + launch_params.resource_prefetch_info_list,
|
| permissions,
|
| launch_params.render_view_id,
|
| launch_params.permission_bits,
|
|
|