| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/shell/runner/host/child_process.h" | 5 #include "mojo/shell/runner/host/child_process.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "mojo/shell/runner/host/child_process_base.h" | 37 #include "mojo/shell/runner/host/child_process_base.h" |
| 38 #include "mojo/shell/runner/host/native_application_support.h" | 38 #include "mojo/shell/runner/host/native_application_support.h" |
| 39 #include "mojo/shell/runner/init.h" | 39 #include "mojo/shell/runner/init.h" |
| 40 | 40 |
| 41 #if defined(OS_LINUX) && !defined(OS_ANDROID) | 41 #if defined(OS_LINUX) && !defined(OS_ANDROID) |
| 42 #include "base/rand_util.h" | 42 #include "base/rand_util.h" |
| 43 #include "base/sys_info.h" | 43 #include "base/sys_info.h" |
| 44 #include "mojo/shell/runner/host/linux_sandbox.h" | 44 #include "mojo/shell/runner/host/linux_sandbox.h" |
| 45 #endif | 45 #endif |
| 46 | 46 |
| 47 #if defined(OS_MACOSX) |
| 48 #include "mojo/shell/runner/host/mach_broker.h" |
| 49 #endif |
| 50 |
| 47 namespace mojo { | 51 namespace mojo { |
| 48 namespace shell { | 52 namespace shell { |
| 49 | 53 |
| 50 namespace { | 54 namespace { |
| 51 | 55 |
| 52 #if defined(OS_LINUX) && !defined(OS_ANDROID) | 56 #if defined(OS_LINUX) && !defined(OS_ANDROID) |
| 53 scoped_ptr<mojo::shell::LinuxSandbox> InitializeSandbox() { | 57 scoped_ptr<mojo::shell::LinuxSandbox> InitializeSandbox() { |
| 54 using sandbox::syscall_broker::BrokerFilePermission; | 58 using sandbox::syscall_broker::BrokerFilePermission; |
| 55 // Warm parts of base in the copy of base in the mojo runner. | 59 // Warm parts of base in the copy of base in the mojo runner. |
| 56 base::RandUint64(); | 60 base::RandUint64(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 base::NativeLibrary app_library = 0; | 100 base::NativeLibrary app_library = 0; |
| 97 // Load the application library before we engage the sandbox. | 101 // Load the application library before we engage the sandbox. |
| 98 base::FilePath app_library_path = | 102 base::FilePath app_library_path = |
| 99 command_line.GetSwitchValuePath(switches::kChildProcess); | 103 command_line.GetSwitchValuePath(switches::kChildProcess); |
| 100 if (!app_library_path.empty()) | 104 if (!app_library_path.empty()) |
| 101 app_library = mojo::shell::LoadNativeApplication(app_library_path); | 105 app_library = mojo::shell::LoadNativeApplication(app_library_path); |
| 102 base::i18n::InitializeICU(); | 106 base::i18n::InitializeICU(); |
| 103 if (app_library) | 107 if (app_library) |
| 104 CallLibraryEarlyInitialization(app_library); | 108 CallLibraryEarlyInitialization(app_library); |
| 105 | 109 |
| 110 #if defined(OS_MACOSX) |
| 111 // Send our task port to the parent. |
| 112 MachBroker::SendTaskPortToParent(); |
| 113 #endif |
| 114 |
| 106 #if !defined(OFFICIAL_BUILD) | 115 #if !defined(OFFICIAL_BUILD) |
| 107 // Initialize stack dumping just before initializing sandbox to make | 116 // Initialize stack dumping just before initializing sandbox to make |
| 108 // sure symbol names in all loaded libraries will be cached. | 117 // sure symbol names in all loaded libraries will be cached. |
| 109 base::debug::EnableInProcessStackDumping(); | 118 base::debug::EnableInProcessStackDumping(); |
| 110 #endif | 119 #endif |
| 111 #if defined(OS_LINUX) && !defined(OS_ANDROID) | 120 #if defined(OS_LINUX) && !defined(OS_ANDROID) |
| 112 if (command_line.HasSwitch(switches::kEnableSandbox)) | 121 if (command_line.HasSwitch(switches::kEnableSandbox)) |
| 113 sandbox = InitializeSandbox(); | 122 sandbox = InitializeSandbox(); |
| 114 #endif | 123 #endif |
| 115 | 124 |
| 116 ChildProcessMain(base::Bind(&RunNativeLibrary, app_library)); | 125 ChildProcessMain(base::Bind(&RunNativeLibrary, app_library)); |
| 117 | 126 |
| 118 return 0; | 127 return 0; |
| 119 } | 128 } |
| 120 | 129 |
| 121 } // namespace shell | 130 } // namespace shell |
| 122 } // namespace mojo | 131 } // namespace mojo |
| OLD | NEW |