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()->Send( | |
122 new NaClProcessHostMsg_FatalLogReceived(std::string(buf, bytes))); | |
123 | |
124 // Give the IPC task runner 50ms to try to send the fatal log message. | |
125 NaClTrustedListener::Get()->FlushIpcTaskRunner( | |
126 base::TimeDelta::FromMilliseconds(50)); | |
dmichael (off chromium)
2014/07/30 20:18:52
I think I'd rather see a SendFatalLog method on Na
| |
127 } | |
128 | |
120 // Creates the PPAPI IPC channel between the NaCl IRT and the host | 129 // 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 | 130 // (browser/renderer) process, and starts to listen it on the thread where |
122 // the given message_loop_proxy runs. | 131 // the given message_loop_proxy runs. |
123 // Also, creates and sets the corresponding NaClDesc to the given nap with | 132 // Also, creates and sets the corresponding NaClDesc to the given nap with |
124 // the FD #. | 133 // the FD #. |
125 void SetUpIPCAdapter(IPC::ChannelHandle* handle, | 134 void SetUpIPCAdapter(IPC::ChannelHandle* handle, |
126 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, | 135 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, |
127 struct NaClApp* nap, | 136 struct NaClApp* nap, |
128 int nacl_fd) { | 137 int nacl_fd) { |
129 scoped_refptr<NaClIPCAdapter> ipc_adapter( | 138 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()); | 283 int urandom_fd = dup(base::GetUrandomFD()); |
275 if (urandom_fd < 0) { | 284 if (urandom_fd < 0) { |
276 LOG(ERROR) << "Failed to dup() the urandom FD"; | 285 LOG(ERROR) << "Failed to dup() the urandom FD"; |
277 return; | 286 return; |
278 } | 287 } |
279 NaClChromeMainSetUrandomFd(urandom_fd); | 288 NaClChromeMainSetUrandomFd(urandom_fd); |
280 #endif | 289 #endif |
281 | 290 |
282 struct NaClApp* nap = NULL; | 291 struct NaClApp* nap = NULL; |
283 NaClChromeMainInit(); | 292 NaClChromeMainInit(); |
293 | |
294 NaClSetFatalErrorCallback(&FatalLogHandler); | |
295 | |
284 nap = NaClAppCreate(); | 296 nap = NaClAppCreate(); |
285 if (nap == NULL) { | 297 if (nap == NULL) { |
286 LOG(ERROR) << "NaClAppCreate() failed"; | 298 LOG(ERROR) << "NaClAppCreate() failed"; |
287 return; | 299 return; |
288 } | 300 } |
289 | 301 |
290 IPC::ChannelHandle browser_handle; | 302 IPC::ChannelHandle browser_handle; |
291 IPC::ChannelHandle ppapi_renderer_handle; | 303 IPC::ChannelHandle ppapi_renderer_handle; |
292 | 304 |
293 if (params.enable_ipc_proxy) { | 305 if (params.enable_ipc_proxy) { |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
504 IPC::ChannelHandle trusted_renderer_handle = | 516 IPC::ChannelHandle trusted_renderer_handle = |
505 IPC::Channel::GenerateVerifiedChannelID("nacl"); | 517 IPC::Channel::GenerateVerifiedChannelID("nacl"); |
506 trusted_listener_ = new NaClTrustedListener( | 518 trusted_listener_ = new NaClTrustedListener( |
507 trusted_renderer_handle, io_thread_.message_loop_proxy().get()); | 519 trusted_renderer_handle, io_thread_.message_loop_proxy().get()); |
508 #if defined(OS_POSIX) | 520 #if defined(OS_POSIX) |
509 trusted_renderer_handle.socket = base::FileDescriptor( | 521 trusted_renderer_handle.socket = base::FileDescriptor( |
510 trusted_listener_->TakeClientFileDescriptor(), true); | 522 trusted_listener_->TakeClientFileDescriptor(), true); |
511 #endif | 523 #endif |
512 return trusted_renderer_handle; | 524 return trusted_renderer_handle; |
513 } | 525 } |
OLD | NEW |