Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(889)

Side by Side Diff: components/nacl/browser/nacl_process_host.cc

Issue 198083006: Update the task manager with the debug stub port chosen by nacl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « components/nacl/browser/nacl_process_host.h ('k') | components/nacl/common/nacl_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 IPC_MESSAGE_HANDLER(NaClProcessMsg_QueryKnownToValidate, 647 IPC_MESSAGE_HANDLER(NaClProcessMsg_QueryKnownToValidate,
648 OnQueryKnownToValidate) 648 OnQueryKnownToValidate)
649 IPC_MESSAGE_HANDLER(NaClProcessMsg_SetKnownToValidate, 649 IPC_MESSAGE_HANDLER(NaClProcessMsg_SetKnownToValidate,
650 OnSetKnownToValidate) 650 OnSetKnownToValidate)
651 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClProcessMsg_ResolveFileToken, 651 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClProcessMsg_ResolveFileToken,
652 OnResolveFileToken) 652 OnResolveFileToken)
653 #if defined(OS_WIN) 653 #if defined(OS_WIN)
654 IPC_MESSAGE_HANDLER_DELAY_REPLY( 654 IPC_MESSAGE_HANDLER_DELAY_REPLY(
655 NaClProcessMsg_AttachDebugExceptionHandler, 655 NaClProcessMsg_AttachDebugExceptionHandler,
656 OnAttachDebugExceptionHandler) 656 OnAttachDebugExceptionHandler)
657 IPC_MESSAGE_HANDLER(NaClProcessHostMsg_DebugStubPortSelected,
658 OnDebugStubPortSelected)
657 #endif 659 #endif
658 IPC_MESSAGE_HANDLER(NaClProcessHostMsg_PpapiChannelsCreated, 660 IPC_MESSAGE_HANDLER(NaClProcessHostMsg_PpapiChannelsCreated,
659 OnPpapiChannelsCreated) 661 OnPpapiChannelsCreated)
660 IPC_MESSAGE_UNHANDLED(handled = false) 662 IPC_MESSAGE_UNHANDLED(handled = false)
661 IPC_END_MESSAGE_MAP() 663 IPC_END_MESSAGE_MAP()
662 } 664 }
663 return handled; 665 return handled;
664 } 666 }
665 667
666 void NaClProcessHost::OnProcessLaunched() { 668 void NaClProcessHost::OnProcessLaunched() {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 DCHECK(reply_msg_); 750 DCHECK(reply_msg_);
749 if (nacl_host_message_filter_ != NULL && reply_msg_ != NULL) { 751 if (nacl_host_message_filter_ != NULL && reply_msg_ != NULL) {
750 NaClHostMsg_LaunchNaCl::WriteReplyParams( 752 NaClHostMsg_LaunchNaCl::WriteReplyParams(
751 reply_msg_, result, error_message); 753 reply_msg_, result, error_message);
752 nacl_host_message_filter_->Send(reply_msg_); 754 nacl_host_message_filter_->Send(reply_msg_);
753 nacl_host_message_filter_ = NULL; 755 nacl_host_message_filter_ = NULL;
754 reply_msg_ = NULL; 756 reply_msg_ = NULL;
755 } 757 }
756 } 758 }
757 759
760 void NaClProcessHost::SetDebugStubPort(uint16_t port) {
761 NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
762 if (nacl_browser->HasGdbDebugStubPortListener()) {
763 nacl_browser->FireGdbDebugStubPortOpened(port);
764 }
765 // Set debug stub port on the process object.
766 process_->SetNaClDebugStubPort(port);
767 }
768
769 #if defined(OS_POSIX)
758 // TCP port we chose for NaCl debug stub. It can be any other number. 770 // TCP port we chose for NaCl debug stub. It can be any other number.
759 static const int kInitialDebugStubPort = 4014; 771 static const int kInitialDebugStubPort = 4014;
760 772
761 #if defined(OS_POSIX)
762 net::SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() { 773 net::SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() {
763 NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
764 net::SocketDescriptor s = net::kInvalidSocket; 774 net::SocketDescriptor s = net::kInvalidSocket;
765 // We always try to allocate the default port first. If this fails, we then 775 // We always try to allocate the default port first. If this fails, we then
766 // allocate any available port. 776 // allocate any available port.
767 // On success, if the test system has register a handler 777 // On success, if the test system has register a handler
768 // (GdbDebugStubPortListener), we fire a notification. 778 // (GdbDebugStubPortListener), we fire a notification.
769 int port = kInitialDebugStubPort; 779 int port = kInitialDebugStubPort;
770 s = net::TCPListenSocket::CreateAndBind("127.0.0.1", port); 780 s = net::TCPListenSocket::CreateAndBind("127.0.0.1", port);
771 if (s == net::kInvalidSocket) { 781 if (s == net::kInvalidSocket) {
772 s = net::TCPListenSocket::CreateAndBindAnyPort("127.0.0.1", &port); 782 s = net::TCPListenSocket::CreateAndBindAnyPort("127.0.0.1", &port);
773 } 783 }
774 if (s != net::kInvalidSocket) { 784 if (s != net::kInvalidSocket) {
775 if (nacl_browser->HasGdbDebugStubPortListener()) { 785 SetDebugStubPort(port);
776 nacl_browser->FireGdbDebugStubPortOpened(port);
777 }
778 } 786 }
779 // Set debug stub port on the process object.
780 process_->SetNaClDebugStubPort(port);
781 if (s == net::kInvalidSocket) { 787 if (s == net::kInvalidSocket) {
782 LOG(ERROR) << "failed to open socket for debug stub"; 788 LOG(ERROR) << "failed to open socket for debug stub";
783 return net::kInvalidSocket; 789 return net::kInvalidSocket;
784 } else { 790 } else {
785 LOG(WARNING) << "debug stub on port " << port; 791 LOG(WARNING) << "debug stub on port " << port;
786 } 792 }
787 if (listen(s, 1)) { 793 if (listen(s, 1)) {
788 LOG(ERROR) << "listen() failed on debug stub socket"; 794 LOG(ERROR) << "listen() failed on debug stub socket";
789 if (IGNORE_EINTR(close(s)) < 0) 795 if (IGNORE_EINTR(close(s)) < 0)
790 PLOG(ERROR) << "failed to close debug stub socket"; 796 PLOG(ERROR) << "failed to close debug stub socket";
791 return net::kInvalidSocket; 797 return net::kInvalidSocket;
792 } 798 }
793 return s; 799 return s;
794 } 800 }
795 #endif 801 #endif
796 802
803 #if defined(OS_WIN)
804 void NaClProcessHost::OnDebugStubPortSelected(uint16_t debug_stub_port) {
805 CHECK(!uses_nonsfi_mode_);
806 SetDebugStubPort(debug_stub_port);
807 }
808 #endif
809
797 bool NaClProcessHost::StartNaClExecution() { 810 bool NaClProcessHost::StartNaClExecution() {
798 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); 811 NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
799 812
800 NaClStartParams params; 813 NaClStartParams params;
801 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled(); 814 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled();
802 params.validation_cache_key = nacl_browser->GetValidationCacheKey(); 815 params.validation_cache_key = nacl_browser->GetValidationCacheKey();
803 params.version = NaClBrowser::GetDelegate()->GetVersionString(); 816 params.version = NaClBrowser::GetDelegate()->GetVersionString();
804 params.enable_exception_handling = enable_exception_handling_; 817 params.enable_exception_handling = enable_exception_handling_;
805 params.enable_debug_stub = enable_debug_stub_ && 818 params.enable_debug_stub = enable_debug_stub_ &&
806 NaClBrowser::GetDelegate()->URLMatchesDebugPatterns(manifest_url_); 819 NaClBrowser::GetDelegate()->URLMatchesDebugPatterns(manifest_url_);
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 process_handle.Take(), info, 1121 process_handle.Take(), info,
1109 base::MessageLoopProxy::current(), 1122 base::MessageLoopProxy::current(),
1110 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 1123 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
1111 weak_factory_.GetWeakPtr())); 1124 weak_factory_.GetWeakPtr()));
1112 return true; 1125 return true;
1113 } 1126 }
1114 } 1127 }
1115 #endif 1128 #endif
1116 1129
1117 } // namespace nacl 1130 } // namespace nacl
OLDNEW
« no previous file with comments | « components/nacl/browser/nacl_process_host.h ('k') | components/nacl/common/nacl_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698