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 c35d946d5bbb369ac221ee5e96a359dfb93e94ff..9fbe14e7d8a3df30a1f583e2b574c9f2d256db3c 100644 |
| --- a/components/nacl/loader/nacl_listener.cc |
| +++ b/components/nacl/loader/nacl_listener.cc |
| @@ -35,6 +35,7 @@ |
| #if defined(OS_LINUX) |
| #include "components/nacl/loader/nonsfi/nonsfi_main.h" |
| #include "content/public/common/child_process_sandbox_support_linux.h" |
| +#include "ppapi/proxy/plugin_main_irt.h" |
| #endif |
| #if defined(OS_WIN) |
| @@ -279,19 +280,55 @@ 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 defined(OS_LINUX) |
| + if (params.enable_nonsfi_mode) { |
| + // In non-SFI mode, we neither intercept nor rewrite the message by |
|
Mark Seaborn
2014/02/19 17:00:30
"by" -> "using"
jln (very slow on Chromium)
2014/02/19 22:40:09
This is key to what's happening in this CL. Could
hidehiko
2014/02/20 18:50:01
Done.
hidehiko
2014/02/20 18:50:01
Updated the commit message.
|
| + // IPCAdapter, and the channels are connected between the plugin and |
|
Mark Seaborn
2014/02/19 17:00:30
"IPCAdapter" -> "NaClIPCAdapter" for clarity
hidehiko
2014/02/20 18:50:01
Done.
|
| + // the hosts directly. So, the IPC::Channel instances will be created in |
| + // the plugin side, because the IPC::Listener needs to live on the |
| + // plugin's main thread. However, on initialization (i.e. before loading |
| + // the plugin binary), the FD needs to be passed to the hosts. So, here |
| + // we create raw FD pairs, and pass the clients side FDs to the hosts, |
|
Mark Seaborn
2014/02/19 17:00:30
"client side"
hidehiko
2014/02/20 18:50:01
Done.
|
| + // 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. |
|
Mark Seaborn
2014/02/19 17:00:30
"FDs"
hidehiko
2014/02/20 18:50:01
Done.
|
| + SetIPCFileDescriptors( |
| + browser_server_ppapi_fd, renderer_server_ppapi_fd); |
| + |
| + // Send back to the client side IPC channel FD to the host. |
| + browser_handle.socket = |
| + base::FileDescriptor(browser_client_ppapi_fd, true); |
| + renderer_handle.socket = |
| + base::FileDescriptor(renderer_client_ppapi_fd, true); |
| + } else { |
| +#endif |
| + // Create the PPAPI IPC channels between the NaCl IRT and the hosts |
|
Mark Seaborn
2014/02/19 17:00:30
"host" (since this is adjectival)
hidehiko
2014/02/20 18:50:01
Done.
|
| + // (browser/renderer) processes. The IRT uses these channels to |
| + // communicate with the host and to initialize the IPC dispatchers. |
| + SetUpIPCAdapter(&browser_handle, io_thread_.message_loop_proxy(), |
| + nap, NACL_CHROME_DESC_BASE); |
| + SetUpIPCAdapter(&renderer_handle, io_thread_.message_loop_proxy(), |
| + nap, NACL_CHROME_DESC_BASE + 1); |
| + |
|
Mark Seaborn
2014/02/19 17:00:30
Nit: remove empty line to match start of block
hidehiko
2014/02/20 18:50:01
Done.
|
| +#if defined(OS_LINUX) |
| + } |
| +#endif |
| if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated( |
| browser_handle, renderer_handle))) |
| LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; |