Index: components/nacl/browser/nacl_file_host.cc |
diff --git a/components/nacl/browser/nacl_file_host.cc b/components/nacl/browser/nacl_file_host.cc |
index 17e5bc5ea4208b7df545403d7b6110361051c842..24873b0232b412a8e77316a8ab5cf7ccc5fcfd3a 100644 |
--- a/components/nacl/browser/nacl_file_host.cc |
+++ b/components/nacl/browser/nacl_file_host.cc |
@@ -122,6 +122,7 @@ void DoOpenPnaclFile( |
void DoOpenNaClExecutableOnThreadPool( |
scoped_refptr<nacl::NaClHostMessageFilter> nacl_host_message_filter, |
const GURL& file_url, |
+ bool register_executable, |
Mark Seaborn
2015/01/12 21:59:35
How about calling this something like "enable_vali
teravest
2015/01/13 16:47:34
Done.
|
IPC::Message* reply_msg) { |
DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
@@ -138,16 +139,26 @@ void DoOpenNaClExecutableOnThreadPool( |
base::File file = nacl::OpenNaClReadExecImpl(file_path, |
true /* is_executable */); |
if (file.IsValid()) { |
- // This function is running on the blocking pool, but the path needs to be |
- // registered in a structure owned by the IO thread. |
- BrowserThread::PostTask( |
- BrowserThread::IO, FROM_HERE, |
- base::Bind( |
- &DoRegisterOpenedNaClExecutableFile, |
- nacl_host_message_filter, |
- Passed(file.Pass()), file_path, reply_msg, |
- static_cast<WriteFileInfoReply>( |
- NaClHostMsg_OpenNaClExecutable::WriteReplyParams))); |
+ if (register_executable) { |
Mark Seaborn
2015/01/12 21:59:34
Can you add a comment to explain that: Both branch
teravest
2015/01/13 16:47:34
Good point. I've added a comment here.
|
+ // This function is running on the blocking pool, but the path needs to be |
+ // registered in a structure owned by the IO thread. |
+ BrowserThread::PostTask( |
+ BrowserThread::IO, FROM_HERE, |
+ base::Bind( |
+ &DoRegisterOpenedNaClExecutableFile, |
+ nacl_host_message_filter, |
+ Passed(file.Pass()), file_path, reply_msg, |
+ static_cast<WriteFileInfoReply>( |
+ NaClHostMsg_OpenNaClExecutable::WriteReplyParams))); |
+ } else { |
+ IPC::PlatformFileForTransit file_desc = |
+ IPC::TakeFileHandleForProcess(file.Pass(), |
+ nacl_host_message_filter->PeerHandle()); |
+ uint64_t dummy_file_token = 0; |
+ NaClHostMsg_OpenNaClExecutable::WriteReplyParams( |
+ reply_msg, file_desc, dummy_file_token, dummy_file_token); |
+ nacl_host_message_filter->Send(reply_msg); |
+ } |
} else { |
NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg); |
return; |
@@ -211,6 +222,7 @@ void OpenNaClExecutable( |
scoped_refptr<nacl::NaClHostMessageFilter> nacl_host_message_filter, |
int render_view_id, |
const GURL& file_url, |
+ bool register_executable, |
IPC::Message* reply_msg) { |
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
BrowserThread::PostTask( |
@@ -218,7 +230,10 @@ void OpenNaClExecutable( |
base::Bind( |
&OpenNaClExecutable, |
nacl_host_message_filter, |
- render_view_id, file_url, reply_msg)); |
+ render_view_id, |
+ file_url, |
+ register_executable, |
+ reply_msg)); |
return; |
} |
@@ -247,7 +262,9 @@ void OpenNaClExecutable( |
base::Bind( |
&DoOpenNaClExecutableOnThreadPool, |
nacl_host_message_filter, |
- file_url, reply_msg))) { |
+ file_url, |
+ register_executable, |
+ reply_msg))) { |
NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg); |
} |
} |