OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #define NACL_LOG_MODULE_NAME "Plugin::ServiceRuntime" | 7 #define NACL_LOG_MODULE_NAME "Plugin::ServiceRuntime" |
8 | 8 |
9 #include "native_client/src/trusted/plugin/service_runtime.h" | 9 #include "native_client/src/trusted/plugin/service_runtime.h" |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 // This is here due to a Windows API collision; plugin.h through | 38 // This is here due to a Windows API collision; plugin.h through |
39 // file_downloader.h transitively includes Instance.h which defines a | 39 // file_downloader.h transitively includes Instance.h which defines a |
40 // PostMessage method, so this undef must appear before any of those. | 40 // PostMessage method, so this undef must appear before any of those. |
41 #ifdef PostMessage | 41 #ifdef PostMessage |
42 #undef PostMessage | 42 #undef PostMessage |
43 #endif | 43 #endif |
44 #include "native_client/src/trusted/plugin/plugin.h" | 44 #include "native_client/src/trusted/plugin/plugin.h" |
45 #include "native_client/src/trusted/plugin/plugin_error.h" | 45 #include "native_client/src/trusted/plugin/plugin_error.h" |
46 #include "native_client/src/trusted/plugin/pnacl_coordinator.h" | 46 #include "native_client/src/trusted/plugin/pnacl_coordinator.h" |
| 47 #include "native_client/src/trusted/plugin/pnacl_resources.h" |
47 #include "native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h" | 48 #include "native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h" |
48 #include "native_client/src/trusted/plugin/srpc_client.h" | 49 #include "native_client/src/trusted/plugin/srpc_client.h" |
49 #include "native_client/src/trusted/plugin/utility.h" | 50 #include "native_client/src/trusted/plugin/utility.h" |
50 | 51 |
51 #include "native_client/src/trusted/weak_ref/call_on_main_thread.h" | 52 #include "native_client/src/trusted/weak_ref/call_on_main_thread.h" |
52 | 53 |
53 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" | 54 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" |
54 #include "native_client/src/trusted/service_runtime/include/sys/nacl_imc_api.h" | 55 #include "native_client/src/trusted/service_runtime/include/sys/nacl_imc_api.h" |
55 | 56 |
56 #include "ppapi/c/pp_errors.h" | 57 #include "ppapi/c/pp_errors.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 // manifest. | 238 // manifest. |
238 NaClLog(4, | 239 NaClLog(4, |
239 "OpenManifestEntry: failed for key %s, code %d (%s)\n", | 240 "OpenManifestEntry: failed for key %s, code %d (%s)\n", |
240 url_key.c_str(), | 241 url_key.c_str(), |
241 error_info.error_code(), | 242 error_info.error_code(), |
242 error_info.message().c_str()); | 243 error_info.message().c_str()); |
243 } | 244 } |
244 return true; | 245 return true; |
245 } | 246 } |
246 | 247 |
| 248 // Transfer point from OpenManifestEntry() which runs on the main thread |
| 249 // (Some PPAPI actions -- like StreamAsFile -- can only run on the main thread). |
| 250 // OpenManifestEntry() is waiting on a condvar for this continuation to |
| 251 // complete. We Broadcast and awaken OpenManifestEntry() whenever we are done |
| 252 // either here, or in a later MainThreadContinuation step, if there are |
| 253 // multiple steps. |
247 void PluginReverseInterface::OpenManifestEntry_MainThreadContinuation( | 254 void PluginReverseInterface::OpenManifestEntry_MainThreadContinuation( |
248 OpenManifestEntryResource* p, | 255 OpenManifestEntryResource* p, |
249 int32_t err) { | 256 int32_t err) { |
250 OpenManifestEntryResource *open_cont; | 257 OpenManifestEntryResource *open_cont; |
251 UNREFERENCED_PARAMETER(err); | 258 UNREFERENCED_PARAMETER(err); |
252 // CallOnMainThread continuations always called with err == PP_OK. | 259 // CallOnMainThread continuations always called with err == PP_OK. |
253 | 260 |
254 NaClLog(4, "Entered OpenManifestEntry_MainThreadContinuation\n"); | 261 NaClLog(4, "Entered OpenManifestEntry_MainThreadContinuation\n"); |
255 | 262 |
256 std::string mapped_url; | 263 std::string mapped_url; |
(...skipping 16 matching lines...) Expand all Loading... |
273 | 280 |
274 open_cont = new OpenManifestEntryResource(*p); // copy ctor! | 281 open_cont = new OpenManifestEntryResource(*p); // copy ctor! |
275 CHECK(open_cont != NULL); | 282 CHECK(open_cont != NULL); |
276 open_cont->url = mapped_url; | 283 open_cont->url = mapped_url; |
277 if (!open_cont->pnacl_translate) { | 284 if (!open_cont->pnacl_translate) { |
278 pp::CompletionCallback stream_cc = WeakRefNewCallback( | 285 pp::CompletionCallback stream_cc = WeakRefNewCallback( |
279 anchor_, | 286 anchor_, |
280 this, | 287 this, |
281 &PluginReverseInterface::StreamAsFile_MainThreadContinuation, | 288 &PluginReverseInterface::StreamAsFile_MainThreadContinuation, |
282 open_cont); | 289 open_cont); |
283 if (!plugin_->StreamAsFile(mapped_url, | 290 // |
284 stream_cc.pp_completion_callback())) { | 291 if (!PnaclUrls::IsPnaclComponent(mapped_url)) { |
| 292 if (!plugin_->StreamAsFile(mapped_url, |
| 293 stream_cc.pp_completion_callback())) { |
| 294 NaClLog(4, |
| 295 "OpenManifestEntry_MainThreadContinuation: " |
| 296 "StreamAsFile failed\n"); |
| 297 nacl::MutexLocker take(&mu_); |
| 298 *p->op_complete_ptr = true; // done... |
| 299 *p->out_desc = -1; // but failed. |
| 300 p->error_info->SetReport(ERROR_MANIFEST_OPEN, |
| 301 "ServiceRuntime: StreamAsFile failed"); |
| 302 NaClXCondVarBroadcast(&cv_); |
| 303 return; |
| 304 } |
285 NaClLog(4, | 305 NaClLog(4, |
286 "OpenManifestEntry_MainThreadContinuation: " | 306 "OpenManifestEntry_MainThreadContinuation: StreamAsFile okay\n"); |
287 "StreamAsFile failed\n"); | 307 } else { |
| 308 int32_t fd = PnaclResources::GetPnaclFD( |
| 309 plugin_, |
| 310 PnaclUrls::StripPnaclComponentPrefix(mapped_url).c_str()); |
| 311 if (fd < 0) { |
| 312 // We should check earlier if the pnacl component wasn't installed |
| 313 // yet. At this point, we can't do much anymore, so just continue |
| 314 // with an invalid fd. |
| 315 NaClLog(4, |
| 316 "OpenManifestEntry_MainThreadContinuation: " |
| 317 "GetReadonlyPnaclFd failed\n"); |
| 318 // TODO(jvoung): Separate the error codes? |
| 319 p->error_info->SetReport(ERROR_MANIFEST_OPEN, |
| 320 "ServiceRuntime: GetPnaclFd failed"); |
| 321 } |
288 nacl::MutexLocker take(&mu_); | 322 nacl::MutexLocker take(&mu_); |
289 *p->op_complete_ptr = true; // done... | 323 *p->op_complete_ptr = true; // done! |
290 *p->out_desc = -1; // but failed. | 324 *p->out_desc = fd; |
291 p->error_info->SetReport(ERROR_MANIFEST_OPEN, | |
292 "ServiceRuntime: StreamAsFile failed"); | |
293 NaClXCondVarBroadcast(&cv_); | 325 NaClXCondVarBroadcast(&cv_); |
294 return; | 326 NaClLog(4, |
| 327 "OpenManifestEntry_MainThreadContinuation: GetPnaclFd okay\n"); |
295 } | 328 } |
296 NaClLog(4, | |
297 "OpenManifestEntry_MainThreadContinuation: StreamAsFile okay\n"); | |
298 } else { | 329 } else { |
299 NaClLog(4, | 330 NaClLog(4, |
300 "OpenManifestEntry_MainThreadContinuation: " | 331 "OpenManifestEntry_MainThreadContinuation: " |
301 "pulling down and translating.\n"); | 332 "pulling down and translating.\n"); |
302 pp::CompletionCallback translate_callback = | 333 pp::CompletionCallback translate_callback = |
303 WeakRefNewCallback( | 334 WeakRefNewCallback( |
304 anchor_, | 335 anchor_, |
305 this, | 336 this, |
306 &PluginReverseInterface::BitcodeTranslate_MainThreadContinuation, | 337 &PluginReverseInterface::BitcodeTranslate_MainThreadContinuation, |
307 open_cont); | 338 open_cont); |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 | 834 |
804 nacl::string ServiceRuntime::GetCrashLogOutput() { | 835 nacl::string ServiceRuntime::GetCrashLogOutput() { |
805 if (NULL != subprocess_.get()) { | 836 if (NULL != subprocess_.get()) { |
806 return subprocess_->GetCrashLogOutput(); | 837 return subprocess_->GetCrashLogOutput(); |
807 } else { | 838 } else { |
808 return ""; | 839 return ""; |
809 } | 840 } |
810 } | 841 } |
811 | 842 |
812 } // namespace plugin | 843 } // namespace plugin |
OLD | NEW |