Chromium Code Reviews| Index: chrome/browser/nacl_host/nacl_process_host.cc |
| =================================================================== |
| --- chrome/browser/nacl_host/nacl_process_host.cc (revision 136022) |
| +++ chrome/browser/nacl_host/nacl_process_host.cc (working copy) |
| @@ -301,6 +301,7 @@ |
| struct NaClProcessHost::NaClInternal { |
| std::vector<nacl::Handle> sockets_for_renderer; |
| std::vector<nacl::Handle> sockets_for_sel_ldr; |
| + std::vector<nacl::FileDescriptor> handles_for_renderer; |
| }; |
| // ----------------------------------------------------------------------------- |
| @@ -713,6 +714,8 @@ |
| IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClProcessMsg_AttachDebugExceptionHandler, |
| OnAttachDebugExceptionHandler) |
| #endif |
| + IPC_MESSAGE_HANDLER(NaClProcessHostMsg_PpapiChannelCreated, |
| + OnPpapiChannelCreated) |
| IPC_MESSAGE_UNHANDLED(handled = false) |
| IPC_END_MESSAGE_MAP() |
| return handled; |
| @@ -738,8 +741,7 @@ |
| } |
| } |
| -bool NaClProcessHost::ReplyToRenderer() { |
| - std::vector<nacl::FileDescriptor> handles_for_renderer; |
| +bool NaClProcessHost::SendStart() { |
| for (size_t i = 0; i < internal_->sockets_for_renderer.size(); i++) { |
| #if defined(OS_WIN) |
| // Copy the handle into the renderer process. |
| @@ -755,7 +757,7 @@ |
| DLOG(ERROR) << "DuplicateHandle() failed"; |
| return false; |
| } |
| - handles_for_renderer.push_back( |
| + internal_->handles_for_renderer.push_back( |
| reinterpret_cast<nacl::FileDescriptor>(handle_in_renderer)); |
| #else |
| // No need to dup the imc_handle - we don't pass it anywhere else so |
| @@ -763,10 +765,11 @@ |
| nacl::FileDescriptor imc_handle; |
| imc_handle.fd = internal_->sockets_for_renderer[i]; |
| imc_handle.auto_close = true; |
| - handles_for_renderer.push_back(imc_handle); |
| + internal_->handles_for_renderer.push_back(imc_handle); |
| #endif |
| } |
| + const ChildProcessData& data = process_->GetData(); |
| #if defined(OS_WIN) |
| // If we are on 64-bit Windows, the NaCl process's sandbox is |
| // managed by a different process from the renderer's sandbox. We |
| @@ -774,23 +777,13 @@ |
| // that the renderer can send handles to the NaCl process using |
| // BrokerDuplicateHandle(). |
| if (RunningOnWOW64()) { |
| - if (!content::BrokerAddTargetPeer(process_->GetData().handle)) { |
| + if (!content::BrokerAddTargetPeer(data.handle)) { |
| DLOG(ERROR) << "Failed to add NaCl process PID"; |
| return false; |
| } |
| } |
| #endif |
| - ChromeViewHostMsg_LaunchNaCl::WriteReplyParams( |
| - reply_msg_, handles_for_renderer); |
| - chrome_render_message_filter_->Send(reply_msg_); |
| - chrome_render_message_filter_ = NULL; |
| - reply_msg_ = NULL; |
| - internal_->sockets_for_renderer.clear(); |
| - return true; |
| -} |
| - |
| -bool NaClProcessHost::StartNaClExecution() { |
| NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); |
| nacl::NaClStartParams params; |
| @@ -801,7 +794,6 @@ |
| base::PlatformFile irt_file = nacl_browser->IrtFile(); |
| CHECK_NE(irt_file, base::kInvalidPlatformFileValue); |
| - const ChildProcessData& data = process_->GetData(); |
| for (size_t i = 0; i < internal_->sockets_for_sel_ldr.size(); i++) { |
| if (!ShareHandleToSelLdr(data.handle, |
| internal_->sockets_for_sel_ldr[i], true, |
| @@ -837,14 +829,36 @@ |
| params.handles.push_back(memory_fd); |
| #endif |
| + // The start message should only be sent once we are sure we won't delete |
| + // ourselves. |
| process_->Send(new NaClProcessMsg_Start(params)); |
| internal_->sockets_for_sel_ldr.clear(); |
| + |
| + // If we aren't creating the IPC channel, send the reply message without |
| + // waiting for the NaCl process to signal that it's ready. |
| + if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableNaClIPCProxy)) { |
|
dmichael (off chromium)
2012/05/10 19:38:58
I think you forgot to add the file where you defin
bbudge
2012/05/11 01:21:16
Separate CL. http://codereview.chromium.org/103920
|
| + OnPpapiChannelCreated(IPC::ChannelHandle()); |
| + } |
| + |
| return true; |
| } |
| -bool NaClProcessHost::SendStart() { |
| - return ReplyToRenderer() && StartNaClExecution(); |
| +void NaClProcessHost::OnPpapiChannelCreated( |
| + const IPC::ChannelHandle& channel_handle) { |
| + // Now that the server end of the channel has been created, send the reply to |
| + // the renderer. |
| + base::ProcessId nacl_process_id = base::GetProcId(process_->GetData().handle); |
| + ChromeViewHostMsg_LaunchNaCl::WriteReplyParams( |
| + reply_msg_, internal_->handles_for_renderer, channel_handle, |
| + base::kNullProcessHandle, nacl_process_id); |
| + chrome_render_message_filter_->Send(reply_msg_); |
| + chrome_render_message_filter_ = NULL; |
| + reply_msg_ = NULL; |
| + |
| + internal_->sockets_for_renderer.clear(); |
| + internal_->handles_for_renderer.clear(); |
| } |
| bool NaClProcessHost::StartWithLaunchedProcess() { |