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 |
247 void PluginReverseInterface::OpenManifestEntry_MainThreadContinuation( | 248 void PluginReverseInterface::OpenManifestEntry_MainThreadContinuation( |
robertm
2012/08/08 21:51:11
maybe say what has happened so far when this is ca
jvoung - send to chromium...
2012/08/08 22:47:04
Done.
| |
248 OpenManifestEntryResource* p, | 249 OpenManifestEntryResource* p, |
249 int32_t err) { | 250 int32_t err) { |
250 OpenManifestEntryResource *open_cont; | 251 OpenManifestEntryResource *open_cont; |
251 UNREFERENCED_PARAMETER(err); | 252 UNREFERENCED_PARAMETER(err); |
252 // CallOnMainThread continuations always called with err == PP_OK. | 253 // CallOnMainThread continuations always called with err == PP_OK. |
253 | 254 |
254 NaClLog(4, "Entered OpenManifestEntry_MainThreadContinuation\n"); | 255 NaClLog(4, "Entered OpenManifestEntry_MainThreadContinuation\n"); |
255 | 256 |
256 std::string mapped_url; | 257 std::string mapped_url; |
257 std::string cache_identity; | 258 std::string cache_identity; |
(...skipping 15 matching lines...) Expand all Loading... | |
273 | 274 |
274 open_cont = new OpenManifestEntryResource(*p); // copy ctor! | 275 open_cont = new OpenManifestEntryResource(*p); // copy ctor! |
275 CHECK(open_cont != NULL); | 276 CHECK(open_cont != NULL); |
276 open_cont->url = mapped_url; | 277 open_cont->url = mapped_url; |
277 if (!open_cont->pnacl_translate) { | 278 if (!open_cont->pnacl_translate) { |
278 pp::CompletionCallback stream_cc = WeakRefNewCallback( | 279 pp::CompletionCallback stream_cc = WeakRefNewCallback( |
279 anchor_, | 280 anchor_, |
280 this, | 281 this, |
281 &PluginReverseInterface::StreamAsFile_MainThreadContinuation, | 282 &PluginReverseInterface::StreamAsFile_MainThreadContinuation, |
282 open_cont); | 283 open_cont); |
283 if (!plugin_->StreamAsFile(mapped_url, | 284 // |
284 stream_cc.pp_completion_callback())) { | 285 if (!PnaclUrls::IsPnaclComponent(mapped_url)) { |
286 if (!plugin_->StreamAsFile(mapped_url, | |
287 stream_cc.pp_completion_callback())) { | |
288 NaClLog(4, | |
289 "OpenManifestEntry_MainThreadContinuation: " | |
290 "StreamAsFile failed\n"); | |
291 nacl::MutexLocker take(&mu_); | |
292 *p->op_complete_ptr = true; // done... | |
293 *p->out_desc = -1; // but failed. | |
294 p->error_info->SetReport(ERROR_MANIFEST_OPEN, | |
295 "ServiceRuntime: StreamAsFile failed"); | |
296 NaClXCondVarBroadcast(&cv_); | |
robertm
2012/08/08 21:51:11
add comment for what is being woken up here
jvoung - send to chromium...
2012/08/08 22:47:04
There's a bunch of these Broadcasts all over the f
| |
297 return; | |
298 } | |
285 NaClLog(4, | 299 NaClLog(4, |
286 "OpenManifestEntry_MainThreadContinuation: " | 300 "OpenManifestEntry_MainThreadContinuation: StreamAsFile okay\n"); |
287 "StreamAsFile failed\n"); | 301 } else { |
302 int32_t fd = PnaclResources::GetPnaclFD( | |
303 plugin_, | |
304 PnaclUrls::StripPnaclComponentPrefix(mapped_url).c_str()); | |
305 if (fd < 0) { | |
306 // We should check earlier if the pnacl component wasn't installed | |
307 // yet. At this point, we can't do much anymore, so just continue | |
308 // with an invalid fd. | |
309 NaClLog(4, | |
310 "OpenManifestEntry_MainThreadContinuation: " | |
311 "GetReadonlyPnaclFd failed\n"); | |
312 // TODO(jvoung): Separate the error codes? | |
313 p->error_info->SetReport(ERROR_MANIFEST_OPEN, | |
314 "ServiceRuntime: GetPnaclFd failed"); | |
315 } | |
288 nacl::MutexLocker take(&mu_); | 316 nacl::MutexLocker take(&mu_); |
289 *p->op_complete_ptr = true; // done... | 317 *p->op_complete_ptr = true; // done! |
290 *p->out_desc = -1; // but failed. | 318 *p->out_desc = fd; |
291 p->error_info->SetReport(ERROR_MANIFEST_OPEN, | |
292 "ServiceRuntime: StreamAsFile failed"); | |
293 NaClXCondVarBroadcast(&cv_); | 319 NaClXCondVarBroadcast(&cv_); |
robertm
2012/08/08 21:51:11
dito
jvoung - send to chromium...
2012/08/08 22:47:04
Done.
| |
294 return; | 320 NaClLog(4, |
321 "OpenManifestEntry_MainThreadContinuation: GetPnaclFd okay\n"); | |
295 } | 322 } |
296 NaClLog(4, | |
297 "OpenManifestEntry_MainThreadContinuation: StreamAsFile okay\n"); | |
298 } else { | 323 } else { |
299 NaClLog(4, | 324 NaClLog(4, |
300 "OpenManifestEntry_MainThreadContinuation: " | 325 "OpenManifestEntry_MainThreadContinuation: " |
301 "pulling down and translating.\n"); | 326 "pulling down and translating.\n"); |
302 pp::CompletionCallback translate_callback = | 327 pp::CompletionCallback translate_callback = |
303 WeakRefNewCallback( | 328 WeakRefNewCallback( |
304 anchor_, | 329 anchor_, |
305 this, | 330 this, |
306 &PluginReverseInterface::BitcodeTranslate_MainThreadContinuation, | 331 &PluginReverseInterface::BitcodeTranslate_MainThreadContinuation, |
307 open_cont); | 332 open_cont); |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
803 | 828 |
804 nacl::string ServiceRuntime::GetCrashLogOutput() { | 829 nacl::string ServiceRuntime::GetCrashLogOutput() { |
805 if (NULL != subprocess_.get()) { | 830 if (NULL != subprocess_.get()) { |
806 return subprocess_->GetCrashLogOutput(); | 831 return subprocess_->GetCrashLogOutput(); |
807 } else { | 832 } else { |
808 return ""; | 833 return ""; |
809 } | 834 } |
810 } | 835 } |
811 | 836 |
812 } // namespace plugin | 837 } // namespace plugin |
OLD | NEW |