| OLD | NEW | 
|    1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2012 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 "chrome/browser/nacl_host/nacl_process_host.h" |    5 #include "chrome/browser/nacl_host/nacl_process_host.h" | 
|    6  |    6  | 
|    7 #include <string> |    7 #include <string> | 
|    8 #include <vector> |    8 #include <vector> | 
|    9  |    9  | 
|   10 #include "base/bind.h" |   10 #include "base/bind.h" | 
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  655   reply_msg_ = NULL; |  655   reply_msg_ = NULL; | 
|  656   internal_->sockets_for_renderer.clear(); |  656   internal_->sockets_for_renderer.clear(); | 
|  657   return true; |  657   return true; | 
|  658 } |  658 } | 
|  659  |  659  | 
|  660 // TCP port we chose for NaCl debug stub. It can be any other number. |  660 // TCP port we chose for NaCl debug stub. It can be any other number. | 
|  661 static const int kDebugStubPort = 4014; |  661 static const int kDebugStubPort = 4014; | 
|  662  |  662  | 
|  663 #if defined(OS_POSIX) |  663 #if defined(OS_POSIX) | 
|  664 SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() { |  664 SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() { | 
|  665   SocketDescriptor s = net::TCPListenSocket::CreateAndBind("127.0.0.1", |  665   NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); | 
|  666                                                            kDebugStubPort); |  666   SocketDescriptor s; | 
 |  667   // We allocate currently unused TCP port for debug stub tests. The port | 
 |  668   // number is passed to the test via debug stub port listener. | 
 |  669   if (nacl_browser->HasGdbDebugStubPortListener()) { | 
 |  670     int port; | 
 |  671     s = net::TCPListenSocket::CreateAndBindAnyPort("127.0.0.1", &port); | 
 |  672     if (s != net::TCPListenSocket::kInvalidSocket) { | 
 |  673       nacl_browser->FireGdbDebugStubPortOpened(port); | 
 |  674     } | 
 |  675   } else { | 
 |  676     s = net::TCPListenSocket::CreateAndBind("127.0.0.1", kDebugStubPort); | 
 |  677   } | 
 |  678   if (s == net::TCPListenSocket::kInvalidSocket) { | 
 |  679     LOG(ERROR) << "failed to open socket for debug stub"; | 
 |  680     return net::TCPListenSocket::kInvalidSocket; | 
 |  681   } | 
|  667   if (listen(s, 1)) { |  682   if (listen(s, 1)) { | 
|  668     LOG(ERROR) << "listen() failed on debug stub socket"; |  683     LOG(ERROR) << "listen() failed on debug stub socket"; | 
 |  684     if (HANDLE_EINTR(close(s)) < 0) | 
 |  685       PLOG(ERROR) << "failed to close debug stub socket"; | 
|  669     return net::TCPListenSocket::kInvalidSocket; |  686     return net::TCPListenSocket::kInvalidSocket; | 
|  670   } |  687   } | 
|  671   return s; |  688   return s; | 
|  672 } |  689 } | 
|  673 #endif |  690 #endif | 
|  674  |  691  | 
|  675 bool NaClProcessHost::StartNaClExecution() { |  692 bool NaClProcessHost::StartNaClExecution() { | 
|  676   NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); |  693   NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); | 
|  677  |  694  | 
|  678   nacl::NaClStartParams params; |  695   nacl::NaClStartParams params; | 
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  899   } else { |  916   } else { | 
|  900     NaClStartDebugExceptionHandlerThread( |  917     NaClStartDebugExceptionHandlerThread( | 
|  901         process_handle.Take(), info, |  918         process_handle.Take(), info, | 
|  902         base::MessageLoopProxy::current(), |  919         base::MessageLoopProxy::current(), | 
|  903         base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |  920         base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 
|  904                    weak_factory_.GetWeakPtr())); |  921                    weak_factory_.GetWeakPtr())); | 
|  905     return true; |  922     return true; | 
|  906   } |  923   } | 
|  907 } |  924 } | 
|  908 #endif |  925 #endif | 
| OLD | NEW |