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

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

Issue 1044953003: Init Mojo embedder for Windows NaCl plugins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move embedder init to helpers Created 5 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
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 // A mini-zygote specifically for Native Client. 5 // A mini-zygote specifically for Native Client.
6 6
7 #include "components/nacl/loader/nacl_helper_linux.h" 7 #include "components/nacl/loader/nacl_helper_linux.h"
8 8
9 #include <errno.h> 9 #include <errno.h>
10 #include <fcntl.h> 10 #include <fcntl.h>
(...skipping 25 matching lines...) Expand all
36 #include "components/nacl/loader/nonsfi/nonsfi_listener.h" 36 #include "components/nacl/loader/nonsfi/nonsfi_listener.h"
37 #include "components/nacl/loader/sandbox_linux/nacl_sandbox_linux.h" 37 #include "components/nacl/loader/sandbox_linux/nacl_sandbox_linux.h"
38 #include "content/public/common/content_descriptors.h" 38 #include "content/public/common/content_descriptors.h"
39 #include "content/public/common/send_zygote_child_ping_linux.h" 39 #include "content/public/common/send_zygote_child_ping_linux.h"
40 #include "content/public/common/zygote_fork_delegate_linux.h" 40 #include "content/public/common/zygote_fork_delegate_linux.h"
41 #include "crypto/nss_util.h" 41 #include "crypto/nss_util.h"
42 #include "ipc/ipc_descriptors.h" 42 #include "ipc/ipc_descriptors.h"
43 #include "ipc/ipc_switches.h" 43 #include "ipc/ipc_switches.h"
44 #include "sandbox/linux/services/libc_urandom_override.h" 44 #include "sandbox/linux/services/libc_urandom_override.h"
45 45
46 #if !defined(OS_NACL_NONSFI)
47 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h"
48 #include "third_party/mojo/src/mojo/edk/embedder/simple_platform_support.h"
49 #endif
50
46 #if defined(OS_NACL_NONSFI) 51 #if defined(OS_NACL_NONSFI)
47 #include "native_client/src/public/nonsfi/irt_exception_handling.h" 52 #include "native_client/src/public/nonsfi/irt_exception_handling.h"
48 #else 53 #else
49 #include <link.h> 54 #include <link.h>
50 #include "components/nacl/loader/nonsfi/irt_exception_handling.h" 55 #include "components/nacl/loader/nonsfi/irt_exception_handling.h"
51 #endif 56 #endif
52 57
53 namespace { 58 namespace {
54 59
55 struct NaClLoaderSystemInfo { 60 struct NaClLoaderSystemInfo {
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 // These are not used by nacl_helper_nonsfi. 455 // These are not used by nacl_helper_nonsfi.
451 CheckReservedAtZero(), 456 CheckReservedAtZero(),
452 sysconf(_SC_NPROCESSORS_ONLN) 457 sysconf(_SC_NPROCESSORS_ONLN)
453 #endif 458 #endif
454 }; 459 };
455 460
456 #if !defined(OS_NACL_NONSFI) 461 #if !defined(OS_NACL_NONSFI)
457 CheckRDebug(argv[0]); 462 CheckRDebug(argv[0]);
458 #endif 463 #endif
459 464
465 // TODO(teravest): Enable mojo for nonsfi.
Nick Bray (chromium) 2015/04/02 21:40:20 What's the problem? Is there an associated issue?
466 #if !defined(OS_NACL_NONSFI)
467 mojo::embedder::Init(
468 make_scoped_ptr(new mojo::embedder::SimplePlatformSupport()));
469 #endif
470
460 scoped_ptr<nacl::NaClSandbox> nacl_sandbox(new nacl::NaClSandbox); 471 scoped_ptr<nacl::NaClSandbox> nacl_sandbox(new nacl::NaClSandbox);
461 // Make sure that the early initialization did not start any spurious 472 // Make sure that the early initialization did not start any spurious
462 // threads. 473 // threads.
463 #if !defined(THREAD_SANITIZER) 474 #if !defined(THREAD_SANITIZER)
464 CHECK(nacl_sandbox->IsSingleThreaded()); 475 CHECK(nacl_sandbox->IsSingleThreaded());
465 #endif 476 #endif
466 477
467 const bool is_init_process = 1 == getpid(); 478 const bool is_init_process = 1 == getpid();
468 nacl_sandbox->InitializeLayerOneSandbox(); 479 nacl_sandbox->InitializeLayerOneSandbox();
469 CHECK_EQ(is_init_process, nacl_sandbox->layer_one_enabled()); 480 CHECK_EQ(is_init_process, nacl_sandbox->layer_one_enabled());
470 481
471 const std::vector<int> empty; 482 const std::vector<int> empty;
472 // Send the zygote a message to let it know we are ready to help 483 // Send the zygote a message to let it know we are ready to help
473 if (!UnixDomainSocket::SendMsg(kNaClZygoteDescriptor, 484 if (!UnixDomainSocket::SendMsg(kNaClZygoteDescriptor,
474 kNaClHelperStartupAck, 485 kNaClHelperStartupAck,
475 sizeof(kNaClHelperStartupAck), empty)) { 486 sizeof(kNaClHelperStartupAck), empty)) {
476 LOG(ERROR) << "*** send() to zygote failed"; 487 LOG(ERROR) << "*** send() to zygote failed";
477 } 488 }
478 489
479 // Now handle requests from the Zygote. 490 // Now handle requests from the Zygote.
480 while (true) { 491 while (true) {
481 bool request_handled = HandleZygoteRequest( 492 bool request_handled = HandleZygoteRequest(
482 kNaClZygoteDescriptor, system_info, nacl_sandbox.get()); 493 kNaClZygoteDescriptor, system_info, nacl_sandbox.get());
483 // Do not turn this into a CHECK() without thinking about robustness 494 // Do not turn this into a CHECK() without thinking about robustness
484 // against malicious IPC requests. 495 // against malicious IPC requests.
485 DCHECK(request_handled); 496 DCHECK(request_handled);
486 } 497 }
487 NOTREACHED(); 498 NOTREACHED();
488 } 499 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698