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

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

Issue 11783112: Remove the NaCl SRPC proxy from Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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/chrome_switches.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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 reply_msg_(NULL), 161 reply_msg_(NULL),
162 #if defined(OS_WIN) 162 #if defined(OS_WIN)
163 debug_exception_handler_requested_(false), 163 debug_exception_handler_requested_(false),
164 #endif 164 #endif
165 internal_(new NaClInternal()), 165 internal_(new NaClInternal()),
166 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), 166 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
167 enable_exception_handling_(false), 167 enable_exception_handling_(false),
168 enable_debug_stub_(false), 168 enable_debug_stub_(false),
169 uses_irt_(uses_irt), 169 uses_irt_(uses_irt),
170 off_the_record_(off_the_record), 170 off_the_record_(off_the_record),
171 enable_ipc_proxy_(false),
172 ALLOW_THIS_IN_INITIALIZER_LIST(ipc_plugin_listener_(this)), 171 ALLOW_THIS_IN_INITIALIZER_LIST(ipc_plugin_listener_(this)),
173 render_view_id_(render_view_id) { 172 render_view_id_(render_view_id) {
174 process_.reset(content::BrowserChildProcessHost::Create( 173 process_.reset(content::BrowserChildProcessHost::Create(
175 content::PROCESS_TYPE_NACL_LOADER, this)); 174 content::PROCESS_TYPE_NACL_LOADER, this));
176 175
177 // Set the display name so the user knows what plugin the process is running. 176 // Set the display name so the user knows what plugin the process is running.
178 // We aren't on the UI thread so getting the pref locale for language 177 // We aren't on the UI thread so getting the pref locale for language
179 // formatting isn't possible, so IDN will be lost, but this is probably OK 178 // formatting isn't possible, so IDN will be lost, but this is probably OK
180 // for this use case. 179 // for this use case.
181 process_->SetName(net::FormatUrl(manifest_url_, std::string())); 180 process_->SetName(net::FormatUrl(manifest_url_, std::string()));
182 181
183 // We allow untrusted hardware exception handling to be enabled via 182 // We allow untrusted hardware exception handling to be enabled via
184 // an env var for consistency with the standalone build of NaCl. 183 // an env var for consistency with the standalone build of NaCl.
185 if (CommandLine::ForCurrentProcess()->HasSwitch( 184 if (CommandLine::ForCurrentProcess()->HasSwitch(
186 switches::kEnableNaClExceptionHandling) || 185 switches::kEnableNaClExceptionHandling) ||
187 getenv("NACL_UNTRUSTED_EXCEPTION_HANDLING") != NULL) { 186 getenv("NACL_UNTRUSTED_EXCEPTION_HANDLING") != NULL) {
188 enable_exception_handling_ = true; 187 enable_exception_handling_ = true;
189 } 188 }
190 enable_debug_stub_ = CommandLine::ForCurrentProcess()->HasSwitch( 189 enable_debug_stub_ = CommandLine::ForCurrentProcess()->HasSwitch(
191 switches::kEnableNaClDebug); 190 switches::kEnableNaClDebug);
192
193 enable_ipc_proxy_ = !CommandLine::ForCurrentProcess()->HasSwitch(
194 switches::kEnableNaClSRPCProxy);
195 // If render_view_id == 0 we do not need PPAPI, so we can skip
196 // PPAPI IPC proxy channel creation, etc.
197 if (!render_view_id_)
198 enable_ipc_proxy_ = false;
199 } 191 }
200 192
201 NaClProcessHost::~NaClProcessHost() { 193 NaClProcessHost::~NaClProcessHost() {
202 int exit_code; 194 int exit_code;
203 process_->GetTerminationStatus(&exit_code); 195 process_->GetTerminationStatus(&exit_code);
204 std::string message = 196 std::string message =
205 base::StringPrintf("NaCl process exited with status %i (0x%x)", 197 base::StringPrintf("NaCl process exited with status %i (0x%x)",
206 exit_code, exit_code); 198 exit_code, exit_code);
207 if (exit_code == 0) { 199 if (exit_code == 0) {
208 LOG(INFO) << message; 200 LOG(INFO) << message;
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 bool NaClProcessHost::StartNaClExecution() { 692 bool NaClProcessHost::StartNaClExecution() {
701 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); 693 NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
702 694
703 nacl::NaClStartParams params; 695 nacl::NaClStartParams params;
704 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled(); 696 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled();
705 params.validation_cache_key = nacl_browser->GetValidationCacheKey(); 697 params.validation_cache_key = nacl_browser->GetValidationCacheKey();
706 params.version = chrome::VersionInfo().CreateVersionString(); 698 params.version = chrome::VersionInfo().CreateVersionString();
707 params.enable_exception_handling = enable_exception_handling_; 699 params.enable_exception_handling = enable_exception_handling_;
708 params.enable_debug_stub = enable_debug_stub_ && 700 params.enable_debug_stub = enable_debug_stub_ &&
709 NaClBrowser::GetInstance()->URLMatchesDebugPatterns(manifest_url_); 701 NaClBrowser::GetInstance()->URLMatchesDebugPatterns(manifest_url_);
710 params.enable_ipc_proxy = enable_ipc_proxy_; 702 // Enable PPAPI proxy channel creation only for renderer processes.
703 params.enable_ipc_proxy = enable_ppapi_proxy();
711 params.uses_irt = uses_irt_; 704 params.uses_irt = uses_irt_;
712 705
713 const ChildProcessData& data = process_->GetData(); 706 const ChildProcessData& data = process_->GetData();
714 if (!ShareHandleToSelLdr(data.handle, 707 if (!ShareHandleToSelLdr(data.handle,
715 internal_->socket_for_sel_ldr, true, 708 internal_->socket_for_sel_ldr, true,
716 &params.handles)) { 709 &params.handles)) {
717 return false; 710 return false;
718 } 711 }
719 712
720 if (params.uses_irt) { 713 if (params.uses_irt) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 } 752 }
760 #endif 753 #endif
761 754
762 process_->Send(new NaClProcessMsg_Start(params)); 755 process_->Send(new NaClProcessMsg_Start(params));
763 756
764 internal_->socket_for_sel_ldr = nacl::kInvalidHandle; 757 internal_->socket_for_sel_ldr = nacl::kInvalidHandle;
765 return true; 758 return true;
766 } 759 }
767 760
768 bool NaClProcessHost::SendStart() { 761 bool NaClProcessHost::SendStart() {
769 if (!enable_ipc_proxy_) { 762 if (!enable_ppapi_proxy()) {
770 if (!ReplyToRenderer(IPC::ChannelHandle())) 763 if (!ReplyToRenderer(IPC::ChannelHandle()))
771 return false; 764 return false;
772 } 765 }
773 return StartNaClExecution(); 766 return StartNaClExecution();
774 } 767 }
775 768
776 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is 769 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is
777 // received or PpapiHostMsg_ChannelCreated is forwarded by our plugin 770 // received or PpapiHostMsg_ChannelCreated is forwarded by our plugin
778 // listener. 771 // listener.
779 void NaClProcessHost::OnPpapiChannelCreated( 772 void NaClProcessHost::OnPpapiChannelCreated(
780 const IPC::ChannelHandle& channel_handle) { 773 const IPC::ChannelHandle& channel_handle) {
781 DCHECK(enable_ipc_proxy_); 774 // Only renderer processes should create a channel.
775 DCHECK(enable_ppapi_proxy());
782 // If the proxy channel is null, this must be the initial NaCl-Browser IPC 776 // If the proxy channel is null, this must be the initial NaCl-Browser IPC
783 // channel. 777 // channel.
784 if (!ipc_proxy_channel_.get()) { 778 if (!ipc_proxy_channel_.get()) {
785 ipc_proxy_channel_.reset( 779 ipc_proxy_channel_.reset(
786 new IPC::ChannelProxy(channel_handle, 780 new IPC::ChannelProxy(channel_handle,
787 IPC::Channel::MODE_CLIENT, 781 IPC::Channel::MODE_CLIENT,
788 &ipc_plugin_listener_, 782 &ipc_plugin_listener_,
789 base::MessageLoopProxy::current())); 783 base::MessageLoopProxy::current()));
790 // Create the browser ppapi host and enable PPAPI message dispatching to the 784 // Create the browser ppapi host and enable PPAPI message dispatching to the
791 // browser process. 785 // browser process.
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 } else { 921 } else {
928 NaClStartDebugExceptionHandlerThread( 922 NaClStartDebugExceptionHandlerThread(
929 process_handle.Take(), info, 923 process_handle.Take(), info,
930 base::MessageLoopProxy::current(), 924 base::MessageLoopProxy::current(),
931 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 925 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
932 weak_factory_.GetWeakPtr())); 926 weak_factory_.GetWeakPtr()));
933 return true; 927 return true;
934 } 928 }
935 } 929 }
936 #endif 930 #endif
OLDNEW
« no previous file with comments | « chrome/browser/nacl_host/nacl_process_host.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698