Chromium Code Reviews| Index: components/nacl/loader/nacl_listener.cc |
| diff --git a/components/nacl/loader/nacl_listener.cc b/components/nacl/loader/nacl_listener.cc |
| index d7c97ad918bfcb7dcc51b58814021539e049d367..604c06a02812ff078d25cbd20ee153b551f53483 100644 |
| --- a/components/nacl/loader/nacl_listener.cc |
| +++ b/components/nacl/loader/nacl_listener.cc |
| @@ -7,6 +7,7 @@ |
| #include <errno.h> |
| #include <fcntl.h> |
| #include <stdlib.h> |
| +#include <string.h> |
| #if defined(OS_POSIX) |
| #include <unistd.h> |
| @@ -46,6 +47,21 @@ |
| #endif |
| namespace { |
|
Mark Seaborn
2014/08/18 19:04:09
Nit: Add empty line after this to match end of nam
teravest
2014/08/19 19:58:16
Done.
|
| +NaClListener* g_listener; |
| + |
| +void FatalLogHandler(const char* data, size_t bytes) { |
| + uint32_t copy_bytes = std::min<uint32_t>(bytes, |
|
Mark Seaborn
2014/08/18 19:04:09
How about commenting: use uint32_t rather than siz
teravest
2014/08/19 19:58:16
Done.
|
| + nacl::kNaClCrashInfoMaxLogSize); |
| + |
| + // We copy the length of the crash data to the start of the shared memory |
| + // segment so we know how much to copy. |
| + memcpy(g_listener->crash_info_shmem_memory(), ©_bytes, sizeof(uint32_t)); |
| + |
| + memcpy((char*)g_listener->crash_info_shmem_memory() + sizeof(uint32_t), |
| + data, |
| + copy_bytes); |
| +} |
| + |
| #if defined(OS_MACOSX) |
| // On Mac OS X, shm_open() works in the sandbox but does not give us |
| @@ -85,9 +101,6 @@ int CreateMemoryObject(size_t size, int executable) { |
| } |
| #elif defined(OS_WIN) |
| - |
| -NaClListener* g_listener; |
| - |
| // We wrap the function to convert the bool return value to an int. |
| int BrokerDuplicateHandle(NaClHandle source_handle, |
| uint32_t process_id, |
| @@ -213,18 +226,14 @@ NaClListener::NaClListener() : shutdown_event_(true, false), |
| main_loop_(NULL) { |
| io_thread_.StartWithOptions( |
| base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| -#if defined(OS_WIN) |
| DCHECK(g_listener == NULL); |
| g_listener = this; |
| -#endif |
| } |
| NaClListener::~NaClListener() { |
| NOTREACHED(); |
| shutdown_event_.Signal(); |
| -#if defined(OS_WIN) |
| g_listener = NULL; |
| -#endif |
| } |
| bool NaClListener::Send(IPC::Message* msg) { |
| @@ -269,9 +278,14 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) { |
| } |
| NaClChromeMainSetUrandomFd(urandom_fd); |
| #endif |
| - |
| struct NaClApp* nap = NULL; |
| NaClChromeMainInit(); |
| + |
| + crash_info_shmem_.reset(new base::SharedMemory(params.crash_info_shmem_handle, |
| + false)); |
| + CHECK(crash_info_shmem_->Map(nacl::kNaClCrashInfoShmemSize)); |
| + NaClSetFatalErrorCallback(&FatalLogHandler); |
| + |
| nap = NaClAppCreate(); |
| if (nap == NULL) { |
| LOG(ERROR) << "NaClAppCreate() failed"; |