Chromium Code Reviews| Index: chrome/browser/nacl_host/nacl_process_host.cc |
| =================================================================== |
| --- chrome/browser/nacl_host/nacl_process_host.cc (revision 134969) |
| +++ chrome/browser/nacl_host/nacl_process_host.cc (working copy) |
| @@ -410,6 +410,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; |
| }; |
| // ----------------------------------------------------------------------------- |
| @@ -882,6 +883,8 @@ |
| OnQueryKnownToValidate) |
| IPC_MESSAGE_HANDLER(NaClProcessMsg_SetKnownToValidate, |
| OnSetKnownToValidate) |
| + IPC_MESSAGE_HANDLER(NaClProcessHostMsg_PpapiChannelCreated, |
| + OnPpapiChannelCreated) |
| IPC_MESSAGE_UNHANDLED(handled = false) |
| IPC_END_MESSAGE_MAP() |
| return handled; |
| @@ -907,8 +910,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. |
| @@ -924,7 +926,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 |
| @@ -932,10 +934,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(); |
|
dmichael (off chromium)
2012/05/04 22:51:42
Why did you move this farther from where it's firs
bbudge
2012/05/07 18:08:53
Done.
|
| #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 |
| @@ -950,16 +953,6 @@ |
| } |
| #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; |
| @@ -970,7 +963,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, |
| @@ -1006,6 +998,8 @@ |
| params.handles.push_back(memory_fd); |
| #endif |
| + // The start message should only be sent once we are sure we won't delete |
| + // ourselves. |
| IPC::Message* start_message = new NaClProcessMsg_Start(params); |
| #if defined(OS_WIN) |
| if (debug_context_ != NULL) { |
| @@ -1022,8 +1016,20 @@ |
| 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() { |