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..bf7815627f2baf1cedfa8231b5bcbcd276688957 100644 |
| --- a/components/nacl/loader/nacl_listener.cc |
| +++ b/components/nacl/loader/nacl_listener.cc |
| @@ -24,6 +24,7 @@ |
| #include "ipc/ipc_switches.h" |
| #include "ipc/ipc_sync_channel.h" |
| #include "ipc/ipc_sync_message_filter.h" |
| +#include "native_client/src/public/nacl_app.h" |
|
teravest
2014/02/04 22:21:06
Presumably this is gated on some change to native_
hidehiko
2014/02/05 06:30:16
Yes, this is based on crrev.com/153453002, and I'l
|
| #include "native_client/src/trusted/service_runtime/sel_main_chrome.h" |
| #include "native_client/src/trusted/validator/nacl_file_info.h" |
| @@ -108,6 +109,26 @@ int AttachDebugExceptionHandler(const void* info, size_t info_size) { |
| #endif |
| +// Creates the PPAPI IPC channel between the NaCl IRT and the host |
| +// (browser/renderer) process, and starts to listen it on the thread where |
| +// the given message_loop_proxy runs. |
| +// Also, creates and sets the corresponding NaClDesc to the given nap with |
| +// the FD #. |
| +void SetUpIPCAdapter(IPC::ChannelHandle* handle, |
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy, |
| + struct NaClApp* nap, |
| + int nacl_fd) { |
| + scoped_refptr<NaClIPCAdapter> ipc_adapter( |
| + new NaClIPCAdapter(*handle, message_loop_proxy.get())); |
| + ipc_adapter->ConnectChannel(); |
| +#if defined(OS_POSIX) |
| + handle->socket = |
| + base::FileDescriptor(ipc_adapter->TakeClientFileDescriptor(), true); |
| +#endif |
| + |
| + NaClAppSetDesc(nap, nacl_fd, ipc_adapter->MakeNaClDesc()); |
| +} |
| + |
| } // namespace |
| class BrowserValidationDBProxy : public NaClValidationDB { |
| @@ -233,30 +254,32 @@ bool NaClListener::OnMessageReceived(const IPC::Message& msg) { |
| } |
| void NaClListener::OnStart(const nacl::NaClStartParams& params) { |
| - struct NaClChromeMainArgs *args = NaClChromeMainArgsCreate(); |
| + NaClChromeMainInit(); |
| + |
| + struct NaClChromeMainArgs* args = NaClChromeMainArgsCreate(); |
| if (args == NULL) { |
| LOG(ERROR) << "NaClChromeMainArgsCreate() failed"; |
| return; |
| } |
| + struct NaClApp* nap = NaClAppMake(); |
| + DCHECK(nap != NULL); |
|
teravest
2014/02/04 22:21:06
I think you want to LOG(ERROR) and return if nap i
hidehiko
2014/02/05 06:30:16
Done, but the method won't seem to return NULL (i.
|
| 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 = |
| + // 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"); |
| - scoped_refptr<NaClIPCAdapter> ipc_adapter( |
| - new NaClIPCAdapter(handle, io_thread_.message_loop_proxy().get())); |
| - ipc_adapter->ConnectChannel(); |
| + SetUpIPCAdapter(&browser_handle, io_thread_.message_loop_proxy(), |
| + nap, NACL_CHROME_DESC_BASE); |
| - // 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); |
| -#endif |
| - if (!Send(new NaClProcessHostMsg_PpapiChannelCreated(handle))) |
| + 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."; |
| } |
| @@ -340,6 +363,6 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) { |
| return; |
| } |
| #endif |
| - NaClChromeMainStart(args); |
| + NaClChromeMainStartApp(nap, args); |
| NOTREACHED(); |
| } |