Chromium Code Reviews| Index: components/nacl/loader/nacl_listener.cc |
| diff --git a/components/nacl/loader/nacl_listener.cc b/components/nacl/loader/nacl_listener.cc |
| index 0866f26000faafbcfdcefe3b3e72aedf9eb6f2b6..8483d0213e8887515046458382e03a80364d1aa9 100644 |
| --- a/components/nacl/loader/nacl_listener.cc |
| +++ b/components/nacl/loader/nacl_listener.cc |
| @@ -240,24 +240,67 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) { |
| } |
| if (params.enable_ipc_proxy) { |
| - // Create the initial PPAPI IPC channel between the NaCl IRT and the |
| - // browser process. The IRT uses this channel to communicate with the |
| - // browser and to create additional IPC channels to renderer processes. |
| - IPC::ChannelHandle handle = |
| - IPC::Channel::GenerateVerifiedChannelID("nacl"); |
| - scoped_refptr<NaClIPCAdapter> ipc_adapter( |
| - new NaClIPCAdapter(handle, io_thread_.message_loop_proxy().get())); |
| - ipc_adapter->ConnectChannel(); |
| - |
| - // Pass a NaClDesc to the untrusted side. This will hold a ref to the |
| - // NaClIPCAdapter. |
| - args->initial_ipc_desc = ipc_adapter->MakeNaClDesc(); |
| +#if defined(OS_LINUX) |
| + if (params.enable_nonsfi_mode) { |
| + IPC::ChannelHandle browser_ppapi_handle = |
| + IPC::Channel::GenerateVerifiedChannelID("nacl"); |
| + IPC::ChannelHandle renderer_ppapi_handle = |
| + IPC::Channel::GenerateVerifiedChannelID("nacl"); |
| + |
| + int browser_ppapi_fds[2]; |
| + int renderer_ppapi_fds[2]; |
| + IPC::Channel::SocketPair(&browser_ppapi_fds[0], &browser_ppapi_fds[1]); |
|
Mark Seaborn
2014/02/03 22:59:07
You need to check the return value here. However,
|
| + IPC::Channel::SocketPair(&renderer_ppapi_fds[0], &renderer_ppapi_fds[1]); |
| + |
| + browser_ppapi_handle.socket = |
| + base::FileDescriptor(browser_ppapi_fds[1], true); |
| + renderer_ppapi_handle.socket = |
| + base::FileDescriptor(renderer_ppapi_fds[1], true); |
| + |
| + nacl::nonsfi::SetIPCFileDescriptors( |
| + browser_ppapi_fds[0], renderer_ppapi_fds[0]); |
| + |
| + // TODO |
| + if (!Send(new NaClProcessHostMsg_PpapiChannelCreated( |
| + browser_ppapi_handle, renderer_ppapi_handle))) |
| + LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; |
| + } else { |
| +#endif |
| + // Create the initial PPAPI IPC channel between the NaCl IRT and the |
| + // browser process. The IRT uses this channel to communicate with the |
| + // browser and to create additional IPC channels to renderer processes. |
| + IPC::ChannelHandle browser_ppapi_handle = |
| + IPC::Channel::GenerateVerifiedChannelID("nacl"); |
| + scoped_refptr<NaClIPCAdapter> ipc_adapter( |
| + new NaClIPCAdapter(browser_ppapi_handle, |
| + io_thread_.message_loop_proxy().get())); |
| + ipc_adapter->ConnectChannel(); |
| + |
| + // Pass a NaClDesc to the untrusted side. This will hold a ref to the |
| + // NaClIPCAdapter. |
| + args->initial_ipc_desc = ipc_adapter->MakeNaClDesc(); |
| #if defined(OS_POSIX) |
| - handle.socket = base::FileDescriptor( |
| - ipc_adapter->TakeClientFileDescriptor(), true); |
| + browser_ppapi_handle.socket = base::FileDescriptor( |
| + ipc_adapter->TakeClientFileDescriptor(), true); |
| #endif |
| - if (!Send(new NaClProcessHostMsg_PpapiChannelCreated(handle))) |
| - LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; |
| + |
| + IPC::ChannelHandle renderer_ppapi_handle = |
| + IPC::Channel::GenerateVerifiedChannelID("nacl"); |
| + scoped_refptr<NaClIPCAdapter> ipc_adapter2( |
| + new NaClIPCAdapter(renderer_ppapi_handle, |
| + io_thread_.message_loop_proxy().get())); |
| + ipc_adapter2->ConnectChannel(); |
| + |
| + args->initial_ipc_desc2 = ipc_adapter2->MakeNaClDesc(); |
| +#if defined(OS_POSIX) |
| + renderer_ppapi_handle.socket = base::FileDescriptor( |
| + ipc_adapter2->TakeClientFileDescriptor(), true); |
| +#endif |
| + // TODO |
| + if (!Send(new NaClProcessHostMsg_PpapiChannelCreated( |
| + browser_ppapi_handle, renderer_ppapi_handle))) |
| + LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; |
| + } |
| } |
| std::vector<nacl::FileDescriptor> handles = params.handles; |