| 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 <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 // We copy the length of the crash data to the start of the shared memory | 63 // We copy the length of the crash data to the start of the shared memory |
| 64 // segment so we know how much to copy. | 64 // segment so we know how much to copy. |
| 65 memcpy(g_listener->crash_info_shmem_memory(), ©_bytes, sizeof(uint32_t)); | 65 memcpy(g_listener->crash_info_shmem_memory(), ©_bytes, sizeof(uint32_t)); |
| 66 | 66 |
| 67 memcpy((char*)g_listener->crash_info_shmem_memory() + sizeof(uint32_t), | 67 memcpy((char*)g_listener->crash_info_shmem_memory() + sizeof(uint32_t), |
| 68 data, | 68 data, |
| 69 copy_bytes); | 69 copy_bytes); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void LoadStatusCallback(int load_status) { |
| 73 g_listener->trusted_listener()->Send( |
| 74 new NaClRendererMsg_ReportLoadStatus(load_status)); |
| 75 } |
| 76 |
| 72 #if defined(OS_MACOSX) | 77 #if defined(OS_MACOSX) |
| 73 | 78 |
| 74 // On Mac OS X, shm_open() works in the sandbox but does not give us | 79 // On Mac OS X, shm_open() works in the sandbox but does not give us |
| 75 // an FD that we can map as PROT_EXEC. Rather than doing an IPC to | 80 // an FD that we can map as PROT_EXEC. Rather than doing an IPC to |
| 76 // get an executable SHM region when CreateMemoryObject() is called, | 81 // get an executable SHM region when CreateMemoryObject() is called, |
| 77 // we preallocate one on startup, since NaCl's sel_ldr only needs one | 82 // we preallocate one on startup, since NaCl's sel_ldr only needs one |
| 78 // of them. This saves a round trip. | 83 // of them. This saves a round trip. |
| 79 | 84 |
| 80 base::subtle::Atomic32 g_shm_fd = -1; | 85 base::subtle::Atomic32 g_shm_fd = -1; |
| 81 | 86 |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 #if defined(OS_LINUX) || defined(OS_MACOSX) | 418 #if defined(OS_LINUX) || defined(OS_MACOSX) |
| 414 args->debug_stub_server_bound_socket_fd = nacl::ToNativeHandle( | 419 args->debug_stub_server_bound_socket_fd = nacl::ToNativeHandle( |
| 415 params.debug_stub_server_bound_socket); | 420 params.debug_stub_server_bound_socket); |
| 416 #endif | 421 #endif |
| 417 #if defined(OS_WIN) | 422 #if defined(OS_WIN) |
| 418 args->broker_duplicate_handle_func = BrokerDuplicateHandle; | 423 args->broker_duplicate_handle_func = BrokerDuplicateHandle; |
| 419 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; | 424 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; |
| 420 args->debug_stub_server_port_selected_handler_func = | 425 args->debug_stub_server_port_selected_handler_func = |
| 421 DebugStubPortSelectedHandler; | 426 DebugStubPortSelectedHandler; |
| 422 #endif | 427 #endif |
| 428 args->load_status_handler_func = LoadStatusCallback; |
| 423 #if defined(OS_LINUX) | 429 #if defined(OS_LINUX) |
| 424 args->prereserved_sandbox_size = prereserved_sandbox_size_; | 430 args->prereserved_sandbox_size = prereserved_sandbox_size_; |
| 425 #endif | 431 #endif |
| 426 | 432 |
| 427 base::PlatformFile nexe_file = IPC::PlatformFileForTransitToPlatformFile( | 433 base::PlatformFile nexe_file = IPC::PlatformFileForTransitToPlatformFile( |
| 428 params.nexe_file); | 434 params.nexe_file); |
| 429 std::string file_path_str = params.nexe_file_path_metadata.AsUTF8Unsafe(); | 435 std::string file_path_str = params.nexe_file_path_metadata.AsUTF8Unsafe(); |
| 430 args->nexe_desc = NaClDescCreateWithFilePathMetadata(nexe_file, | 436 args->nexe_desc = NaClDescCreateWithFilePathMetadata(nexe_file, |
| 431 file_path_str.c_str()); | 437 file_path_str.c_str()); |
| 432 | 438 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 } | 470 } |
| 465 | 471 |
| 466 void NaClListener::OnFileTokenResolved( | 472 void NaClListener::OnFileTokenResolved( |
| 467 uint64_t token_lo, | 473 uint64_t token_lo, |
| 468 uint64_t token_hi, | 474 uint64_t token_hi, |
| 469 IPC::PlatformFileForTransit ipc_fd, | 475 IPC::PlatformFileForTransit ipc_fd, |
| 470 base::FilePath file_path) { | 476 base::FilePath file_path) { |
| 471 resolved_cb_.Run(ipc_fd, file_path); | 477 resolved_cb_.Run(ipc_fd, file_path); |
| 472 resolved_cb_.Reset(); | 478 resolved_cb_.Reset(); |
| 473 } | 479 } |
| OLD | NEW |