Chromium Code Reviews| Index: components/nacl/browser/nacl_process_host.cc |
| diff --git a/components/nacl/browser/nacl_process_host.cc b/components/nacl/browser/nacl_process_host.cc |
| index 33b071f07b1ebfa91b9f301160080bf66f23293f..dd8578c03db019b3b869818022ca8eb4169d64ae 100644 |
| --- a/components/nacl/browser/nacl_process_host.cc |
| +++ b/components/nacl/browser/nacl_process_host.cc |
| @@ -664,6 +664,9 @@ bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) { |
| OnSetKnownToValidate) |
| IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClProcessMsg_ResolveFileToken, |
| OnResolveFileToken) |
| + IPC_MESSAGE_HANDLER(NaClProcessMsg_ResolveFileTokenAsync, |
| + OnResolveFileTokenAsync) |
| + |
| #if defined(OS_WIN) |
| IPC_MESSAGE_HANDLER_DELAY_REPLY( |
| NaClProcessMsg_AttachDebugExceptionHandler, |
| @@ -1048,6 +1051,28 @@ void NaClProcessHost::FileResolved( |
| Send(reply_msg); |
| } |
| +void NaClProcessHost::FileResolvedAsync( |
|
dmichael (off chromium)
2014/08/27 20:49:14
nit: the order here should match the header. Actua
teravest
2014/09/04 22:13:30
Done.
|
| + uint64_t file_token_lo, |
| + uint64_t file_token_hi, |
| + const base::FilePath& file_path, |
| + base::File file) { |
| + base::FilePath out_file_path; |
| + IPC::PlatformFileForTransit out_handle; |
| + if (file.IsValid()) { |
| + out_file_path = file_path; |
| + out_handle = IPC::TakeFileHandleForProcess( |
| + file.Pass(), |
| + process_->GetData().handle); |
| + } else { |
| + out_handle = IPC::InvalidPlatformFileForTransit(); |
| + } |
| + Send(new NaClProcessMsg_ResolveFileTokenAsyncReply( |
| + file_token_lo, |
| + file_token_hi, |
| + out_handle, |
| + out_file_path)); |
|
dmichael (off chromium)
2014/08/27 20:49:14
nit: indent off by one
teravest
2014/09/04 22:13:30
Done.
|
| +} |
| + |
| void NaClProcessHost::OnResolveFileToken(uint64 file_token_lo, |
| uint64 file_token_hi, |
| IPC::Message* reply_msg) { |
| @@ -1103,6 +1128,40 @@ void NaClProcessHost::OnResolveFileToken(uint64 file_token_lo, |
| } |
| } |
| +void NaClProcessHost::OnResolveFileTokenAsync(uint64 file_token_lo, |
| + uint64 file_token_hi) { |
| + // See the comment at OnResolveFileToken() for details of the file path cache |
| + // behavior. |
| + CHECK(!uses_nonsfi_mode_); |
| + base::FilePath file_path; |
| + if (!NaClBrowser::GetInstance()->GetFilePath( |
| + file_token_lo, file_token_hi, &file_path)) { |
| + Send(new NaClProcessMsg_ResolveFileTokenAsyncReply( |
| + file_token_lo, |
| + file_token_hi, |
| + IPC::PlatformFileForTransit(), |
| + base::FilePath())); |
| + return; |
| + } |
| + |
| + // Open the file. |
| + if (!base::PostTaskAndReplyWithResult( |
| + content::BrowserThread::GetBlockingPool(), |
| + FROM_HERE, |
| + base::Bind(OpenNaClReadExecImpl, file_path, true /* is_executable */), |
| + base::Bind(&NaClProcessHost::FileResolvedAsync, |
| + weak_factory_.GetWeakPtr(), |
| + file_token_lo, |
| + file_token_hi, |
| + file_path))) { |
| + Send(new NaClProcessMsg_ResolveFileTokenAsyncReply( |
| + file_token_lo, |
| + file_token_hi, |
| + IPC::PlatformFileForTransit(), |
| + base::FilePath())); |
| + } |
| +} |
| + |
| #if defined(OS_WIN) |
| void NaClProcessHost::OnAttachDebugExceptionHandler(const std::string& info, |
| IPC::Message* reply_msg) { |