OLD | NEW |
---|---|
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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 void NaClListener::OnStart(const nacl::NaClStartParams& params) { | 259 void NaClListener::OnStart(const nacl::NaClStartParams& params) { |
260 #if defined(OS_LINUX) || defined(OS_MACOSX) | 260 #if defined(OS_LINUX) || defined(OS_MACOSX) |
261 int urandom_fd = dup(base::GetUrandomFD()); | 261 int urandom_fd = dup(base::GetUrandomFD()); |
262 if (urandom_fd < 0) { | 262 if (urandom_fd < 0) { |
263 LOG(ERROR) << "Failed to dup() the urandom FD"; | 263 LOG(ERROR) << "Failed to dup() the urandom FD"; |
264 return; | 264 return; |
265 } | 265 } |
266 NaClChromeMainSetUrandomFd(urandom_fd); | 266 NaClChromeMainSetUrandomFd(urandom_fd); |
267 #endif | 267 #endif |
268 | 268 |
269 NaClChromeMainInit(); | 269 struct NaClApp* nap = NULL; |
270 struct NaClChromeMainArgs *args = NaClChromeMainArgsCreate(); | 270 if (!params.uses_nonsfi_mode) { |
Mark Seaborn
2014/04/01 14:35:36
This conflicts with your other change, https://cod
hamaji
2014/04/03 07:05:54
Done.
| |
271 if (args == NULL) { | 271 NaClChromeMainInit(); |
272 LOG(ERROR) << "NaClChromeMainArgsCreate() failed"; | 272 nap = NaClAppCreate(); |
273 return; | 273 if (nap == NULL) { |
274 } | 274 LOG(ERROR) << "NaClAppCreate() failed"; |
275 | 275 return; |
276 struct NaClApp *nap = NaClAppCreate(); | 276 } |
277 if (nap == NULL) { | |
278 LOG(ERROR) << "NaClAppCreate() failed"; | |
279 return; | |
280 } | 277 } |
281 | 278 |
282 IPC::ChannelHandle browser_handle; | 279 IPC::ChannelHandle browser_handle; |
283 IPC::ChannelHandle ppapi_renderer_handle; | 280 IPC::ChannelHandle ppapi_renderer_handle; |
284 | 281 |
285 if (params.enable_ipc_proxy) { | 282 if (params.enable_ipc_proxy) { |
286 browser_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); | 283 browser_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); |
287 ppapi_renderer_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); | 284 ppapi_renderer_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); |
288 | 285 |
289 #if defined(OS_LINUX) | 286 #if defined(OS_LINUX) |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 #if defined(OS_POSIX) | 339 #if defined(OS_POSIX) |
343 trusted_renderer_handle.socket = base::FileDescriptor( | 340 trusted_renderer_handle.socket = base::FileDescriptor( |
344 trusted_listener_->TakeClientFileDescriptor(), true); | 341 trusted_listener_->TakeClientFileDescriptor(), true); |
345 #endif | 342 #endif |
346 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated( | 343 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated( |
347 browser_handle, ppapi_renderer_handle, trusted_renderer_handle))) | 344 browser_handle, ppapi_renderer_handle, trusted_renderer_handle))) |
348 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; | 345 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; |
349 | 346 |
350 std::vector<nacl::FileDescriptor> handles = params.handles; | 347 std::vector<nacl::FileDescriptor> handles = params.handles; |
351 | 348 |
349 #if defined(OS_LINUX) | |
350 if (params.uses_nonsfi_mode) { | |
351 if (params.uses_irt) { | |
352 LOG(ERROR) << "IRT must not be used for non-SFI NaCl."; | |
353 return; | |
354 } | |
355 CHECK(handles.size() == 1); | |
356 int imc_bootstrap_handle = nacl::ToNativeHandle(handles[0]); | |
357 nacl::nonsfi::MainStart(imc_bootstrap_handle); | |
358 return; | |
359 } | |
360 #endif | |
361 | |
362 struct NaClChromeMainArgs* args = NULL; | |
363 args = NaClChromeMainArgsCreate(); | |
Mark Seaborn
2014/04/01 14:35:36
Combine with previous line?
hamaji
2014/04/03 07:05:54
Done.
| |
364 if (args == NULL) { | |
365 LOG(ERROR) << "NaClChromeMainArgsCreate() failed"; | |
366 return; | |
367 } | |
368 | |
352 #if defined(OS_LINUX) || defined(OS_MACOSX) | 369 #if defined(OS_LINUX) || defined(OS_MACOSX) |
353 args->number_of_cores = number_of_cores_; | 370 args->number_of_cores = number_of_cores_; |
354 args->create_memory_object_func = CreateMemoryObject; | 371 args->create_memory_object_func = CreateMemoryObject; |
355 # if defined(OS_MACOSX) | 372 # if defined(OS_MACOSX) |
356 CHECK(handles.size() >= 1); | 373 CHECK(handles.size() >= 1); |
357 g_shm_fd = nacl::ToNativeHandle(handles[handles.size() - 1]); | 374 g_shm_fd = nacl::ToNativeHandle(handles[handles.size() - 1]); |
358 handles.pop_back(); | 375 handles.pop_back(); |
359 # endif | 376 # endif |
360 #endif | 377 #endif |
361 | 378 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
413 params.debug_stub_server_bound_socket); | 430 params.debug_stub_server_bound_socket); |
414 #endif | 431 #endif |
415 #if defined(OS_WIN) | 432 #if defined(OS_WIN) |
416 args->broker_duplicate_handle_func = BrokerDuplicateHandle; | 433 args->broker_duplicate_handle_func = BrokerDuplicateHandle; |
417 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; | 434 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; |
418 #endif | 435 #endif |
419 #if defined(OS_LINUX) | 436 #if defined(OS_LINUX) |
420 args->prereserved_sandbox_size = prereserved_sandbox_size_; | 437 args->prereserved_sandbox_size = prereserved_sandbox_size_; |
421 #endif | 438 #endif |
422 | 439 |
423 #if defined(OS_LINUX) | |
424 if (params.uses_nonsfi_mode) { | |
425 nacl::nonsfi::MainStart(args->imc_bootstrap_handle); | |
426 return; | |
427 } | |
428 #endif | |
429 NaClChromeMainStartApp(nap, args); | 440 NaClChromeMainStartApp(nap, args); |
430 NOTREACHED(); | 441 NOTREACHED(); |
431 } | 442 } |
OLD | NEW |