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..2410e11bd50099f10f6ef739d3f72c33852273a3 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 enable_validation_caching, |
IPC::Message* reply_msg) { |
DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
@@ -138,16 +139,31 @@ 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))); |
+ // Opening a NaCl executable works with or without validation caching. |
+ // Validation caching requires that the file descriptor is registered now |
+ // for later use, which will save time. |
+ // When validation caching isn't used (e.g. Non-SFI mode), there is no |
+ // reason to do that unnecessary registration. |
+ if (enable_validation_caching) { |
+ // 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 +227,7 @@ void OpenNaClExecutable( |
scoped_refptr<nacl::NaClHostMessageFilter> nacl_host_message_filter, |
int render_view_id, |
const GURL& file_url, |
+ bool enable_validation_caching, |
IPC::Message* reply_msg) { |
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
BrowserThread::PostTask( |
@@ -218,7 +235,10 @@ void OpenNaClExecutable( |
base::Bind( |
&OpenNaClExecutable, |
nacl_host_message_filter, |
- render_view_id, file_url, reply_msg)); |
+ render_view_id, |
+ file_url, |
+ enable_validation_caching, |
+ reply_msg)); |
return; |
} |
@@ -247,7 +267,9 @@ void OpenNaClExecutable( |
base::Bind( |
&DoOpenNaClExecutableOnThreadPool, |
nacl_host_message_filter, |
- file_url, reply_msg))) { |
+ file_url, |
+ enable_validation_caching, |
+ reply_msg))) { |
NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg); |
} |
} |