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

Side by Side Diff: ppapi/native_client/src/trusted/plugin/plugin.cc

Issue 337463002: Remove LoadModule SRPC for non-SFI mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 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
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 "ppapi/native_client/src/trusted/plugin/plugin.h" 5 #include "ppapi/native_client/src/trusted/plugin/plugin.h"
6 6
7 #include <sys/stat.h> 7 #include <sys/stat.h>
8 #include <sys/types.h> 8 #include <sys/types.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 23 matching lines...) Expand all
34 34
35 namespace plugin { 35 namespace plugin {
36 36
37 namespace { 37 namespace {
38 38
39 // Up to 20 seconds 39 // Up to 20 seconds
40 const int64_t kTimeSmallMin = 1; // in ms 40 const int64_t kTimeSmallMin = 1; // in ms
41 const int64_t kTimeSmallMax = 20000; // in ms 41 const int64_t kTimeSmallMax = 20000; // in ms
42 const uint32_t kTimeSmallBuckets = 100; 42 const uint32_t kTimeSmallBuckets = 100;
43 43
44 const PP_NaClFileInfo kInvalidNaClFileInfo = {
45 PP_kInvalidFileHandle,
46 0, // token_lo
47 0, // token_hi
48 };
49
44 } // namespace 50 } // namespace
45 51
46 void Plugin::ShutDownSubprocesses() { 52 void Plugin::ShutDownSubprocesses() {
47 PLUGIN_PRINTF(("Plugin::ShutDownSubprocesses (this=%p)\n", 53 PLUGIN_PRINTF(("Plugin::ShutDownSubprocesses (this=%p)\n",
48 static_cast<void*>(this))); 54 static_cast<void*>(this)));
49 PLUGIN_PRINTF(("Plugin::ShutDownSubprocesses (%s)\n", 55 PLUGIN_PRINTF(("Plugin::ShutDownSubprocesses (%s)\n",
50 main_subprocess_.detailed_description().c_str())); 56 main_subprocess_.detailed_description().c_str()));
51 57
52 // Shut down service runtime. This must be done before all other calls so 58 // Shut down service runtime. This must be done before all other calls so
53 // they don't block forever when waiting for the upcall thread to exit. 59 // they don't block forever when waiting for the upcall thread to exit.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 const pp::CompletionCallback& crash_cb) { 166 const pp::CompletionCallback& crash_cb) {
161 CHECK(pp::Module::Get()->core()->IsMainThread()); 167 CHECK(pp::Module::Get()->core()->IsMainThread());
162 // Before forking a new sel_ldr process, ensure that we do not leak 168 // Before forking a new sel_ldr process, ensure that we do not leak
163 // the ServiceRuntime object for an existing subprocess, and that any 169 // the ServiceRuntime object for an existing subprocess, and that any
164 // associated listener threads do not go unjoined because if they 170 // associated listener threads do not go unjoined because if they
165 // outlive the Plugin object, they will not be memory safe. 171 // outlive the Plugin object, they will not be memory safe.
166 ShutDownSubprocesses(); 172 ShutDownSubprocesses();
167 pp::Var manifest_base_url = 173 pp::Var manifest_base_url =
168 pp::Var(pp::PASS_REF, nacl_interface_->GetManifestBaseURL(pp_instance())); 174 pp::Var(pp::PASS_REF, nacl_interface_->GetManifestBaseURL(pp_instance()));
169 std::string manifest_base_url_str = manifest_base_url.AsString(); 175 std::string manifest_base_url_str = manifest_base_url.AsString();
176
177 PP_NaClFileInfo file_info_for_srpc = kInvalidNaClFileInfo;
178 PP_NaClFileInfo file_info_for_ipc = kInvalidNaClFileInfo;
179 if (uses_nonsfi_mode) {
180 // In non-SFI mode, LaunchSelLdr is used to pass the nexe file's descriptor
181 // to the NaCl loader process.
182 file_info_for_ipc = file_info;
183 } else {
184 // Otherwise (i.e. in SFI-mode), LoadModule SRPC is still being used.
185 file_info_for_srpc = file_info;
186 }
187
170 SelLdrStartParams params(manifest_base_url_str, 188 SelLdrStartParams params(manifest_base_url_str,
189 file_info_for_ipc,
171 true /* uses_irt */, 190 true /* uses_irt */,
172 true /* uses_ppapi */, 191 true /* uses_ppapi */,
173 enable_dyncode_syscalls, 192 enable_dyncode_syscalls,
174 enable_exception_handling, 193 enable_exception_handling,
175 enable_crash_throttling); 194 enable_crash_throttling);
176 ErrorInfo error_info; 195 ErrorInfo error_info;
177 ServiceRuntime* service_runtime = new ServiceRuntime( 196 ServiceRuntime* service_runtime = new ServiceRuntime(
178 this, true, uses_nonsfi_mode, init_done_cb, crash_cb); 197 this, true, uses_nonsfi_mode, init_done_cb, crash_cb);
179 main_subprocess_.set_service_runtime(service_runtime); 198 main_subprocess_.set_service_runtime(service_runtime);
180 PLUGIN_PRINTF(("Plugin::LoadNaClModule (service_runtime=%p)\n", 199 PLUGIN_PRINTF(("Plugin::LoadNaClModule (service_runtime=%p)\n",
181 static_cast<void*>(service_runtime))); 200 static_cast<void*>(service_runtime)));
182 if (NULL == service_runtime) { 201 if (NULL == service_runtime) {
183 error_info.SetReport( 202 error_info.SetReport(
184 PP_NACL_ERROR_SEL_LDR_INIT, 203 PP_NACL_ERROR_SEL_LDR_INIT,
185 "sel_ldr init failure " + main_subprocess_.description()); 204 "sel_ldr init failure " + main_subprocess_.description());
186 ReportLoadError(error_info); 205 ReportLoadError(error_info);
187 return; 206 return;
188 } 207 }
189 208
190 // We don't take any action once nexe loading has completed, so pass an empty 209 // We don't take any action once nexe loading has completed, so pass an empty
191 // callback here for |callback|. 210 // callback here for |callback|.
192 pp::CompletionCallback callback = callback_factory_.NewCallback( 211 pp::CompletionCallback callback = callback_factory_.NewCallback(
193 &Plugin::LoadNexeAndStart, 212 &Plugin::LoadNexeAndStart,
194 service_runtime, file_info, pp::CompletionCallback()); 213 service_runtime, file_info_for_srpc, pp::CompletionCallback());
195 StartSelLdrOnMainThread( 214 StartSelLdrOnMainThread(
196 static_cast<int32_t>(PP_OK), service_runtime, params, callback); 215 static_cast<int32_t>(PP_OK), service_runtime, params, callback);
197 } 216 }
198 217
199 void Plugin::LoadNexeAndStart(int32_t pp_error, 218 void Plugin::LoadNexeAndStart(int32_t pp_error,
200 ServiceRuntime* service_runtime, 219 ServiceRuntime* service_runtime,
201 PP_NaClFileInfo file_info, 220 PP_NaClFileInfo file_info,
202 const pp::CompletionCallback& callback) { 221 const pp::CompletionCallback& callback) {
203 CHECK(pp::Module::Get()->core()->IsMainThread()); 222 CHECK(pp::Module::Get()->core()->IsMainThread());
204 if (pp_error != PP_OK) 223 if (pp_error != PP_OK)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 if (NULL == nacl_subprocess.get()) { 258 if (NULL == nacl_subprocess.get()) {
240 error_info->SetReport(PP_NACL_ERROR_SEL_LDR_INIT, 259 error_info->SetReport(PP_NACL_ERROR_SEL_LDR_INIT,
241 "unable to allocate helper subprocess."); 260 "unable to allocate helper subprocess.");
242 return NULL; 261 return NULL;
243 } 262 }
244 263
245 // Do not report UMA stats for translator-related nexes. 264 // Do not report UMA stats for translator-related nexes.
246 // TODO(sehr): define new UMA stats for translator related nexe events. 265 // TODO(sehr): define new UMA stats for translator related nexe events.
247 // NOTE: The PNaCl translator nexes are not built to use the IRT. This is 266 // NOTE: The PNaCl translator nexes are not built to use the IRT. This is
248 // done to save on address space and swap space. 267 // done to save on address space and swap space.
268 //
269 // Currently, this works only in SFI-mode. So, LoadModule SRPC is still used.
270 // So, pass kInvalidNaClFileInfo here, and instead |file_handle| is passed
271 // to LoadNaClModuleFromBackgroundThread() below.
272 // TODO(teravest, hidehiko): Pass file_handle to params, so that LaunchSelLdr
273 // will look at the info.
249 SelLdrStartParams params(helper_url, 274 SelLdrStartParams params(helper_url,
275 kInvalidNaClFileInfo,
250 false /* uses_irt */, 276 false /* uses_irt */,
251 false /* uses_ppapi */, 277 false /* uses_ppapi */,
252 false /* enable_dyncode_syscalls */, 278 false /* enable_dyncode_syscalls */,
253 false /* enable_exception_handling */, 279 false /* enable_exception_handling */,
254 true /* enable_crash_throttling */); 280 true /* enable_crash_throttling */);
255 281
256 // Helper NaCl modules always use the PNaCl manifest, as there is no 282 // Helper NaCl modules always use the PNaCl manifest, as there is no
257 // corresponding NMF. 283 // corresponding NMF.
258 if (!LoadHelperNaClModule(file_handle, nacl_subprocess.get(), params)) { 284 if (!LoadHelperNaClModule(file_handle, nacl_subprocess.get(), params)) {
259 return NULL; 285 return NULL;
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 551
526 void Plugin::SetExitStatusOnMainThread(int32_t pp_error, 552 void Plugin::SetExitStatusOnMainThread(int32_t pp_error,
527 int exit_status) { 553 int exit_status) {
528 DCHECK(pp::Module::Get()->core()->IsMainThread()); 554 DCHECK(pp::Module::Get()->core()->IsMainThread());
529 DCHECK(nacl_interface_); 555 DCHECK(nacl_interface_);
530 nacl_interface_->SetExitStatus(pp_instance(), exit_status); 556 nacl_interface_->SetExitStatus(pp_instance(), exit_status);
531 } 557 }
532 558
533 559
534 } // namespace plugin 560 } // namespace plugin
OLDNEW
« no previous file with comments | « ppapi/c/private/ppb_nacl_private.h ('k') | ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698