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

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
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 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 IPC_MESSAGE_HANDLER(NaClProcessMsg_SetKnownToValidate, 639 IPC_MESSAGE_HANDLER(NaClProcessMsg_SetKnownToValidate,
640 OnSetKnownToValidate) 640 OnSetKnownToValidate)
641 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClProcessMsg_ResolveFileToken, 641 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClProcessMsg_ResolveFileToken,
642 OnResolveFileToken) 642 OnResolveFileToken)
643 #if defined(OS_WIN) 643 #if defined(OS_WIN)
644 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClProcessMsg_AttachDebugExceptionHandler, 644 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClProcessMsg_AttachDebugExceptionHandler,
645 OnAttachDebugExceptionHandler) 645 OnAttachDebugExceptionHandler)
646 #endif 646 #endif
647 IPC_MESSAGE_HANDLER(NaClProcessHostMsg_PpapiChannelsCreated, 647 IPC_MESSAGE_HANDLER(NaClProcessHostMsg_PpapiChannelsCreated,
648 OnPpapiChannelsCreated) 648 OnPpapiChannelsCreated)
649 IPC_MESSAGE_HANDLER(NaClProcessHostMsg_DebugStubPortSelected,
Mark Seaborn 2014/05/08 15:52:23 FYI, this needs rebasing. I changed this method y
bradn 2014/05/08 17:00:24 Done.
650 OnDebugStubPortSelected)
649 IPC_MESSAGE_UNHANDLED(handled = false) 651 IPC_MESSAGE_UNHANDLED(handled = false)
650 IPC_END_MESSAGE_MAP() 652 IPC_END_MESSAGE_MAP()
651 return handled; 653 return handled;
652 } 654 }
653 655
654 void NaClProcessHost::OnProcessLaunched() { 656 void NaClProcessHost::OnProcessLaunched() {
655 if (!StartWithLaunchedProcess()) 657 if (!StartWithLaunchedProcess())
656 delete this; 658 delete this;
657 } 659 }
658 660
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 reply_msg_, result, error_message); 741 reply_msg_, result, error_message);
740 nacl_host_message_filter_->Send(reply_msg_); 742 nacl_host_message_filter_->Send(reply_msg_);
741 nacl_host_message_filter_ = NULL; 743 nacl_host_message_filter_ = NULL;
742 reply_msg_ = NULL; 744 reply_msg_ = NULL;
743 } 745 }
744 } 746 }
745 747
746 // TCP port we chose for NaCl debug stub. It can be any other number. 748 // TCP port we chose for NaCl debug stub. It can be any other number.
747 static const int kInitialDebugStubPort = 4014; 749 static const int kInitialDebugStubPort = 4014;
748 750
751 void NaClProcessHost::ChangeDebugStubPort(uint16_t port) {
752 NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
753 if (nacl_browser->HasGdbDebugStubPortListener()) {
754 nacl_browser->FireGdbDebugStubPortOpened(port);
755 }
756 // Set debug stub port on the process object.
757 process_->SetNaClDebugStubPort(port);
758 }
759
749 #if defined(OS_POSIX) 760 #if defined(OS_POSIX)
750 net::SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() { 761 net::SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() {
751 NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
752 net::SocketDescriptor s = net::kInvalidSocket; 762 net::SocketDescriptor s = net::kInvalidSocket;
753 // We always try to allocate the default port first. If this fails, we then 763 // We always try to allocate the default port first. If this fails, we then
754 // allocate any available port. 764 // allocate any available port.
755 // On success, if the test system has register a handler 765 // On success, if the test system has register a handler
756 // (GdbDebugStubPortListener), we fire a notification. 766 // (GdbDebugStubPortListener), we fire a notification.
757 int port = kInitialDebugStubPort; 767 int port = kInitialDebugStubPort;
758 s = net::TCPListenSocket::CreateAndBind("127.0.0.1", port); 768 s = net::TCPListenSocket::CreateAndBind("127.0.0.1", port);
759 if (s == net::kInvalidSocket) { 769 if (s == net::kInvalidSocket) {
760 s = net::TCPListenSocket::CreateAndBindAnyPort("127.0.0.1", &port); 770 s = net::TCPListenSocket::CreateAndBindAnyPort("127.0.0.1", &port);
761 } 771 }
762 if (s != net::kInvalidSocket) { 772 if (s != net::kInvalidSocket) {
763 if (nacl_browser->HasGdbDebugStubPortListener()) { 773 ChangeDebugStubPort(port);
764 nacl_browser->FireGdbDebugStubPortOpened(port);
765 }
766 } 774 }
767 // Set debug stub port on the process object.
768 process_->SetNaClDebugStubPort(port);
769 if (s == net::kInvalidSocket) { 775 if (s == net::kInvalidSocket) {
770 LOG(ERROR) << "failed to open socket for debug stub"; 776 LOG(ERROR) << "failed to open socket for debug stub";
771 return net::kInvalidSocket; 777 return net::kInvalidSocket;
772 } else { 778 } else {
773 LOG(WARNING) << "debug stub on port " << port; 779 LOG(WARNING) << "debug stub on port " << port;
774 } 780 }
775 if (listen(s, 1)) { 781 if (listen(s, 1)) {
776 LOG(ERROR) << "listen() failed on debug stub socket"; 782 LOG(ERROR) << "listen() failed on debug stub socket";
777 if (IGNORE_EINTR(close(s)) < 0) 783 if (IGNORE_EINTR(close(s)) < 0)
778 PLOG(ERROR) << "failed to close debug stub socket"; 784 PLOG(ERROR) << "failed to close debug stub socket";
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 ReplyToRenderer(ppapi_renderer_channel_handle, 925 ReplyToRenderer(ppapi_renderer_channel_handle,
920 trusted_renderer_channel_handle, 926 trusted_renderer_channel_handle,
921 manifest_service_channel_handle); 927 manifest_service_channel_handle);
922 } else { 928 } else {
923 // Attempt to open more than 1 browser channel is not supported. 929 // Attempt to open more than 1 browser channel is not supported.
924 // Shut down the NaCl process. 930 // Shut down the NaCl process.
925 process_->GetHost()->ForceShutdown(); 931 process_->GetHost()->ForceShutdown();
926 } 932 }
927 } 933 }
928 934
935 void NaClProcessHost::OnDebugStubPortSelected(uint16_t debug_stub_port) {
936 ChangeDebugStubPort(debug_stub_port);
Mark Seaborn 2014/05/08 15:52:23 Can you add: CHECK(!uses_nonsfi_mode_) to make thi
bradn 2014/05/08 17:00:24 Done.
937 }
938
929 bool NaClProcessHost::StartWithLaunchedProcess() { 939 bool NaClProcessHost::StartWithLaunchedProcess() {
930 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); 940 NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
931 941
932 if (nacl_browser->IsReady()) { 942 if (nacl_browser->IsReady()) {
933 return StartNaClExecution(); 943 return StartNaClExecution();
934 } else if (nacl_browser->IsOk()) { 944 } else if (nacl_browser->IsOk()) {
935 nacl_browser->WaitForResources( 945 nacl_browser->WaitForResources(
936 base::Bind(&NaClProcessHost::OnResourcesReady, 946 base::Bind(&NaClProcessHost::OnResourcesReady,
937 weak_factory_.GetWeakPtr())); 947 weak_factory_.GetWeakPtr()));
938 return true; 948 return true;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 process_handle.Take(), info, 1102 process_handle.Take(), info,
1093 base::MessageLoopProxy::current(), 1103 base::MessageLoopProxy::current(),
1094 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 1104 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
1095 weak_factory_.GetWeakPtr())); 1105 weak_factory_.GetWeakPtr()));
1096 return true; 1106 return true;
1097 } 1107 }
1098 } 1108 }
1099 #endif 1109 #endif
1100 1110
1101 } // namespace nacl 1111 } // namespace nacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698