OLD | NEW |
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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 } | 142 } |
143 | 143 |
144 bool NaClProcessHost::PluginListener::OnMessageReceived( | 144 bool NaClProcessHost::PluginListener::OnMessageReceived( |
145 const IPC::Message& msg) { | 145 const IPC::Message& msg) { |
146 return host_->OnUntrustedMessageForwarded(msg); | 146 return host_->OnUntrustedMessageForwarded(msg); |
147 } | 147 } |
148 | 148 |
149 NaClProcessHost::NaClProcessHost(const GURL& manifest_url, | 149 NaClProcessHost::NaClProcessHost(const GURL& manifest_url, |
150 int render_view_id, | 150 int render_view_id, |
151 uint32 permission_bits, | 151 uint32 permission_bits, |
| 152 bool uses_irt, |
152 bool off_the_record) | 153 bool off_the_record) |
153 : manifest_url_(manifest_url), | 154 : manifest_url_(manifest_url), |
154 permissions_(GetNaClPermissions(permission_bits)), | 155 permissions_(GetNaClPermissions(permission_bits)), |
155 #if defined(OS_WIN) | 156 #if defined(OS_WIN) |
156 process_launched_by_broker_(false), | 157 process_launched_by_broker_(false), |
157 #elif defined(OS_LINUX) | 158 #elif defined(OS_LINUX) |
158 wait_for_nacl_gdb_(false), | 159 wait_for_nacl_gdb_(false), |
159 #endif | 160 #endif |
160 reply_msg_(NULL), | 161 reply_msg_(NULL), |
161 #if defined(OS_WIN) | 162 #if defined(OS_WIN) |
162 debug_exception_handler_requested_(false), | 163 debug_exception_handler_requested_(false), |
163 #endif | 164 #endif |
164 internal_(new NaClInternal()), | 165 internal_(new NaClInternal()), |
165 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), | 166 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
166 enable_exception_handling_(false), | 167 enable_exception_handling_(false), |
167 enable_debug_stub_(false), | 168 enable_debug_stub_(false), |
| 169 uses_irt_(uses_irt), |
168 off_the_record_(off_the_record), | 170 off_the_record_(off_the_record), |
169 enable_ipc_proxy_(false), | 171 enable_ipc_proxy_(false), |
170 ALLOW_THIS_IN_INITIALIZER_LIST(ipc_plugin_listener_(this)), | 172 ALLOW_THIS_IN_INITIALIZER_LIST(ipc_plugin_listener_(this)), |
171 render_view_id_(render_view_id) { | 173 render_view_id_(render_view_id) { |
172 process_.reset(content::BrowserChildProcessHost::Create( | 174 process_.reset(content::BrowserChildProcessHost::Create( |
173 content::PROCESS_TYPE_NACL_LOADER, this)); | 175 content::PROCESS_TYPE_NACL_LOADER, this)); |
174 | 176 |
175 // Set the display name so the user knows what plugin the process is running. | 177 // Set the display name so the user knows what plugin the process is running. |
176 // We aren't on the UI thread so getting the pref locale for language | 178 // We aren't on the UI thread so getting the pref locale for language |
177 // formatting isn't possible, so IDN will be lost, but this is probably OK | 179 // formatting isn't possible, so IDN will be lost, but this is probably OK |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); | 701 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); |
700 | 702 |
701 nacl::NaClStartParams params; | 703 nacl::NaClStartParams params; |
702 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled(); | 704 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled(); |
703 params.validation_cache_key = nacl_browser->GetValidationCacheKey(); | 705 params.validation_cache_key = nacl_browser->GetValidationCacheKey(); |
704 params.version = chrome::VersionInfo().CreateVersionString(); | 706 params.version = chrome::VersionInfo().CreateVersionString(); |
705 params.enable_exception_handling = enable_exception_handling_; | 707 params.enable_exception_handling = enable_exception_handling_; |
706 params.enable_debug_stub = enable_debug_stub_ && | 708 params.enable_debug_stub = enable_debug_stub_ && |
707 NaClBrowser::GetInstance()->URLMatchesDebugPatterns(manifest_url_); | 709 NaClBrowser::GetInstance()->URLMatchesDebugPatterns(manifest_url_); |
708 params.enable_ipc_proxy = enable_ipc_proxy_; | 710 params.enable_ipc_proxy = enable_ipc_proxy_; |
709 | 711 params.uses_irt = uses_irt_; |
710 base::PlatformFile irt_file = nacl_browser->IrtFile(); | |
711 CHECK_NE(irt_file, base::kInvalidPlatformFileValue); | |
712 | 712 |
713 const ChildProcessData& data = process_->GetData(); | 713 const ChildProcessData& data = process_->GetData(); |
714 if (!ShareHandleToSelLdr(data.handle, | 714 if (!ShareHandleToSelLdr(data.handle, |
715 internal_->socket_for_sel_ldr, true, | 715 internal_->socket_for_sel_ldr, true, |
716 ¶ms.handles)) { | 716 ¶ms.handles)) { |
717 return false; | 717 return false; |
718 } | 718 } |
719 | 719 |
720 // Send over the IRT file handle. We don't close our own copy! | 720 if (params.uses_irt) { |
721 if (!ShareHandleToSelLdr(data.handle, irt_file, false, ¶ms.handles)) | 721 base::PlatformFile irt_file = nacl_browser->IrtFile(); |
722 return false; | 722 CHECK_NE(irt_file, base::kInvalidPlatformFileValue); |
| 723 |
| 724 // Send over the IRT file handle. We don't close our own copy! |
| 725 if (!ShareHandleToSelLdr(data.handle, irt_file, false, ¶ms.handles)) |
| 726 return false; |
| 727 } |
723 | 728 |
724 #if defined(OS_MACOSX) | 729 #if defined(OS_MACOSX) |
725 // For dynamic loading support, NaCl requires a file descriptor that | 730 // For dynamic loading support, NaCl requires a file descriptor that |
726 // was created in /tmp, since those created with shm_open() are not | 731 // was created in /tmp, since those created with shm_open() are not |
727 // mappable with PROT_EXEC. Rather than requiring an extra IPC | 732 // mappable with PROT_EXEC. Rather than requiring an extra IPC |
728 // round trip out of the sandbox, we create an FD here. | 733 // round trip out of the sandbox, we create an FD here. |
729 base::SharedMemory memory_buffer; | 734 base::SharedMemory memory_buffer; |
730 base::SharedMemoryCreateOptions options; | 735 base::SharedMemoryCreateOptions options; |
731 options.size = 1; | 736 options.size = 1; |
732 options.executable = true; | 737 options.executable = true; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 } else { | 927 } else { |
923 NaClStartDebugExceptionHandlerThread( | 928 NaClStartDebugExceptionHandlerThread( |
924 process_handle.Take(), info, | 929 process_handle.Take(), info, |
925 base::MessageLoopProxy::current(), | 930 base::MessageLoopProxy::current(), |
926 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 931 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
927 weak_factory_.GetWeakPtr())); | 932 weak_factory_.GetWeakPtr())); |
928 return true; | 933 return true; |
929 } | 934 } |
930 } | 935 } |
931 #endif | 936 #endif |
OLD | NEW |