Chromium Code Reviews| Index: chrome/browser/nacl_host/nacl_process_host.cc |
| =================================================================== |
| --- chrome/browser/nacl_host/nacl_process_host.cc (revision 156197) |
| +++ chrome/browser/nacl_host/nacl_process_host.cc (working copy) |
| @@ -39,6 +39,7 @@ |
| #include "ipc/ipc_switches.h" |
| #include "native_client/src/shared/imc/nacl_imc.h" |
| #include "net/base/net_util.h" |
| +#include "net/base/tcp_listen_socket.h" |
| #include "ppapi/proxy/ppapi_messages.h" |
| #if defined(OS_POSIX) |
| @@ -633,6 +634,21 @@ |
| return true; |
| } |
| +// TCP port we chosen for NaCl debug stub. It can be any other number. |
|
Mark Seaborn
2012/09/13 18:19:04
'chose'
halyavin
2012/09/13 19:03:30
Done.
|
| +static const int kDebugStubPort = 4014; |
| + |
| +#if defined(OS_POSIX) |
| +SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() { |
| + SocketDescriptor s = net::TCPListenSocket::CreateAndBind("127.0.0.1", |
| + kDebugStubPort); |
| + if (listen(s, 1)) { |
| + LOG(ERROR) << "listen() failed on debug stub socket"; |
| + return net::TCPListenSocket::kInvalidSocket; |
| + } |
| + return s; |
| +} |
| +#endif |
| + |
| bool NaClProcessHost::StartNaClExecution() { |
| NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); |
| @@ -683,6 +699,16 @@ |
| params.handles.push_back(memory_fd); |
| #endif |
| +#if defined(OS_POSIX) |
| + if (enable_debug_stub_) { |
| + SocketDescriptor server_bound_socket = GetDebugStubSocketHandle(); |
| + if (server_bound_socket != net::TCPListenSocket::kInvalidSocket) { |
| + params.debug_stub_server_bound_socket = |
| + nacl::FileDescriptor(server_bound_socket, true); |
| + } |
| + } |
| +#endif |
| + |
| process_->Send(new NaClProcessMsg_Start(params)); |
| internal_->sockets_for_sel_ldr.clear(); |