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 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
657 if (nacl_host_message_filter_ != NULL && reply_msg_ != NULL) { | 657 if (nacl_host_message_filter_ != NULL && reply_msg_ != NULL) { |
658 NaClHostMsg_LaunchNaCl::WriteReplyParams( | 658 NaClHostMsg_LaunchNaCl::WriteReplyParams( |
659 reply_msg_, result, error_message); | 659 reply_msg_, result, error_message); |
660 nacl_host_message_filter_->Send(reply_msg_); | 660 nacl_host_message_filter_->Send(reply_msg_); |
661 nacl_host_message_filter_ = NULL; | 661 nacl_host_message_filter_ = NULL; |
662 reply_msg_ = NULL; | 662 reply_msg_ = NULL; |
663 } | 663 } |
664 } | 664 } |
665 | 665 |
666 // TCP port we chose for NaCl debug stub. It can be any other number. | 666 // TCP port we chose for NaCl debug stub. It can be any other number. |
667 static const int kDebugStubPort = 4014; | 667 static const int kInitialDebugStubPort = 4014; |
668 | 668 |
669 #if defined(OS_POSIX) | 669 #if defined(OS_POSIX) |
670 net::SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() { | 670 net::SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() { |
671 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); | 671 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); |
672 net::SocketDescriptor s = net::kInvalidSocket; | 672 net::SocketDescriptor s = net::kInvalidSocket; |
673 // We allocate currently unused TCP port for debug stub tests. The port | 673 // We allocate currently unused TCP port for debug stub tests. The port |
noelallen_use_chromium
2013/12/20 01:00:28
Update comment.
We always try to allocate the def
bradn
2013/12/20 01:25:35
Done.
| |
674 // number is passed to the test via debug stub port listener. | 674 // number is passed to the test via debug stub port listener. |
675 if (nacl_browser->HasGdbDebugStubPortListener()) { | 675 int port = kInitialDebugStubPort; |
676 int port; | 676 s = net::TCPListenSocket::CreateAndBind("127.0.0.1", port); |
677 if (s == net::kInvalidSocket) { | |
677 s = net::TCPListenSocket::CreateAndBindAnyPort("127.0.0.1", &port); | 678 s = net::TCPListenSocket::CreateAndBindAnyPort("127.0.0.1", &port); |
678 if (s != net::kInvalidSocket) { | 679 } |
680 if (s != net::kInvalidSocket) { | |
681 if (nacl_browser->HasGdbDebugStubPortListener()) { | |
679 nacl_browser->FireGdbDebugStubPortOpened(port); | 682 nacl_browser->FireGdbDebugStubPortOpened(port); |
680 } | 683 } |
681 } else { | |
682 s = net::TCPListenSocket::CreateAndBind("127.0.0.1", kDebugStubPort); | |
683 } | 684 } |
685 process_->SetNaClDebugStubPort(port); | |
684 if (s == net::kInvalidSocket) { | 686 if (s == net::kInvalidSocket) { |
685 LOG(ERROR) << "failed to open socket for debug stub"; | 687 LOG(ERROR) << "failed to open socket for debug stub"; |
noelallen_use_chromium
2013/12/20 01:00:28
print port number?
bradn
2013/12/20 01:25:35
Done.
| |
686 return net::kInvalidSocket; | 688 return net::kInvalidSocket; |
687 } | 689 } |
688 if (listen(s, 1)) { | 690 if (listen(s, 1)) { |
689 LOG(ERROR) << "listen() failed on debug stub socket"; | 691 LOG(ERROR) << "listen() failed on debug stub socket"; |
690 if (IGNORE_EINTR(close(s)) < 0) | 692 if (IGNORE_EINTR(close(s)) < 0) |
691 PLOG(ERROR) << "failed to close debug stub socket"; | 693 PLOG(ERROR) << "failed to close debug stub socket"; |
692 return net::kInvalidSocket; | 694 return net::kInvalidSocket; |
693 } | 695 } |
694 return s; | 696 return s; |
695 } | 697 } |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1018 process_handle.Take(), info, | 1020 process_handle.Take(), info, |
1019 base::MessageLoopProxy::current(), | 1021 base::MessageLoopProxy::current(), |
1020 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1022 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
1021 weak_factory_.GetWeakPtr())); | 1023 weak_factory_.GetWeakPtr())); |
1022 return true; | 1024 return true; |
1023 } | 1025 } |
1024 } | 1026 } |
1025 #endif | 1027 #endif |
1026 | 1028 |
1027 } // namespace nacl | 1029 } // namespace nacl |
OLD | NEW |