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( |
| 75 static_cast<NaClErrorCode>(load_status))); |
| 76 } |
| 77 |
72 #if defined(OS_MACOSX) | 78 #if defined(OS_MACOSX) |
73 | 79 |
74 // On Mac OS X, shm_open() works in the sandbox but does not give us | 80 // 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 | 81 // 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, | 82 // get an executable SHM region when CreateMemoryObject() is called, |
77 // we preallocate one on startup, since NaCl's sel_ldr only needs one | 83 // we preallocate one on startup, since NaCl's sel_ldr only needs one |
78 // of them. This saves a round trip. | 84 // of them. This saves a round trip. |
79 | 85 |
80 base::subtle::Atomic32 g_shm_fd = -1; | 86 base::subtle::Atomic32 g_shm_fd = -1; |
81 | 87 |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 #if defined(OS_LINUX) || defined(OS_MACOSX) | 419 #if defined(OS_LINUX) || defined(OS_MACOSX) |
414 args->debug_stub_server_bound_socket_fd = nacl::ToNativeHandle( | 420 args->debug_stub_server_bound_socket_fd = nacl::ToNativeHandle( |
415 params.debug_stub_server_bound_socket); | 421 params.debug_stub_server_bound_socket); |
416 #endif | 422 #endif |
417 #if defined(OS_WIN) | 423 #if defined(OS_WIN) |
418 args->broker_duplicate_handle_func = BrokerDuplicateHandle; | 424 args->broker_duplicate_handle_func = BrokerDuplicateHandle; |
419 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; | 425 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; |
420 args->debug_stub_server_port_selected_handler_func = | 426 args->debug_stub_server_port_selected_handler_func = |
421 DebugStubPortSelectedHandler; | 427 DebugStubPortSelectedHandler; |
422 #endif | 428 #endif |
| 429 args->load_status_handler_func = LoadStatusCallback; |
423 #if defined(OS_LINUX) | 430 #if defined(OS_LINUX) |
424 args->prereserved_sandbox_size = prereserved_sandbox_size_; | 431 args->prereserved_sandbox_size = prereserved_sandbox_size_; |
425 #endif | 432 #endif |
426 | 433 |
427 base::PlatformFile nexe_file = IPC::PlatformFileForTransitToPlatformFile( | 434 base::PlatformFile nexe_file = IPC::PlatformFileForTransitToPlatformFile( |
428 params.nexe_file); | 435 params.nexe_file); |
429 std::string file_path_str = params.nexe_file_path_metadata.AsUTF8Unsafe(); | 436 std::string file_path_str = params.nexe_file_path_metadata.AsUTF8Unsafe(); |
430 args->nexe_desc = NaClDescCreateWithFilePathMetadata(nexe_file, | 437 args->nexe_desc = NaClDescCreateWithFilePathMetadata(nexe_file, |
431 file_path_str.c_str()); | 438 file_path_str.c_str()); |
432 | 439 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 } | 471 } |
465 | 472 |
466 void NaClListener::OnFileTokenResolved( | 473 void NaClListener::OnFileTokenResolved( |
467 uint64_t token_lo, | 474 uint64_t token_lo, |
468 uint64_t token_hi, | 475 uint64_t token_hi, |
469 IPC::PlatformFileForTransit ipc_fd, | 476 IPC::PlatformFileForTransit ipc_fd, |
470 base::FilePath file_path) { | 477 base::FilePath file_path) { |
471 resolved_cb_.Run(ipc_fd, file_path); | 478 resolved_cb_.Run(ipc_fd, file_path); |
472 resolved_cb_.Reset(); | 479 resolved_cb_.Reset(); |
473 } | 480 } |
OLD | NEW |