OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/nacl/nacl_listener.h" | 5 #include "chrome/nacl/nacl_listener.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
15 #include "chrome/common/nacl_messages.h" | 15 #include "chrome/common/nacl_messages.h" |
| 16 #include "chrome/nacl/nacl_ipc_adapter.h" |
16 #include "chrome/nacl/nacl_validation_db.h" | 17 #include "chrome/nacl/nacl_validation_db.h" |
17 #include "chrome/nacl/nacl_validation_query.h" | 18 #include "chrome/nacl/nacl_validation_query.h" |
| 19 #include "ipc/ipc_channel_handle.h" |
| 20 #include "ipc/ipc_switches.h" |
18 #include "ipc/ipc_sync_channel.h" | 21 #include "ipc/ipc_sync_channel.h" |
19 #include "ipc/ipc_sync_message_filter.h" | 22 #include "ipc/ipc_sync_message_filter.h" |
20 #include "ipc/ipc_switches.h" | |
21 #include "native_client/src/trusted/service_runtime/sel_main_chrome.h" | 23 #include "native_client/src/trusted/service_runtime/sel_main_chrome.h" |
22 | 24 |
| 25 #if defined(OS_POSIX) |
| 26 #include "base/file_descriptor_posix.h" |
| 27 #endif |
| 28 |
23 #if defined(OS_LINUX) | 29 #if defined(OS_LINUX) |
24 #include "content/public/common/child_process_sandbox_support_linux.h" | 30 #include "content/public/common/child_process_sandbox_support_linux.h" |
25 #endif | 31 #endif |
26 | 32 |
27 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
28 #include <fcntl.h> | 34 #include <fcntl.h> |
29 #include <io.h> | 35 #include <io.h> |
30 | 36 |
31 #include "content/public/common/sandbox_init.h" | 37 #include "content/public/common/sandbox_init.h" |
32 #endif | 38 #endif |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 return handled; | 187 return handled; |
182 } | 188 } |
183 | 189 |
184 void NaClListener::OnMsgStart(const nacl::NaClStartParams& params) { | 190 void NaClListener::OnMsgStart(const nacl::NaClStartParams& params) { |
185 struct NaClChromeMainArgs *args = NaClChromeMainArgsCreate(); | 191 struct NaClChromeMainArgs *args = NaClChromeMainArgsCreate(); |
186 if (args == NULL) { | 192 if (args == NULL) { |
187 LOG(ERROR) << "NaClChromeMainArgsCreate() failed"; | 193 LOG(ERROR) << "NaClChromeMainArgsCreate() failed"; |
188 return; | 194 return; |
189 } | 195 } |
190 | 196 |
| 197 if (params.enable_ipc_proxy) { |
| 198 // Create the server side of the channel and notify the process host so it |
| 199 // can reply to the renderer, which will connect as client. |
| 200 IPC::ChannelHandle channel_handle = |
| 201 IPC::Channel::GenerateVerifiedChannelID("nacl"); |
| 202 |
| 203 scoped_refptr<NaClIPCAdapter> ipc_adapter(new NaClIPCAdapter( |
| 204 channel_handle, io_thread_.message_loop_proxy())); |
| 205 args->initial_ipc_desc = ipc_adapter.get()->MakeNaClDesc(); |
| 206 |
| 207 #if defined(OS_POSIX) |
| 208 channel_handle.socket = base::FileDescriptor( |
| 209 ipc_adapter.get()->TakeClientFileDescriptor(), true); |
| 210 #endif |
| 211 |
| 212 Send(new NaClProcessHostMsg_PpapiChannelCreated(channel_handle)); |
| 213 } |
| 214 |
191 std::vector<nacl::FileDescriptor> handles = params.handles; | 215 std::vector<nacl::FileDescriptor> handles = params.handles; |
192 | 216 |
193 #if defined(OS_LINUX) || defined(OS_MACOSX) | 217 #if defined(OS_LINUX) || defined(OS_MACOSX) |
194 args->urandom_fd = dup(base::GetUrandomFD()); | 218 args->urandom_fd = dup(base::GetUrandomFD()); |
195 if (args->urandom_fd < 0) { | 219 if (args->urandom_fd < 0) { |
196 LOG(ERROR) << "Failed to dup() the urandom FD"; | 220 LOG(ERROR) << "Failed to dup() the urandom FD"; |
197 return; | 221 return; |
198 } | 222 } |
199 args->create_memory_object_func = CreateMemoryObject; | 223 args->create_memory_object_func = CreateMemoryObject; |
200 # if defined(OS_MACOSX) | 224 # if defined(OS_MACOSX) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 args->imc_bootstrap_handle = nacl::ToNativeHandle(handles[0]); | 256 args->imc_bootstrap_handle = nacl::ToNativeHandle(handles[0]); |
233 args->enable_exception_handling = params.enable_exception_handling; | 257 args->enable_exception_handling = params.enable_exception_handling; |
234 args->enable_debug_stub = params.enable_debug_stub; | 258 args->enable_debug_stub = params.enable_debug_stub; |
235 #if defined(OS_WIN) | 259 #if defined(OS_WIN) |
236 args->broker_duplicate_handle_func = BrokerDuplicateHandle; | 260 args->broker_duplicate_handle_func = BrokerDuplicateHandle; |
237 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; | 261 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; |
238 #endif | 262 #endif |
239 NaClChromeMainStart(args); | 263 NaClChromeMainStart(args); |
240 NOTREACHED(); | 264 NOTREACHED(); |
241 } | 265 } |
OLD | NEW |