| 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 "components/nacl/browser/nacl_process_host.h" | 5 #include "components/nacl/browser/nacl_process_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 } | 750 } |
| 751 } | 751 } |
| 752 | 752 |
| 753 void NaClProcessHost::SetDebugStubPort(int port) { | 753 void NaClProcessHost::SetDebugStubPort(int port) { |
| 754 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); | 754 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); |
| 755 nacl_browser->SetProcessGdbDebugStubPort(process_->GetData().id, port); | 755 nacl_browser->SetProcessGdbDebugStubPort(process_->GetData().id, port); |
| 756 } | 756 } |
| 757 | 757 |
| 758 #if defined(OS_POSIX) | 758 #if defined(OS_POSIX) |
| 759 // TCP port we chose for NaCl debug stub. It can be any other number. | 759 // TCP port we chose for NaCl debug stub. It can be any other number. |
| 760 static const int kInitialDebugStubPort = 4014; | 760 static const uint16_t kInitialDebugStubPort = 4014; |
| 761 | 761 |
| 762 net::SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() { | 762 net::SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() { |
| 763 net::SocketDescriptor s = net::kInvalidSocket; | 763 net::SocketDescriptor s = net::kInvalidSocket; |
| 764 // We always try to allocate the default port first. If this fails, we then | 764 // We always try to allocate the default port first. If this fails, we then |
| 765 // allocate any available port. | 765 // allocate any available port. |
| 766 // On success, if the test system has register a handler | 766 // On success, if the test system has register a handler |
| 767 // (GdbDebugStubPortListener), we fire a notification. | 767 // (GdbDebugStubPortListener), we fire a notification. |
| 768 int port = kInitialDebugStubPort; | 768 uint16 port = kInitialDebugStubPort; |
| 769 s = net::TCPListenSocket::CreateAndBind("127.0.0.1", port); | 769 s = net::TCPListenSocket::CreateAndBind("127.0.0.1", port); |
| 770 if (s == net::kInvalidSocket) { | 770 if (s == net::kInvalidSocket) { |
| 771 s = net::TCPListenSocket::CreateAndBindAnyPort("127.0.0.1", &port); | 771 s = net::TCPListenSocket::CreateAndBindAnyPort("127.0.0.1", &port); |
| 772 } | 772 } |
| 773 if (s != net::kInvalidSocket) { | 773 if (s != net::kInvalidSocket) { |
| 774 SetDebugStubPort(port); | 774 SetDebugStubPort(port); |
| 775 } | 775 } |
| 776 if (s == net::kInvalidSocket) { | 776 if (s == net::kInvalidSocket) { |
| 777 LOG(ERROR) << "failed to open socket for debug stub"; | 777 LOG(ERROR) << "failed to open socket for debug stub"; |
| 778 return net::kInvalidSocket; | 778 return net::kInvalidSocket; |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 process_handle.Take(), info, | 1186 process_handle.Take(), info, |
| 1187 base::MessageLoopProxy::current(), | 1187 base::MessageLoopProxy::current(), |
| 1188 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1188 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
| 1189 weak_factory_.GetWeakPtr())); | 1189 weak_factory_.GetWeakPtr())); |
| 1190 return true; | 1190 return true; |
| 1191 } | 1191 } |
| 1192 } | 1192 } |
| 1193 #endif | 1193 #endif |
| 1194 | 1194 |
| 1195 } // namespace nacl | 1195 } // namespace nacl |
| OLD | NEW |