Chromium Code Reviews| 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 "components/nacl/loader/nonsfi/nonsfi_listener.h" | 5 #include "components/nacl/loader/nonsfi/nonsfi_listener.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_descriptor_posix.h" | 8 #include "base/file_descriptor_posix.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
| 12 #include "components/nacl/common/nacl_messages.h" | 12 #include "components/nacl/common/nacl_messages.h" |
| 13 #include "components/nacl/common/nacl_types.h" | 13 #include "components/nacl/common/nacl_types.h" |
| 14 #include "components/nacl/loader/nacl_trusted_listener.h" | 14 #include "components/nacl/loader/nacl_trusted_listener.h" |
| 15 #include "components/nacl/loader/nonsfi/irt_random.h" | 15 #include "components/nacl/loader/nonsfi/irt_random.h" |
| 16 #include "components/nacl/loader/nonsfi/nonsfi_main.h" | 16 #include "components/nacl/loader/nonsfi/nonsfi_main.h" |
| 17 #include "ipc/ipc_channel.h" | 17 #include "ipc/ipc_channel.h" |
| 18 #include "ipc/ipc_channel_handle.h" | 18 #include "ipc/ipc_channel_handle.h" |
| 19 #include "ipc/ipc_switches.h" | 19 #include "ipc/ipc_switches.h" |
| 20 #include "ipc/ipc_sync_channel.h" | 20 #include "ipc/ipc_sync_channel.h" |
| 21 #include "ppapi/nacl_irt/plugin_startup.h" | 21 #include "ppapi/nacl_irt/plugin_startup.h" |
| 22 | 22 |
| 23 #if !defined(OS_LINUX) | 23 #if !defined(OS_LINUX) |
| 24 # error "non-SFI mode is supported only on linux." | 24 # error "non-SFI mode is supported only on linux." |
| 25 #endif | 25 #endif |
| 26 | 26 |
| 27 namespace nacl { | 27 namespace nacl { |
| 28 namespace nonsfi { | 28 namespace nonsfi { |
| 29 | 29 |
| 30 void RegisterPreopenedDescriptors(const std::vector<std::string>& keys, | |
|
teravest
2014/10/24 16:18:06
Why is this defined in another file?
Yusuke Sato
2014/11/04 22:50:21
Because nacl::nonsfi::IrtOpenResource() in compone
| |
| 31 const std::vector<int>& fds); | |
| 32 | |
| 30 NonSfiListener::NonSfiListener() : io_thread_("NaCl_IOThread"), | 33 NonSfiListener::NonSfiListener() : io_thread_("NaCl_IOThread"), |
| 31 shutdown_event_(true, false) { | 34 shutdown_event_(true, false) { |
| 32 io_thread_.StartWithOptions( | 35 io_thread_.StartWithOptions( |
| 33 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 36 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 34 } | 37 } |
| 35 | 38 |
| 36 NonSfiListener::~NonSfiListener() { | 39 NonSfiListener::~NonSfiListener() { |
| 37 } | 40 } |
| 38 | 41 |
| 39 void NonSfiListener::Listen() { | 42 void NonSfiListener::Listen() { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 CHECK(params.debug_stub_server_bound_socket.fd == -1); | 142 CHECK(params.debug_stub_server_bound_socket.fd == -1); |
| 140 | 143 |
| 141 CHECK(params.handles.empty()); | 144 CHECK(params.handles.empty()); |
| 142 // We are only expecting non-SFI mode to be used with NaCl for now, | 145 // We are only expecting non-SFI mode to be used with NaCl for now, |
| 143 // not PNaCl processes. | 146 // not PNaCl processes. |
| 144 CHECK(params.process_type == kNativeNaClProcessType); | 147 CHECK(params.process_type == kNativeNaClProcessType); |
| 145 | 148 |
| 146 CHECK(params.nexe_file != IPC::InvalidPlatformFileForTransit()); | 149 CHECK(params.nexe_file != IPC::InvalidPlatformFileForTransit()); |
| 147 CHECK(params.nexe_file_path_metadata.empty()); | 150 CHECK(params.nexe_file_path_metadata.empty()); |
| 148 | 151 |
| 152 CHECK(params.resource_keys.size() == params.resource_files.size()); | |
| 153 std::vector<base::PlatformFile> fds; | |
| 154 for (size_t i = 0; i < params.resource_files.size(); ++i) { | |
| 155 fds.push_back( | |
| 156 IPC::PlatformFileForTransitToPlatformFile(params.resource_files[i])); | |
| 157 } | |
| 158 RegisterPreopenedDescriptors(params.resource_keys, fds); | |
| 159 | |
| 149 MainStart(IPC::PlatformFileForTransitToPlatformFile(params.nexe_file)); | 160 MainStart(IPC::PlatformFileForTransitToPlatformFile(params.nexe_file)); |
| 150 } | 161 } |
| 151 | 162 |
| 152 } // namespace nonsfi | 163 } // namespace nonsfi |
| 153 } // namespace nacl | 164 } // namespace nacl |
| OLD | NEW |