| Index: components/nacl/loader/nacl_listener.cc
|
| diff --git a/components/nacl/loader/nacl_listener.cc b/components/nacl/loader/nacl_listener.cc
|
| index c35d946d5bbb369ac221ee5e96a359dfb93e94ff..5f840c204f75a5cfecde66492ca2545c4fd51537 100644
|
| --- a/components/nacl/loader/nacl_listener.cc
|
| +++ b/components/nacl/loader/nacl_listener.cc
|
| @@ -279,22 +279,67 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) {
|
| }
|
|
|
| if (params.enable_ipc_proxy) {
|
| - // Create the PPAPI IPC channels between the NaCl IRT and the hosts
|
| - // (browser/renderer) processes. The IRT uses these channels to communicate
|
| - // with the host and to initialize the IPC dispatchers.
|
| - IPC::ChannelHandle browser_handle =
|
| - IPC::Channel::GenerateVerifiedChannelID("nacl");
|
| - SetUpIPCAdapter(&browser_handle, io_thread_.message_loop_proxy(),
|
| - nap, NACL_CHROME_DESC_BASE);
|
| -
|
| - IPC::ChannelHandle renderer_handle =
|
| - IPC::Channel::GenerateVerifiedChannelID("nacl");
|
| - SetUpIPCAdapter(&renderer_handle, io_thread_.message_loop_proxy(),
|
| - nap, NACL_CHROME_DESC_BASE + 1);
|
| -
|
| - if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated(
|
| - browser_handle, renderer_handle)))
|
| - LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost.";
|
| +#if defined(OS_LINUX)
|
| + if (params.enable_nonsfi_mode) {
|
| + // In non-SFI mode, we neither intercept nor rewrite the message by
|
| + // IPCAdapter, and the channels are connected between the plugin and
|
| + // the hosts directly. So, the IPC::Channel instances will be created in
|
| + // the plugin side, because the IPC::Listener needs to be live on the
|
| + // plugin's main thread. However, on the initialization (i.e. before
|
| + // loading the plugin binary), the FD is needed to be passed to the
|
| + // hosts. So, here we create raw FD pairs, and pass the clients side FDs
|
| + // to the hosts, and the server side FDs to the plugin.
|
| + int browser_server_ppapi_fd;
|
| + int browser_client_ppapi_fd;
|
| + int renderer_server_ppapi_fd;
|
| + int renderer_client_ppapi_fd;
|
| + if (!IPC::SocketPair(
|
| + &browser_server_ppapi_fd, &browser_client_ppapi_fd) ||
|
| + !IPC::SocketPair(
|
| + &renderer_server_ppapi_fd, &renderer_client_ppapi_fd)) {
|
| + LOG(ERROR) << "Failed to create sockets for IPC.";
|
| + return;
|
| + }
|
| +
|
| + // Set the plugin IPC channel FD.
|
| + nacl::nonsfi::SetIPCFileDescriptors(
|
| + browser_server_ppapi_fd, renderer_server_ppapi_fd);
|
| +
|
| + // Send back to the client side IPC channel FD to the host.
|
| + IPC::ChannelHandle browser_handle =
|
| + IPC::Channel::GenerateVerifiedChannelID("nacl");
|
| + browser_handle.socket =
|
| + base::FileDescriptor(browser_client_ppapi_fd, true);
|
| +
|
| + IPC::ChannelHandle renderer_handle =
|
| + IPC::Channel::GenerateVerifiedChannelID("nacl");
|
| + renderer_handle.socket =
|
| + base::FileDescriptor(renderer_client_ppapi_fd, true);
|
| +
|
| + if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated(
|
| + browser_handle, renderer_handle)))
|
| + LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost.";
|
| + } else {
|
| +#endif
|
| + // Create the PPAPI IPC channels between the NaCl IRT and the hosts
|
| + // (browser/renderer) processes. The IRT uses these channels to
|
| + // communicate with the host and to initialize the IPC dispatchers.
|
| + IPC::ChannelHandle browser_handle =
|
| + IPC::Channel::GenerateVerifiedChannelID("nacl");
|
| + SetUpIPCAdapter(&browser_handle, io_thread_.message_loop_proxy(),
|
| + nap, NACL_CHROME_DESC_BASE);
|
| +
|
| + IPC::ChannelHandle renderer_handle =
|
| + IPC::Channel::GenerateVerifiedChannelID("nacl");
|
| + SetUpIPCAdapter(&renderer_handle, io_thread_.message_loop_proxy(),
|
| + nap, NACL_CHROME_DESC_BASE + 1);
|
| +
|
| + if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated(
|
| + browser_handle, renderer_handle)))
|
| + LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost.";
|
| +#if defined(OS_LINUX)
|
| + }
|
| +#endif
|
| }
|
|
|
| std::vector<nacl::FileDescriptor> handles = params.handles;
|
|
|