Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(894)

Unified Diff: components/nacl/browser/nacl_host_message_filter.cc

Issue 1117883002: Reduce resource leak code for StartNaClExecution. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/nacl/browser/nacl_host_message_filter.h ('k') | components/nacl/browser/nacl_process_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8ebfed40115abf896cf2b98e6b50ccfa1f22ff6c..5e3570a51d3d4b81f8789e6fef0a7df0610d8d37 100644
--- a/components/nacl/browser/nacl_host_message_filter.cc
+++ b/components/nacl/browser/nacl_host_message_filter.cc
@@ -24,11 +24,6 @@ namespace nacl {
namespace {
-// The maximum number of resource file handles the browser process accepts. Use
-// 200 because ARC's nmf has ~128 resource files as of May 2015. This prevents
-// untrusted code filling the FD/handle table.
-const size_t kMaxPreOpenResourceFiles = 200;
-
ppapi::PpapiPermissions GetNaClPermissions(
uint32 permission_bits,
content::BrowserContext* browser_context,
@@ -130,20 +125,19 @@ void NaClHostMessageFilter::OnLaunchNaCl(
LaunchNaClContinuationOnIOThread(
launch_params,
reply_msg,
- std::vector<NaClResourcePrefetchResult>(),
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);
@@ -163,9 +157,6 @@ void NaClHostMessageFilter::LaunchNaClContinuation(
nacl::NaClLaunchParams safe_launch_params(launch_params);
safe_launch_params.resource_prefetch_request_list.clear();
- // TODO(yusukes): Fix NaClProcessHost::~NaClProcessHost() and remove the
- // ifdef.
-#if !defined(OS_WIN)
const std::vector<NaClResourcePrefetchRequest>& original_request_list =
launch_params.resource_prefetch_request_list;
content::SiteInstance* site_instance = rvh->GetSiteInstance();
@@ -182,65 +173,20 @@ void NaClHostMessageFilter::LaunchNaClContinuation(
safe_launch_params.resource_prefetch_request_list.push_back(
original_request_list[i]);
}
-#endif
-
- // 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<NaClResourcePrefetchResult> prefetched_resource_files;
- const std::vector<NaClResourcePrefetchRequest>& request_list =
- launch_params.resource_prefetch_request_list;
- for (size_t i = 0; i < request_list.size(); ++i) {
- GURL gurl(request_list[i].resource_url);
- base::FilePath file_path_metadata;
- if (!nacl::NaClBrowser::GetDelegate()->MapUrlToLocalFilePath(
- gurl,
- true, // use_blocking_api
- profile_directory_,
- &file_path_metadata)) {
- continue;
- }
- base::File file = nacl::OpenNaClReadExecImpl(
- file_path_metadata, true /* is_executable */);
- if (!file.IsValid())
- continue;
-
- prefetched_resource_files.push_back(NaClResourcePrefetchResult(
- IPC::TakeFileHandleForProcess(file.Pass(), PeerHandle()),
- file_path_metadata,
- request_list[i].file_key));
-
- if (prefetched_resource_files.size() >= kMaxPreOpenResourceFiles)
- break;
- }
content::BrowserThread::PostTask(
content::BrowserThread::IO,
FROM_HERE,
base::Bind(&NaClHostMessageFilter::LaunchNaClContinuationOnIOThread,
this,
- launch_params,
+ safe_launch_params,
reply_msg,
- prefetched_resource_files,
permissions));
}
void NaClHostMessageFilter::LaunchNaClContinuationOnIOThread(
const nacl::NaClLaunchParams& launch_params,
IPC::Message* reply_msg,
- const std::vector<NaClResourcePrefetchResult>& prefetched_resource_files,
ppapi::PpapiPermissions permissions) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
@@ -278,7 +224,7 @@ void NaClHostMessageFilter::LaunchNaClContinuationOnIOThread(
GURL(launch_params.manifest_url),
base::File(nexe_file),
nexe_token,
- prefetched_resource_files,
+ launch_params.resource_prefetch_request_list,
permissions,
launch_params.render_view_id,
launch_params.permission_bits,
« no previous file with comments | « components/nacl/browser/nacl_host_message_filter.h ('k') | components/nacl/browser/nacl_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698