| 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 | 10 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 return false; | 110 return false; |
| 111 return result; | 111 return result; |
| 112 } | 112 } |
| 113 | 113 |
| 114 void DebugStubPortSelectedHandler(uint16_t port) { | 114 void DebugStubPortSelectedHandler(uint16_t port) { |
| 115 g_listener->Send(new NaClProcessHostMsg_DebugStubPortSelected(port)); | 115 g_listener->Send(new NaClProcessHostMsg_DebugStubPortSelected(port)); |
| 116 } | 116 } |
| 117 | 117 |
| 118 #endif | 118 #endif |
| 119 | 119 |
| 120 void FatalLogHandler(const char* buf, size_t bytes) { |
| 121 NaClTrustedListener::Get()->SendFatalCrashLog(std::string(buf, bytes)); |
| 122 } |
| 123 |
| 120 // Creates the PPAPI IPC channel between the NaCl IRT and the host | 124 // Creates the PPAPI IPC channel between the NaCl IRT and the host |
| 121 // (browser/renderer) process, and starts to listen it on the thread where | 125 // (browser/renderer) process, and starts to listen it on the thread where |
| 122 // the given message_loop_proxy runs. | 126 // the given message_loop_proxy runs. |
| 123 // Also, creates and sets the corresponding NaClDesc to the given nap with | 127 // Also, creates and sets the corresponding NaClDesc to the given nap with |
| 124 // the FD #. | 128 // the FD #. |
| 125 void SetUpIPCAdapter(IPC::ChannelHandle* handle, | 129 void SetUpIPCAdapter(IPC::ChannelHandle* handle, |
| 126 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, | 130 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, |
| 127 struct NaClApp* nap, | 131 struct NaClApp* nap, |
| 128 int nacl_fd) { | 132 int nacl_fd) { |
| 129 scoped_refptr<NaClIPCAdapter> ipc_adapter( | 133 scoped_refptr<NaClIPCAdapter> ipc_adapter( |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 int urandom_fd = dup(base::GetUrandomFD()); | 278 int urandom_fd = dup(base::GetUrandomFD()); |
| 275 if (urandom_fd < 0) { | 279 if (urandom_fd < 0) { |
| 276 LOG(ERROR) << "Failed to dup() the urandom FD"; | 280 LOG(ERROR) << "Failed to dup() the urandom FD"; |
| 277 return; | 281 return; |
| 278 } | 282 } |
| 279 NaClChromeMainSetUrandomFd(urandom_fd); | 283 NaClChromeMainSetUrandomFd(urandom_fd); |
| 280 #endif | 284 #endif |
| 281 | 285 |
| 282 struct NaClApp* nap = NULL; | 286 struct NaClApp* nap = NULL; |
| 283 NaClChromeMainInit(); | 287 NaClChromeMainInit(); |
| 288 |
| 289 NaClSetFatalErrorCallback(&FatalLogHandler); |
| 290 |
| 284 nap = NaClAppCreate(); | 291 nap = NaClAppCreate(); |
| 285 if (nap == NULL) { | 292 if (nap == NULL) { |
| 286 LOG(ERROR) << "NaClAppCreate() failed"; | 293 LOG(ERROR) << "NaClAppCreate() failed"; |
| 287 return; | 294 return; |
| 288 } | 295 } |
| 289 | 296 |
| 290 IPC::ChannelHandle browser_handle; | 297 IPC::ChannelHandle browser_handle; |
| 291 IPC::ChannelHandle ppapi_renderer_handle; | 298 IPC::ChannelHandle ppapi_renderer_handle; |
| 292 | 299 |
| 293 if (params.enable_ipc_proxy) { | 300 if (params.enable_ipc_proxy) { |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 IPC::ChannelHandle trusted_renderer_handle = | 511 IPC::ChannelHandle trusted_renderer_handle = |
| 505 IPC::Channel::GenerateVerifiedChannelID("nacl"); | 512 IPC::Channel::GenerateVerifiedChannelID("nacl"); |
| 506 trusted_listener_ = new NaClTrustedListener( | 513 trusted_listener_ = new NaClTrustedListener( |
| 507 trusted_renderer_handle, io_thread_.message_loop_proxy().get()); | 514 trusted_renderer_handle, io_thread_.message_loop_proxy().get()); |
| 508 #if defined(OS_POSIX) | 515 #if defined(OS_POSIX) |
| 509 trusted_renderer_handle.socket = base::FileDescriptor( | 516 trusted_renderer_handle.socket = base::FileDescriptor( |
| 510 trusted_listener_->TakeClientFileDescriptor(), true); | 517 trusted_listener_->TakeClientFileDescriptor(), true); |
| 511 #endif | 518 #endif |
| 512 return trusted_renderer_handle; | 519 return trusted_renderer_handle; |
| 513 } | 520 } |
| OLD | NEW |