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

Side by Side Diff: chrome/browser/nacl_host/nacl_process_host.cc

Issue 10928050: Open socket for NaCl GDB debug stub in browser process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 | « chrome/browser/nacl_host/nacl_process_host.h ('k') | chrome/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 "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 21 matching lines...) Expand all
32 #include "chrome/common/nacl_messages.h" 32 #include "chrome/common/nacl_messages.h"
33 #include "chrome/common/render_messages.h" 33 #include "chrome/common/render_messages.h"
34 #include "chrome/common/url_constants.h" 34 #include "chrome/common/url_constants.h"
35 #include "content/public/browser/browser_child_process_host.h" 35 #include "content/public/browser/browser_child_process_host.h"
36 #include "content/public/browser/child_process_data.h" 36 #include "content/public/browser/child_process_data.h"
37 #include "content/public/common/child_process_host.h" 37 #include "content/public/common/child_process_host.h"
38 #include "ipc/ipc_channel.h" 38 #include "ipc/ipc_channel.h"
39 #include "ipc/ipc_switches.h" 39 #include "ipc/ipc_switches.h"
40 #include "native_client/src/shared/imc/nacl_imc.h" 40 #include "native_client/src/shared/imc/nacl_imc.h"
41 #include "net/base/net_util.h" 41 #include "net/base/net_util.h"
42 #include "net/base/tcp_listen_socket.h"
42 #include "ppapi/proxy/ppapi_messages.h" 43 #include "ppapi/proxy/ppapi_messages.h"
43 44
44 #if defined(OS_POSIX) 45 #if defined(OS_POSIX)
45 #include <fcntl.h> 46 #include <fcntl.h>
46 47
47 #include "ipc/ipc_channel_posix.h" 48 #include "ipc/ipc_channel_posix.h"
48 #elif defined(OS_WIN) 49 #elif defined(OS_WIN)
49 #include <windows.h> 50 #include <windows.h>
50 51
51 #include "base/threading/thread.h" 52 #include "base/threading/thread.h"
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 627
627 ChromeViewHostMsg_LaunchNaCl::WriteReplyParams( 628 ChromeViewHostMsg_LaunchNaCl::WriteReplyParams(
628 reply_msg_, handles_for_renderer, channel_handle); 629 reply_msg_, handles_for_renderer, channel_handle);
629 chrome_render_message_filter_->Send(reply_msg_); 630 chrome_render_message_filter_->Send(reply_msg_);
630 chrome_render_message_filter_ = NULL; 631 chrome_render_message_filter_ = NULL;
631 reply_msg_ = NULL; 632 reply_msg_ = NULL;
632 internal_->sockets_for_renderer.clear(); 633 internal_->sockets_for_renderer.clear();
633 return true; 634 return true;
634 } 635 }
635 636
637 // TCP port we chosen for NaCl debug stub. It can be any other number.
Mark Seaborn 2012/09/13 18:19:04 'chose'
halyavin 2012/09/13 19:03:30 Done.
638 static const int kDebugStubPort = 4014;
639
640 #if defined(OS_POSIX)
641 SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() {
642 SocketDescriptor s = net::TCPListenSocket::CreateAndBind("127.0.0.1",
643 kDebugStubPort);
644 if (listen(s, 1)) {
645 LOG(ERROR) << "listen() failed on debug stub socket";
646 return net::TCPListenSocket::kInvalidSocket;
647 }
648 return s;
649 }
650 #endif
651
636 bool NaClProcessHost::StartNaClExecution() { 652 bool NaClProcessHost::StartNaClExecution() {
637 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); 653 NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
638 654
639 nacl::NaClStartParams params; 655 nacl::NaClStartParams params;
640 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled(); 656 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled();
641 params.validation_cache_key = nacl_browser->GetValidationCacheKey(); 657 params.validation_cache_key = nacl_browser->GetValidationCacheKey();
642 params.version = chrome::VersionInfo().CreateVersionString(); 658 params.version = chrome::VersionInfo().CreateVersionString();
643 params.enable_exception_handling = enable_exception_handling_; 659 params.enable_exception_handling = enable_exception_handling_;
644 params.enable_debug_stub = enable_debug_stub_; 660 params.enable_debug_stub = enable_debug_stub_;
645 params.enable_ipc_proxy = enable_ipc_proxy_; 661 params.enable_ipc_proxy = enable_ipc_proxy_;
(...skipping 30 matching lines...) Expand all
676 nacl::FileDescriptor memory_fd; 692 nacl::FileDescriptor memory_fd;
677 memory_fd.fd = dup(memory_buffer.handle().fd); 693 memory_fd.fd = dup(memory_buffer.handle().fd);
678 if (memory_fd.fd < 0) { 694 if (memory_fd.fd < 0) {
679 DLOG(ERROR) << "Failed to dup() a file descriptor"; 695 DLOG(ERROR) << "Failed to dup() a file descriptor";
680 return false; 696 return false;
681 } 697 }
682 memory_fd.auto_close = true; 698 memory_fd.auto_close = true;
683 params.handles.push_back(memory_fd); 699 params.handles.push_back(memory_fd);
684 #endif 700 #endif
685 701
702 #if defined(OS_POSIX)
703 if (enable_debug_stub_) {
704 SocketDescriptor server_bound_socket = GetDebugStubSocketHandle();
705 if (server_bound_socket != net::TCPListenSocket::kInvalidSocket) {
706 params.debug_stub_server_bound_socket =
707 nacl::FileDescriptor(server_bound_socket, true);
708 }
709 }
710 #endif
711
686 process_->Send(new NaClProcessMsg_Start(params)); 712 process_->Send(new NaClProcessMsg_Start(params));
687 713
688 internal_->sockets_for_sel_ldr.clear(); 714 internal_->sockets_for_sel_ldr.clear();
689 return true; 715 return true;
690 } 716 }
691 717
692 bool NaClProcessHost::SendStart() { 718 bool NaClProcessHost::SendStart() {
693 if (!enable_ipc_proxy_) { 719 if (!enable_ipc_proxy_) {
694 if (!ReplyToRenderer(IPC::ChannelHandle())) 720 if (!ReplyToRenderer(IPC::ChannelHandle()))
695 return false; 721 return false;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 } else { 864 } else {
839 NaClStartDebugExceptionHandlerThread( 865 NaClStartDebugExceptionHandlerThread(
840 process_handle.Take(), info, 866 process_handle.Take(), info,
841 base::MessageLoopProxy::current(), 867 base::MessageLoopProxy::current(),
842 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 868 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
843 weak_factory_.GetWeakPtr())); 869 weak_factory_.GetWeakPtr()));
844 return true; 870 return true;
845 } 871 }
846 } 872 }
847 #endif 873 #endif
OLDNEW
« no previous file with comments | « chrome/browser/nacl_host/nacl_process_host.h ('k') | chrome/common/nacl_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698