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

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 22 matching lines...) Expand all
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/browser/pepper_helper.h" 37 #include "content/public/browser/pepper_helper.h"
38 #include "content/public/common/child_process_host.h" 38 #include "content/public/common/child_process_host.h"
39 #include "ipc/ipc_channel.h" 39 #include "ipc/ipc_channel.h"
40 #include "ipc/ipc_switches.h" 40 #include "ipc/ipc_switches.h"
41 #include "native_client/src/shared/imc/nacl_imc.h" 41 #include "native_client/src/shared/imc/nacl_imc.h"
42 #include "net/base/net_util.h" 42 #include "net/base/net_util.h"
43 #include "net/base/tcp_listen_socket.h"
43 #include "ppapi/proxy/ppapi_messages.h" 44 #include "ppapi/proxy/ppapi_messages.h"
44 45
45 #if defined(OS_POSIX) 46 #if defined(OS_POSIX)
46 #include <fcntl.h> 47 #include <fcntl.h>
47 48
48 #include "ipc/ipc_channel_posix.h" 49 #include "ipc/ipc_channel_posix.h"
49 #elif defined(OS_WIN) 50 #elif defined(OS_WIN)
50 #include <windows.h> 51 #include <windows.h>
51 52
52 #include "base/threading/thread.h" 53 #include "base/threading/thread.h"
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 628
628 ChromeViewHostMsg_LaunchNaCl::WriteReplyParams( 629 ChromeViewHostMsg_LaunchNaCl::WriteReplyParams(
629 reply_msg_, handles_for_renderer, channel_handle); 630 reply_msg_, handles_for_renderer, channel_handle);
630 chrome_render_message_filter_->Send(reply_msg_); 631 chrome_render_message_filter_->Send(reply_msg_);
631 chrome_render_message_filter_ = NULL; 632 chrome_render_message_filter_ = NULL;
632 reply_msg_ = NULL; 633 reply_msg_ = NULL;
633 internal_->sockets_for_renderer.clear(); 634 internal_->sockets_for_renderer.clear();
634 return true; 635 return true;
635 } 636 }
636 637
638 // TCP port we chose for NaCl debug stub. It can be any other number.
639 static const int kDebugStubPort = 4014;
640
641 #if defined(OS_POSIX)
642 SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() {
643 SocketDescriptor s = net::TCPListenSocket::CreateAndBind("127.0.0.1",
644 kDebugStubPort);
645 if (listen(s, 1)) {
646 LOG(ERROR) << "listen() failed on debug stub socket";
647 return net::TCPListenSocket::kInvalidSocket;
648 }
649 return s;
650 }
651 #endif
652
637 bool NaClProcessHost::StartNaClExecution() { 653 bool NaClProcessHost::StartNaClExecution() {
638 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); 654 NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
639 655
640 nacl::NaClStartParams params; 656 nacl::NaClStartParams params;
641 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled(); 657 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled();
642 params.validation_cache_key = nacl_browser->GetValidationCacheKey(); 658 params.validation_cache_key = nacl_browser->GetValidationCacheKey();
643 params.version = chrome::VersionInfo().CreateVersionString(); 659 params.version = chrome::VersionInfo().CreateVersionString();
644 params.enable_exception_handling = enable_exception_handling_; 660 params.enable_exception_handling = enable_exception_handling_;
645 params.enable_debug_stub = enable_debug_stub_; 661 params.enable_debug_stub = enable_debug_stub_;
646 params.enable_ipc_proxy = enable_ipc_proxy_; 662 params.enable_ipc_proxy = enable_ipc_proxy_;
(...skipping 30 matching lines...) Expand all
677 nacl::FileDescriptor memory_fd; 693 nacl::FileDescriptor memory_fd;
678 memory_fd.fd = dup(memory_buffer.handle().fd); 694 memory_fd.fd = dup(memory_buffer.handle().fd);
679 if (memory_fd.fd < 0) { 695 if (memory_fd.fd < 0) {
680 DLOG(ERROR) << "Failed to dup() a file descriptor"; 696 DLOG(ERROR) << "Failed to dup() a file descriptor";
681 return false; 697 return false;
682 } 698 }
683 memory_fd.auto_close = true; 699 memory_fd.auto_close = true;
684 params.handles.push_back(memory_fd); 700 params.handles.push_back(memory_fd);
685 #endif 701 #endif
686 702
703 #if defined(OS_POSIX)
704 if (enable_debug_stub_) {
705 SocketDescriptor server_bound_socket = GetDebugStubSocketHandle();
706 if (server_bound_socket != net::TCPListenSocket::kInvalidSocket) {
707 params.debug_stub_server_bound_socket =
708 nacl::FileDescriptor(server_bound_socket, true);
709 }
710 }
711 #endif
712
687 process_->Send(new NaClProcessMsg_Start(params)); 713 process_->Send(new NaClProcessMsg_Start(params));
688 714
689 internal_->sockets_for_sel_ldr.clear(); 715 internal_->sockets_for_sel_ldr.clear();
690 return true; 716 return true;
691 } 717 }
692 718
693 bool NaClProcessHost::SendStart() { 719 bool NaClProcessHost::SendStart() {
694 if (!enable_ipc_proxy_) { 720 if (!enable_ipc_proxy_) {
695 if (!ReplyToRenderer(IPC::ChannelHandle())) 721 if (!ReplyToRenderer(IPC::ChannelHandle()))
696 return false; 722 return false;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 } else { 869 } else {
844 NaClStartDebugExceptionHandlerThread( 870 NaClStartDebugExceptionHandlerThread(
845 process_handle.Take(), info, 871 process_handle.Take(), info,
846 base::MessageLoopProxy::current(), 872 base::MessageLoopProxy::current(),
847 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 873 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
848 weak_factory_.GetWeakPtr())); 874 weak_factory_.GetWeakPtr()));
849 return true; 875 return true;
850 } 876 }
851 } 877 }
852 #endif 878 #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