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 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.
| |
291 // 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.
| |
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 clients side FDs to the hosts, | |
Mark Seaborn
2014/02/19 17:00:30
"client side"
hidehiko
2014/02/20 18:50:01
Done.
| |
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 FD. | |
Mark Seaborn
2014/02/19 17:00:30
"FDs"
hidehiko
2014/02/20 18:50:01
Done.
| |
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 hosts | |
Mark Seaborn
2014/02/19 17:00:30
"host" (since this is adjectival)
hidehiko
2014/02/20 18:50:01
Done.
| |
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 | |
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.
| |
329 #if defined(OS_LINUX) | |
330 } | |
331 #endif | |
295 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated( | 332 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated( |
296 browser_handle, renderer_handle))) | 333 browser_handle, renderer_handle))) |
297 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; | 334 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; |
298 } | 335 } |
299 | 336 |
300 std::vector<nacl::FileDescriptor> handles = params.handles; | 337 std::vector<nacl::FileDescriptor> handles = params.handles; |
301 | 338 |
302 #if defined(OS_LINUX) || defined(OS_MACOSX) | 339 #if defined(OS_LINUX) || defined(OS_MACOSX) |
303 args->number_of_cores = number_of_cores_; | 340 args->number_of_cores = number_of_cores_; |
304 args->create_memory_object_func = CreateMemoryObject; | 341 args->create_memory_object_func = CreateMemoryObject; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 #if defined(OS_LINUX) | 405 #if defined(OS_LINUX) |
369 if (params.enable_nonsfi_mode) { | 406 if (params.enable_nonsfi_mode) { |
370 nacl::nonsfi::MainStart(args->imc_bootstrap_handle); | 407 nacl::nonsfi::MainStart(args->imc_bootstrap_handle); |
371 NOTREACHED(); | 408 NOTREACHED(); |
372 return; | 409 return; |
373 } | 410 } |
374 #endif | 411 #endif |
375 NaClChromeMainStartApp(nap, args); | 412 NaClChromeMainStartApp(nap, args); |
376 NOTREACHED(); | 413 NOTREACHED(); |
377 } | 414 } |
OLD | NEW |