| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/nacl/loader/nacl_listener.h" | 5 #include "components/nacl/loader/nacl_listener.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 | 9 |
| 10 #if defined(OS_POSIX) | 10 #if defined(OS_POSIX) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "native_client/src/public/nacl_app.h" | 28 #include "native_client/src/public/nacl_app.h" |
| 29 #include "native_client/src/trusted/validator/nacl_file_info.h" | 29 #include "native_client/src/trusted/validator/nacl_file_info.h" |
| 30 | 30 |
| 31 #if defined(OS_POSIX) | 31 #if defined(OS_POSIX) |
| 32 #include "base/file_descriptor_posix.h" | 32 #include "base/file_descriptor_posix.h" |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 #if defined(OS_LINUX) | 35 #if defined(OS_LINUX) |
| 36 #include "components/nacl/loader/nonsfi/nonsfi_main.h" | 36 #include "components/nacl/loader/nonsfi/nonsfi_main.h" |
| 37 #include "content/public/common/child_process_sandbox_support_linux.h" | 37 #include "content/public/common/child_process_sandbox_support_linux.h" |
| 38 #include "ppapi/proxy/plugin_main_irt.h" |
| 38 #endif | 39 #endif |
| 39 | 40 |
| 40 #if defined(OS_WIN) | 41 #if defined(OS_WIN) |
| 41 #include <fcntl.h> | 42 #include <fcntl.h> |
| 42 #include <io.h> | 43 #include <io.h> |
| 43 | 44 |
| 44 #include "content/public/common/sandbox_init.h" | 45 #include "content/public/common/sandbox_init.h" |
| 45 #endif | 46 #endif |
| 46 | 47 |
| 47 namespace { | 48 namespace { |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 return; | 273 return; |
| 273 } | 274 } |
| 274 | 275 |
| 275 struct NaClApp *nap = NaClAppCreate(); | 276 struct NaClApp *nap = NaClAppCreate(); |
| 276 if (nap == NULL) { | 277 if (nap == NULL) { |
| 277 LOG(ERROR) << "NaClAppCreate() failed"; | 278 LOG(ERROR) << "NaClAppCreate() failed"; |
| 278 return; | 279 return; |
| 279 } | 280 } |
| 280 | 281 |
| 281 if (params.enable_ipc_proxy) { | 282 if (params.enable_ipc_proxy) { |
| 282 // Create the PPAPI IPC channels between the NaCl IRT and the hosts | |
| 283 // (browser/renderer) processes. The IRT uses these channels to communicate | |
| 284 // with the host and to initialize the IPC dispatchers. | |
| 285 IPC::ChannelHandle browser_handle = | 283 IPC::ChannelHandle browser_handle = |
| 286 IPC::Channel::GenerateVerifiedChannelID("nacl"); | 284 IPC::Channel::GenerateVerifiedChannelID("nacl"); |
| 287 SetUpIPCAdapter(&browser_handle, io_thread_.message_loop_proxy(), | |
| 288 nap, NACL_CHROME_DESC_BASE); | |
| 289 | |
| 290 IPC::ChannelHandle renderer_handle = | 285 IPC::ChannelHandle renderer_handle = |
| 291 IPC::Channel::GenerateVerifiedChannelID("nacl"); | 286 IPC::Channel::GenerateVerifiedChannelID("nacl"); |
| 292 SetUpIPCAdapter(&renderer_handle, io_thread_.message_loop_proxy(), | |
| 293 nap, NACL_CHROME_DESC_BASE + 1); | |
| 294 | 287 |
| 288 #if defined(OS_LINUX) |
| 289 if (params.enable_nonsfi_mode) { |
| 290 // In non-SFI mode, we neither intercept nor rewrite the message using |
| 291 // NaClIPCAdapter, and the channels are connected between the plugin and |
| 292 // the hosts directly. So, the IPC::Channel instances will be created in |
| 293 // the plugin side, because the IPC::Listener needs to live on the |
| 294 // plugin's main thread. However, on initialization (i.e. before loading |
| 295 // the plugin binary), the FD needs to be passed to the hosts. So, here |
| 296 // we create raw FD pairs, and pass the client side FDs to the hosts, |
| 297 // and the server side FDs to the plugin. |
| 298 int browser_server_ppapi_fd; |
| 299 int browser_client_ppapi_fd; |
| 300 int renderer_server_ppapi_fd; |
| 301 int renderer_client_ppapi_fd; |
| 302 if (!IPC::SocketPair( |
| 303 &browser_server_ppapi_fd, &browser_client_ppapi_fd) || |
| 304 !IPC::SocketPair( |
| 305 &renderer_server_ppapi_fd, &renderer_client_ppapi_fd)) { |
| 306 LOG(ERROR) << "Failed to create sockets for IPC."; |
| 307 return; |
| 308 } |
| 309 |
| 310 // Set the plugin IPC channel FDs. |
| 311 SetIPCFileDescriptors( |
| 312 browser_server_ppapi_fd, renderer_server_ppapi_fd); |
| 313 |
| 314 // Send back to the client side IPC channel FD to the host. |
| 315 browser_handle.socket = |
| 316 base::FileDescriptor(browser_client_ppapi_fd, true); |
| 317 renderer_handle.socket = |
| 318 base::FileDescriptor(renderer_client_ppapi_fd, true); |
| 319 } else { |
| 320 #endif |
| 321 // Create the PPAPI IPC channels between the NaCl IRT and the host |
| 322 // (browser/renderer) processes. The IRT uses these channels to |
| 323 // communicate with the host and to initialize the IPC dispatchers. |
| 324 SetUpIPCAdapter(&browser_handle, io_thread_.message_loop_proxy(), |
| 325 nap, NACL_CHROME_DESC_BASE); |
| 326 SetUpIPCAdapter(&renderer_handle, io_thread_.message_loop_proxy(), |
| 327 nap, NACL_CHROME_DESC_BASE + 1); |
| 328 #if defined(OS_LINUX) |
| 329 } |
| 330 #endif |
| 295 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated( | 331 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated( |
| 296 browser_handle, renderer_handle))) | 332 browser_handle, renderer_handle))) |
| 297 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; | 333 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; |
| 298 } | 334 } |
| 299 | 335 |
| 300 std::vector<nacl::FileDescriptor> handles = params.handles; | 336 std::vector<nacl::FileDescriptor> handles = params.handles; |
| 301 | 337 |
| 302 #if defined(OS_LINUX) || defined(OS_MACOSX) | 338 #if defined(OS_LINUX) || defined(OS_MACOSX) |
| 303 args->number_of_cores = number_of_cores_; | 339 args->number_of_cores = number_of_cores_; |
| 304 args->create_memory_object_func = CreateMemoryObject; | 340 args->create_memory_object_func = CreateMemoryObject; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 #if defined(OS_LINUX) | 404 #if defined(OS_LINUX) |
| 369 if (params.enable_nonsfi_mode) { | 405 if (params.enable_nonsfi_mode) { |
| 370 nacl::nonsfi::MainStart(args->imc_bootstrap_handle); | 406 nacl::nonsfi::MainStart(args->imc_bootstrap_handle); |
| 371 NOTREACHED(); | 407 NOTREACHED(); |
| 372 return; | 408 return; |
| 373 } | 409 } |
| 374 #endif | 410 #endif |
| 375 NaClChromeMainStartApp(nap, args); | 411 NaClChromeMainStartApp(nap, args); |
| 376 NOTREACHED(); | 412 NOTREACHED(); |
| 377 } | 413 } |
| OLD | NEW |