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

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

Issue 332333003: Remove redundant use_nonsfi_mode from SelLdrStartParams. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 void Plugin::HistogramTimeSmall(const std::string& name, 60 void Plugin::HistogramTimeSmall(const std::string& name,
61 int64_t ms) { 61 int64_t ms) {
62 if (ms < 0) return; 62 if (ms < 0) return;
63 uma_interface_.HistogramCustomTimes(name, 63 uma_interface_.HistogramCustomTimes(name,
64 ms, 64 ms,
65 kTimeSmallMin, kTimeSmallMax, 65 kTimeSmallMin, kTimeSmallMax,
66 kTimeSmallBuckets); 66 kTimeSmallBuckets);
67 } 67 }
68 68
69 bool Plugin::LoadNaClModuleFromBackgroundThread( 69 bool Plugin::LoadHelperNaClModule(PP_FileHandle file_handle,
70 PP_FileHandle file_handle, 70 NaClSubprocess* subprocess,
71 NaClSubprocess* subprocess, 71 const SelLdrStartParams& params) {
72 const SelLdrStartParams& params) {
73 CHECK(!pp::Module::Get()->core()->IsMainThread()); 72 CHECK(!pp::Module::Get()->core()->IsMainThread());
74 ServiceRuntime* service_runtime = 73 ServiceRuntime* service_runtime =
75 new ServiceRuntime(this, false, uses_nonsfi_mode_, 74 new ServiceRuntime(this,
75 false, // No main_service_runtime.
76 false, // No non-SFI mode (i.e. in SFI-mode).
76 pp::BlockUntilComplete(), pp::BlockUntilComplete()); 77 pp::BlockUntilComplete(), pp::BlockUntilComplete());
77 subprocess->set_service_runtime(service_runtime); 78 subprocess->set_service_runtime(service_runtime);
78 PLUGIN_PRINTF(("Plugin::LoadNaClModuleFromBackgroundThread " 79 PLUGIN_PRINTF(("Plugin::LoadHelperNaClModule "
79 "(service_runtime=%p)\n", 80 "(service_runtime=%p)\n",
80 static_cast<void*>(service_runtime))); 81 static_cast<void*>(service_runtime)));
81 82
82 // Now start the SelLdr instance. This must be created on the main thread. 83 // Now start the SelLdr instance. This must be created on the main thread.
83 bool service_runtime_started = false; 84 bool service_runtime_started = false;
84 pp::CompletionCallback sel_ldr_callback = 85 pp::CompletionCallback sel_ldr_callback =
85 callback_factory_.NewCallback(&Plugin::SignalStartSelLdrDone, 86 callback_factory_.NewCallback(&Plugin::SignalStartSelLdrDone,
86 &service_runtime_started, 87 &service_runtime_started,
87 service_runtime); 88 service_runtime);
88 pp::CompletionCallback callback = 89 pp::CompletionCallback callback =
89 callback_factory_.NewCallback(&Plugin::StartSelLdrOnMainThread, 90 callback_factory_.NewCallback(&Plugin::StartSelLdrOnMainThread,
90 service_runtime, params, 91 service_runtime, params,
91 sel_ldr_callback); 92 sel_ldr_callback);
92 pp::Module::Get()->core()->CallOnMainThread(0, callback, 0); 93 pp::Module::Get()->core()->CallOnMainThread(0, callback, 0);
93 if (!service_runtime->WaitForSelLdrStart()) { 94 if (!service_runtime->WaitForSelLdrStart()) {
94 PLUGIN_PRINTF(("Plugin::LoadNaClModuleFromBackgroundThread " 95 PLUGIN_PRINTF(("Plugin::LoadHelperNaClModule "
95 "WaitForSelLdrStart timed out!\n")); 96 "WaitForSelLdrStart timed out!\n"));
96 return false; 97 return false;
97 } 98 }
98 PLUGIN_PRINTF(("Plugin::LoadNaClModuleFromBackgroundThread " 99 PLUGIN_PRINTF(("Plugin::LoadHelperNaClModule (service_runtime_started=%d)\n",
99 "(service_runtime_started=%d)\n",
100 service_runtime_started)); 100 service_runtime_started));
101 if (!service_runtime_started) 101 if (!service_runtime_started)
102 return false; 102 return false;
103 103
104 PP_NaClFileInfo info; 104 PP_NaClFileInfo info;
105 info.handle = file_handle; 105 info.handle = file_handle;
106 info.token_lo = 0; 106 info.token_lo = 0;
107 info.token_hi = 0; 107 info.token_hi = 0;
108 108
109 // Now actually load the nexe, which can happen on a background thread. 109 // Now actually load the nexe, which can happen on a background thread.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 // the ServiceRuntime object for an existing subprocess, and that any 163 // the ServiceRuntime object for an existing subprocess, and that any
164 // associated listener threads do not go unjoined because if they 164 // associated listener threads do not go unjoined because if they
165 // outlive the Plugin object, they will not be memory safe. 165 // outlive the Plugin object, they will not be memory safe.
166 ShutDownSubprocesses(); 166 ShutDownSubprocesses();
167 pp::Var manifest_base_url = 167 pp::Var manifest_base_url =
168 pp::Var(pp::PASS_REF, nacl_interface_->GetManifestBaseURL(pp_instance())); 168 pp::Var(pp::PASS_REF, nacl_interface_->GetManifestBaseURL(pp_instance()));
169 std::string manifest_base_url_str = manifest_base_url.AsString(); 169 std::string manifest_base_url_str = manifest_base_url.AsString();
170 SelLdrStartParams params(manifest_base_url_str, 170 SelLdrStartParams params(manifest_base_url_str,
171 true /* uses_irt */, 171 true /* uses_irt */,
172 true /* uses_ppapi */, 172 true /* uses_ppapi */,
173 uses_nonsfi_mode,
174 enable_dyncode_syscalls, 173 enable_dyncode_syscalls,
175 enable_exception_handling, 174 enable_exception_handling,
176 enable_crash_throttling); 175 enable_crash_throttling);
177 ErrorInfo error_info; 176 ErrorInfo error_info;
178 ServiceRuntime* service_runtime = 177 ServiceRuntime* service_runtime = new ServiceRuntime(
179 new ServiceRuntime(this, true, uses_nonsfi_mode, 178 this, true, uses_nonsfi_mode, init_done_cb, crash_cb);
180 init_done_cb, crash_cb);
181 main_subprocess_.set_service_runtime(service_runtime); 179 main_subprocess_.set_service_runtime(service_runtime);
182 PLUGIN_PRINTF(("Plugin::LoadNaClModule (service_runtime=%p)\n", 180 PLUGIN_PRINTF(("Plugin::LoadNaClModule (service_runtime=%p)\n",
183 static_cast<void*>(service_runtime))); 181 static_cast<void*>(service_runtime)));
184 if (NULL == service_runtime) { 182 if (NULL == service_runtime) {
185 error_info.SetReport( 183 error_info.SetReport(
186 PP_NACL_ERROR_SEL_LDR_INIT, 184 PP_NACL_ERROR_SEL_LDR_INIT,
187 "sel_ldr init failure " + main_subprocess_.description()); 185 "sel_ldr init failure " + main_subprocess_.description());
188 ReportLoadError(error_info); 186 ReportLoadError(error_info);
189 return; 187 return;
190 } 188 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 return NULL; 242 return NULL;
245 } 243 }
246 244
247 // Do not report UMA stats for translator-related nexes. 245 // Do not report UMA stats for translator-related nexes.
248 // TODO(sehr): define new UMA stats for translator related nexe events. 246 // TODO(sehr): define new UMA stats for translator related nexe events.
249 // NOTE: The PNaCl translator nexes are not built to use the IRT. This is 247 // NOTE: The PNaCl translator nexes are not built to use the IRT. This is
250 // done to save on address space and swap space. 248 // done to save on address space and swap space.
251 SelLdrStartParams params(helper_url, 249 SelLdrStartParams params(helper_url,
252 false /* uses_irt */, 250 false /* uses_irt */,
253 false /* uses_ppapi */, 251 false /* uses_ppapi */,
254 false /* uses_nonsfi_mode */,
255 false /* enable_dyncode_syscalls */, 252 false /* enable_dyncode_syscalls */,
256 false /* enable_exception_handling */, 253 false /* enable_exception_handling */,
257 true /* enable_crash_throttling */); 254 true /* enable_crash_throttling */);
258 255
259 // Helper NaCl modules always use the PNaCl manifest, as there is no 256 // Helper NaCl modules always use the PNaCl manifest, as there is no
260 // corresponding NMF. 257 // corresponding NMF.
261 if (!LoadNaClModuleFromBackgroundThread(file_handle, nacl_subprocess.get(), 258 if (!LoadHelperNaClModule(file_handle, nacl_subprocess.get(), params)) {
262 params)) {
263 return NULL; 259 return NULL;
264 } 260 }
265 // We need not wait for the init_done callback. We can block 261 // We need not wait for the init_done callback. We can block
266 // here in StartSrpcServices, since helper NaCl modules 262 // here in StartSrpcServices, since helper NaCl modules
267 // are spawned from a private thread. 263 // are spawned from a private thread.
268 // 264 //
269 // TODO(bsy): if helper module crashes, we should abort. 265 // TODO(bsy): if helper module crashes, we should abort.
270 // crash_cb is not used here, so we are relying on crashes 266 // crash_cb is not used here, so we are relying on crashes
271 // being detected in StartSrpcServices or later. 267 // being detected in StartSrpcServices or later.
272 // 268 //
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 525
530 void Plugin::SetExitStatusOnMainThread(int32_t pp_error, 526 void Plugin::SetExitStatusOnMainThread(int32_t pp_error,
531 int exit_status) { 527 int exit_status) {
532 DCHECK(pp::Module::Get()->core()->IsMainThread()); 528 DCHECK(pp::Module::Get()->core()->IsMainThread());
533 DCHECK(nacl_interface_); 529 DCHECK(nacl_interface_);
534 nacl_interface_->SetExitStatus(pp_instance(), exit_status); 530 nacl_interface_->SetExitStatus(pp_instance(), exit_status);
535 } 531 }
536 532
537 533
538 } // namespace plugin 534 } // namespace plugin
OLDNEW
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/plugin.h ('k') | ppapi/native_client/src/trusted/plugin/service_runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698