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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 } | 291 } |
287 NaClChromeMainSetUrandomFd(urandom_fd); | 292 NaClChromeMainSetUrandomFd(urandom_fd); |
288 #endif | 293 #endif |
289 struct NaClApp* nap = NULL; | 294 struct NaClApp* nap = NULL; |
290 NaClChromeMainInit(); | 295 NaClChromeMainInit(); |
291 | 296 |
292 crash_info_shmem_.reset(new base::SharedMemory(params.crash_info_shmem_handle, | 297 crash_info_shmem_.reset(new base::SharedMemory(params.crash_info_shmem_handle, |
293 false)); | 298 false)); |
294 CHECK(crash_info_shmem_->Map(nacl::kNaClCrashInfoShmemSize)); | 299 CHECK(crash_info_shmem_->Map(nacl::kNaClCrashInfoShmemSize)); |
295 NaClSetFatalErrorCallback(&FatalLogHandler); | 300 NaClSetFatalErrorCallback(&FatalLogHandler); |
| 301 NaClSetLoadStatusCallback(&LoadStatusCallback); |
296 | 302 |
297 nap = NaClAppCreate(); | 303 nap = NaClAppCreate(); |
298 if (nap == NULL) { | 304 if (nap == NULL) { |
299 LOG(ERROR) << "NaClAppCreate() failed"; | 305 LOG(ERROR) << "NaClAppCreate() failed"; |
300 return; | 306 return; |
301 } | 307 } |
302 | 308 |
303 IPC::ChannelHandle browser_handle; | 309 IPC::ChannelHandle browser_handle; |
304 IPC::ChannelHandle ppapi_renderer_handle; | 310 IPC::ChannelHandle ppapi_renderer_handle; |
305 IPC::ChannelHandle manifest_service_handle; | 311 IPC::ChannelHandle manifest_service_handle; |
(...skipping 158 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 |