Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: components/nacl/loader/nacl_listener.cc

Issue 231793003: Add IPC Channel for new ManifestService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « components/nacl/common/nacl_types.cc ('k') | components/nacl/loader/nonsfi/nonsfi_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 NaClChromeMainInit(); 285 NaClChromeMainInit();
286 nap = NaClAppCreate(); 286 nap = NaClAppCreate();
287 if (nap == NULL) { 287 if (nap == NULL) {
288 LOG(ERROR) << "NaClAppCreate() failed"; 288 LOG(ERROR) << "NaClAppCreate() failed";
289 return; 289 return;
290 } 290 }
291 } 291 }
292 292
293 IPC::ChannelHandle browser_handle; 293 IPC::ChannelHandle browser_handle;
294 IPC::ChannelHandle ppapi_renderer_handle; 294 IPC::ChannelHandle ppapi_renderer_handle;
295 IPC::ChannelHandle manifest_service_handle;
295 296
296 if (params.enable_ipc_proxy) { 297 if (params.enable_ipc_proxy) {
297 browser_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); 298 browser_handle = IPC::Channel::GenerateVerifiedChannelID("nacl");
298 ppapi_renderer_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); 299 ppapi_renderer_handle = IPC::Channel::GenerateVerifiedChannelID("nacl");
299 300
300 #if defined(OS_LINUX) 301 #if defined(OS_LINUX)
301 if (uses_nonsfi_mode_) { 302 if (uses_nonsfi_mode_) {
303 manifest_service_handle =
304 IPC::Channel::GenerateVerifiedChannelID("nacl");
305
302 // In non-SFI mode, we neither intercept nor rewrite the message using 306 // In non-SFI mode, we neither intercept nor rewrite the message using
303 // NaClIPCAdapter, and the channels are connected between the plugin and 307 // NaClIPCAdapter, and the channels are connected between the plugin and
304 // the hosts directly. So, the IPC::Channel instances will be created in 308 // the hosts directly. So, the IPC::Channel instances will be created in
305 // the plugin side, because the IPC::Listener needs to live on the 309 // the plugin side, because the IPC::Listener needs to live on the
306 // plugin's main thread. However, on initialization (i.e. before loading 310 // plugin's main thread. However, on initialization (i.e. before loading
307 // the plugin binary), the FD needs to be passed to the hosts. So, here 311 // the plugin binary), the FD needs to be passed to the hosts. So, here
308 // we create raw FD pairs, and pass the client side FDs to the hosts, 312 // we create raw FD pairs, and pass the client side FDs to the hosts,
309 // and the server side FDs to the plugin. 313 // and the server side FDs to the plugin.
310 int browser_server_ppapi_fd; 314 int browser_server_ppapi_fd;
311 int browser_client_ppapi_fd; 315 int browser_client_ppapi_fd;
312 int renderer_server_ppapi_fd; 316 int renderer_server_ppapi_fd;
313 int renderer_client_ppapi_fd; 317 int renderer_client_ppapi_fd;
318 int manifest_service_server_fd;
319 int manifest_service_client_fd;
314 if (!IPC::SocketPair( 320 if (!IPC::SocketPair(
315 &browser_server_ppapi_fd, &browser_client_ppapi_fd) || 321 &browser_server_ppapi_fd, &browser_client_ppapi_fd) ||
316 !IPC::SocketPair( 322 !IPC::SocketPair(
317 &renderer_server_ppapi_fd, &renderer_client_ppapi_fd)) { 323 &renderer_server_ppapi_fd, &renderer_client_ppapi_fd) ||
324 !IPC::SocketPair(
325 &manifest_service_server_fd, &manifest_service_client_fd)) {
318 LOG(ERROR) << "Failed to create sockets for IPC."; 326 LOG(ERROR) << "Failed to create sockets for IPC.";
319 return; 327 return;
320 } 328 }
321 329
322 // Set the plugin IPC channel FDs. 330 // Set the plugin IPC channel FDs.
323 ppapi::SetIPCFileDescriptors( 331 ppapi::SetIPCFileDescriptors(browser_server_ppapi_fd,
324 browser_server_ppapi_fd, renderer_server_ppapi_fd); 332 renderer_server_ppapi_fd,
333 manifest_service_server_fd);
334 ppapi::StartUpPlugin();
325 335
326 // Send back to the client side IPC channel FD to the host. 336 // Send back to the client side IPC channel FD to the host.
327 browser_handle.socket = 337 browser_handle.socket =
328 base::FileDescriptor(browser_client_ppapi_fd, true); 338 base::FileDescriptor(browser_client_ppapi_fd, true);
329 ppapi_renderer_handle.socket = 339 ppapi_renderer_handle.socket =
330 base::FileDescriptor(renderer_client_ppapi_fd, true); 340 base::FileDescriptor(renderer_client_ppapi_fd, true);
341 manifest_service_handle.socket =
342 base::FileDescriptor(manifest_service_client_fd, true);
331 } else { 343 } else {
332 #endif 344 #endif
333 // Create the PPAPI IPC channels between the NaCl IRT and the host 345 // Create the PPAPI IPC channels between the NaCl IRT and the host
334 // (browser/renderer) processes. The IRT uses these channels to 346 // (browser/renderer) processes. The IRT uses these channels to
335 // communicate with the host and to initialize the IPC dispatchers. 347 // communicate with the host and to initialize the IPC dispatchers.
336 SetUpIPCAdapter(&browser_handle, io_thread_.message_loop_proxy(), 348 SetUpIPCAdapter(&browser_handle, io_thread_.message_loop_proxy(),
337 nap, NACL_CHROME_DESC_BASE); 349 nap, NACL_CHROME_DESC_BASE);
338 SetUpIPCAdapter(&ppapi_renderer_handle, io_thread_.message_loop_proxy(), 350 SetUpIPCAdapter(&ppapi_renderer_handle, io_thread_.message_loop_proxy(),
339 nap, NACL_CHROME_DESC_BASE + 1); 351 nap, NACL_CHROME_DESC_BASE + 1);
340 #if defined(OS_LINUX) 352 #if defined(OS_LINUX)
341 } 353 }
342 #endif 354 #endif
343 } 355 }
344 356
345 // The argument passed to GenerateVerifiedChannelID() here MUST be "nacl". 357 // The argument passed to GenerateVerifiedChannelID() here MUST be "nacl".
346 // Using an alternate channel name prevents the pipe from being created on 358 // Using an alternate channel name prevents the pipe from being created on
347 // Windows when the sandbox is enabled. 359 // Windows when the sandbox is enabled.
348 IPC::ChannelHandle trusted_renderer_handle = 360 IPC::ChannelHandle trusted_renderer_handle =
349 IPC::Channel::GenerateVerifiedChannelID("nacl"); 361 IPC::Channel::GenerateVerifiedChannelID("nacl");
350 trusted_listener_ = new NaClTrustedListener( 362 trusted_listener_ = new NaClTrustedListener(
351 trusted_renderer_handle, io_thread_.message_loop_proxy(), 363 trusted_renderer_handle, io_thread_.message_loop_proxy(),
352 &shutdown_event_); 364 &shutdown_event_);
353 #if defined(OS_POSIX) 365 #if defined(OS_POSIX)
354 trusted_renderer_handle.socket = base::FileDescriptor( 366 trusted_renderer_handle.socket = base::FileDescriptor(
355 trusted_listener_->TakeClientFileDescriptor(), true); 367 trusted_listener_->TakeClientFileDescriptor(), true);
356 #endif 368 #endif
357 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated( 369 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated(
358 browser_handle, ppapi_renderer_handle, trusted_renderer_handle))) 370 browser_handle, ppapi_renderer_handle,
371 trusted_renderer_handle, manifest_service_handle)))
359 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; 372 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost.";
360 373
361 std::vector<nacl::FileDescriptor> handles = params.handles; 374 std::vector<nacl::FileDescriptor> handles = params.handles;
362 375
363 #if defined(OS_LINUX) 376 #if defined(OS_LINUX)
364 if (uses_nonsfi_mode_) { 377 if (uses_nonsfi_mode_) {
365 if (params.uses_irt) { 378 if (params.uses_irt) {
366 LOG(ERROR) << "IRT must not be used for non-SFI NaCl."; 379 LOG(ERROR) << "IRT must not be used for non-SFI NaCl.";
367 return; 380 return;
368 } 381 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 args->broker_duplicate_handle_func = BrokerDuplicateHandle; 459 args->broker_duplicate_handle_func = BrokerDuplicateHandle;
447 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; 460 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler;
448 #endif 461 #endif
449 #if defined(OS_LINUX) 462 #if defined(OS_LINUX)
450 args->prereserved_sandbox_size = prereserved_sandbox_size_; 463 args->prereserved_sandbox_size = prereserved_sandbox_size_;
451 #endif 464 #endif
452 465
453 NaClChromeMainStartApp(nap, args); 466 NaClChromeMainStartApp(nap, args);
454 NOTREACHED(); 467 NOTREACHED();
455 } 468 }
OLDNEW
« no previous file with comments | « components/nacl/common/nacl_types.cc ('k') | components/nacl/loader/nonsfi/nonsfi_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698