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

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

Issue 10625007: Revert 143656 - Add an IPC channel between the NaCl loader process and the renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // for this use case. 138 // for this use case.
139 process_->SetName(net::FormatUrl(manifest_url_, std::string())); 139 process_->SetName(net::FormatUrl(manifest_url_, std::string()));
140 140
141 // We allow untrusted hardware exception handling to be enabled via 141 // We allow untrusted hardware exception handling to be enabled via
142 // an env var for consistency with the standalone build of NaCl. 142 // an env var for consistency with the standalone build of NaCl.
143 if (CommandLine::ForCurrentProcess()->HasSwitch( 143 if (CommandLine::ForCurrentProcess()->HasSwitch(
144 switches::kEnableNaClExceptionHandling) || 144 switches::kEnableNaClExceptionHandling) ||
145 getenv("NACL_UNTRUSTED_EXCEPTION_HANDLING") != NULL) { 145 getenv("NACL_UNTRUSTED_EXCEPTION_HANDLING") != NULL) {
146 enable_exception_handling_ = true; 146 enable_exception_handling_ = true;
147 } 147 }
148
149 enable_ipc_proxy_ = CommandLine::ForCurrentProcess()->HasSwitch(
150 switches::kEnableNaClIPCProxy);
151 } 148 }
152 149
153 NaClProcessHost::~NaClProcessHost() { 150 NaClProcessHost::~NaClProcessHost() {
154 int exit_code; 151 int exit_code;
155 process_->GetTerminationStatus(&exit_code); 152 process_->GetTerminationStatus(&exit_code);
156 std::string message = 153 std::string message =
157 base::StringPrintf("NaCl process exited with status %i (0x%x)", 154 base::StringPrintf("NaCl process exited with status %i (0x%x)",
158 exit_code, exit_code); 155 exit_code, exit_code);
159 if (exit_code == 0) { 156 if (exit_code == 0) {
160 LOG(INFO) << message; 157 LOG(INFO) << message;
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 bool handled = true; 530 bool handled = true;
534 IPC_BEGIN_MESSAGE_MAP(NaClProcessHost, msg) 531 IPC_BEGIN_MESSAGE_MAP(NaClProcessHost, msg)
535 IPC_MESSAGE_HANDLER(NaClProcessMsg_QueryKnownToValidate, 532 IPC_MESSAGE_HANDLER(NaClProcessMsg_QueryKnownToValidate,
536 OnQueryKnownToValidate) 533 OnQueryKnownToValidate)
537 IPC_MESSAGE_HANDLER(NaClProcessMsg_SetKnownToValidate, 534 IPC_MESSAGE_HANDLER(NaClProcessMsg_SetKnownToValidate,
538 OnSetKnownToValidate) 535 OnSetKnownToValidate)
539 #if defined(OS_WIN) 536 #if defined(OS_WIN)
540 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClProcessMsg_AttachDebugExceptionHandler, 537 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClProcessMsg_AttachDebugExceptionHandler,
541 OnAttachDebugExceptionHandler) 538 OnAttachDebugExceptionHandler)
542 #endif 539 #endif
543 IPC_MESSAGE_HANDLER(NaClProcessHostMsg_PpapiChannelCreated,
544 OnPpapiChannelCreated)
545 IPC_MESSAGE_UNHANDLED(handled = false) 540 IPC_MESSAGE_UNHANDLED(handled = false)
546 IPC_END_MESSAGE_MAP() 541 IPC_END_MESSAGE_MAP()
547 return handled; 542 return handled;
548 } 543 }
549 544
550 void NaClProcessHost::OnProcessLaunched() { 545 void NaClProcessHost::OnProcessLaunched() {
551 if (!StartWithLaunchedProcess()) 546 if (!StartWithLaunchedProcess())
552 delete this; 547 delete this;
553 } 548 }
554 549
555 // Called when the NaClBrowser singleton has been fully initialized. 550 // Called when the NaClBrowser singleton has been fully initialized.
556 void NaClProcessHost::OnResourcesReady() { 551 void NaClProcessHost::OnResourcesReady() {
557 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); 552 NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
558 if (!nacl_browser->IsReady() || !SendStart()) { 553 if (!nacl_browser->IsReady() || !SendStart()) {
559 DLOG(ERROR) << "Cannot launch NaCl process"; 554 DLOG(ERROR) << "Cannot launch NaCl process";
560 delete this; 555 delete this;
561 } 556 }
562 } 557 }
563 558
564 bool NaClProcessHost::ReplyToRenderer( 559 bool NaClProcessHost::ReplyToRenderer() {
565 const IPC::ChannelHandle& channel_handle) {
566 std::vector<nacl::FileDescriptor> handles_for_renderer; 560 std::vector<nacl::FileDescriptor> handles_for_renderer;
567 for (size_t i = 0; i < internal_->sockets_for_renderer.size(); i++) { 561 for (size_t i = 0; i < internal_->sockets_for_renderer.size(); i++) {
568 #if defined(OS_WIN) 562 #if defined(OS_WIN)
569 // Copy the handle into the renderer process. 563 // Copy the handle into the renderer process.
570 HANDLE handle_in_renderer; 564 HANDLE handle_in_renderer;
571 if (!DuplicateHandle(base::GetCurrentProcessHandle(), 565 if (!DuplicateHandle(base::GetCurrentProcessHandle(),
572 reinterpret_cast<HANDLE>( 566 reinterpret_cast<HANDLE>(
573 internal_->sockets_for_renderer[i]), 567 internal_->sockets_for_renderer[i]),
574 chrome_render_message_filter_->peer_handle(), 568 chrome_render_message_filter_->peer_handle(),
575 &handle_in_renderer, 569 &handle_in_renderer,
(...skipping 23 matching lines...) Expand all
599 // BrokerDuplicateHandle(). 593 // BrokerDuplicateHandle().
600 if (RunningOnWOW64()) { 594 if (RunningOnWOW64()) {
601 if (!content::BrokerAddTargetPeer(process_->GetData().handle)) { 595 if (!content::BrokerAddTargetPeer(process_->GetData().handle)) {
602 DLOG(ERROR) << "Failed to add NaCl process PID"; 596 DLOG(ERROR) << "Failed to add NaCl process PID";
603 return false; 597 return false;
604 } 598 }
605 } 599 }
606 #endif 600 #endif
607 601
608 ChromeViewHostMsg_LaunchNaCl::WriteReplyParams( 602 ChromeViewHostMsg_LaunchNaCl::WriteReplyParams(
609 reply_msg_, handles_for_renderer, channel_handle); 603 reply_msg_, handles_for_renderer);
610 chrome_render_message_filter_->Send(reply_msg_); 604 chrome_render_message_filter_->Send(reply_msg_);
611 chrome_render_message_filter_ = NULL; 605 chrome_render_message_filter_ = NULL;
612 reply_msg_ = NULL; 606 reply_msg_ = NULL;
613 internal_->sockets_for_renderer.clear(); 607 internal_->sockets_for_renderer.clear();
614 return true; 608 return true;
615 } 609 }
616 610
617 bool NaClProcessHost::StartNaClExecution() { 611 bool NaClProcessHost::StartNaClExecution() {
618 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); 612 NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
619 613
620 nacl::NaClStartParams params; 614 nacl::NaClStartParams params;
621 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled(); 615 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled();
622 params.validation_cache_key = nacl_browser->GetValidationCacheKey(); 616 params.validation_cache_key = nacl_browser->GetValidationCacheKey();
623 params.version = chrome::VersionInfo().CreateVersionString(); 617 params.version = chrome::VersionInfo().CreateVersionString();
624 params.enable_exception_handling = enable_exception_handling_; 618 params.enable_exception_handling = enable_exception_handling_;
625 params.enable_debug_stub = 619 params.enable_debug_stub =
626 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableNaClDebug); 620 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableNaClDebug);
627 params.enable_ipc_proxy = enable_ipc_proxy_;
628 621
629 base::PlatformFile irt_file = nacl_browser->IrtFile(); 622 base::PlatformFile irt_file = nacl_browser->IrtFile();
630 CHECK_NE(irt_file, base::kInvalidPlatformFileValue); 623 CHECK_NE(irt_file, base::kInvalidPlatformFileValue);
631 624
632 const ChildProcessData& data = process_->GetData(); 625 const ChildProcessData& data = process_->GetData();
633 for (size_t i = 0; i < internal_->sockets_for_sel_ldr.size(); i++) { 626 for (size_t i = 0; i < internal_->sockets_for_sel_ldr.size(); i++) {
634 if (!ShareHandleToSelLdr(data.handle, 627 if (!ShareHandleToSelLdr(data.handle,
635 internal_->sockets_for_sel_ldr[i], true, 628 internal_->sockets_for_sel_ldr[i], true,
636 &params.handles)) { 629 &params.handles)) {
637 return false; 630 return false;
(...skipping 27 matching lines...) Expand all
665 params.handles.push_back(memory_fd); 658 params.handles.push_back(memory_fd);
666 #endif 659 #endif
667 660
668 process_->Send(new NaClProcessMsg_Start(params)); 661 process_->Send(new NaClProcessMsg_Start(params));
669 662
670 internal_->sockets_for_sel_ldr.clear(); 663 internal_->sockets_for_sel_ldr.clear();
671 return true; 664 return true;
672 } 665 }
673 666
674 bool NaClProcessHost::SendStart() { 667 bool NaClProcessHost::SendStart() {
675 if (!enable_ipc_proxy_) { 668 return ReplyToRenderer() && StartNaClExecution();
676 if (!ReplyToRenderer(IPC::ChannelHandle()))
677 return false;
678 }
679 return StartNaClExecution();
680 }
681
682 void NaClProcessHost::OnPpapiChannelCreated(
683 const IPC::ChannelHandle& channel_handle) {
684 DCHECK(enable_ipc_proxy_);
685 ReplyToRenderer(channel_handle);
686 } 669 }
687 670
688 bool NaClProcessHost::StartWithLaunchedProcess() { 671 bool NaClProcessHost::StartWithLaunchedProcess() {
689 #if defined(OS_LINUX) 672 #if defined(OS_LINUX)
690 if (wait_for_nacl_gdb_) { 673 if (wait_for_nacl_gdb_) {
691 if (LaunchNaClGdb(base::GetProcId(process_->GetData().handle))) { 674 if (LaunchNaClGdb(base::GetProcId(process_->GetData().handle))) {
692 // We will be called with wait_for_nacl_gdb_ = false once debugger is 675 // We will be called with wait_for_nacl_gdb_ = false once debugger is
693 // attached to the program. 676 // attached to the program.
694 return true; 677 return true;
695 } 678 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 } else { 765 } else {
783 NaClStartDebugExceptionHandlerThread( 766 NaClStartDebugExceptionHandlerThread(
784 process_handle.Take(), info, 767 process_handle.Take(), info,
785 base::MessageLoopProxy::current(), 768 base::MessageLoopProxy::current(),
786 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 769 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
787 weak_factory_.GetWeakPtr())); 770 weak_factory_.GetWeakPtr()));
788 return true; 771 return true;
789 } 772 }
790 } 773 }
791 #endif 774 #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