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 "ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h" | 5 #include "ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "native_client/src/include/checked_cast.h" | 10 #include "native_client/src/include/checked_cast.h" |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 } else { | 329 } else { |
330 PLUGIN_PRINTF(("PnaclCoordinator::ExitWithError an earlier error was " | 330 PLUGIN_PRINTF(("PnaclCoordinator::ExitWithError an earlier error was " |
331 "already reported -- Skipping.\n")); | 331 "already reported -- Skipping.\n")); |
332 } | 332 } |
333 } | 333 } |
334 | 334 |
335 // Signal that Pnacl translation completed normally. | 335 // Signal that Pnacl translation completed normally. |
336 void PnaclCoordinator::TranslateFinished(int32_t pp_error) { | 336 void PnaclCoordinator::TranslateFinished(int32_t pp_error) { |
337 PLUGIN_PRINTF(("PnaclCoordinator::TranslateFinished (pp_error=%" | 337 PLUGIN_PRINTF(("PnaclCoordinator::TranslateFinished (pp_error=%" |
338 NACL_PRId32 ")\n", pp_error)); | 338 NACL_PRId32 ")\n", pp_error)); |
339 // Bail out if there was an earlier error (e.g., pexe load failure). | 339 // Bail out if there was an earlier error (e.g., pexe load failure), |
340 if (translate_finish_error_ != PP_OK) { | 340 // or if there is an error from the translation thread. |
| 341 if (translate_finish_error_ != PP_OK || pp_error != PP_OK) { |
| 342 if (use_new_cache_) { |
| 343 plugin_->nacl_interface()->ReportTranslationFinished( |
| 344 plugin_->pp_instance(), |
| 345 PP_FALSE); |
| 346 } |
341 ExitWithError(); | 347 ExitWithError(); |
342 return; | 348 return; |
343 } | 349 } |
344 // Bail out if there is an error from the translation thread. | |
345 if (pp_error != PP_OK) { | |
346 ExitWithError(); | |
347 return; | |
348 } | |
349 // Send out one last progress event, to finish up the progress events | 350 // Send out one last progress event, to finish up the progress events |
350 // that were delayed (see the delay inserted in BitcodeGotCompiled). | 351 // that were delayed (see the delay inserted in BitcodeGotCompiled). |
351 if (ExpectedProgressKnown()) { | 352 if (ExpectedProgressKnown()) { |
352 pexe_bytes_compiled_ = expected_pexe_size_; | 353 pexe_bytes_compiled_ = expected_pexe_size_; |
353 plugin_->EnqueueProgressEvent(plugin::Plugin::kProgressEventProgress, | 354 plugin_->EnqueueProgressEvent(plugin::Plugin::kProgressEventProgress, |
354 pexe_url_, | 355 pexe_url_, |
355 plugin::Plugin::LENGTH_IS_COMPUTABLE, | 356 plugin::Plugin::LENGTH_IS_COMPUTABLE, |
356 pexe_bytes_compiled_, | 357 pexe_bytes_compiled_, |
357 expected_pexe_size_); | 358 expected_pexe_size_); |
358 } | 359 } |
(...skipping 29 matching lines...) Expand all Loading... |
388 } | 389 } |
389 | 390 |
390 // The nexe is written to the temp_nexe_file_. We must Reset() the file | 391 // The nexe is written to the temp_nexe_file_. We must Reset() the file |
391 // pointer to be able to read it again from the beginning. | 392 // pointer to be able to read it again from the beginning. |
392 temp_nexe_file_->Reset(); | 393 temp_nexe_file_->Reset(); |
393 | 394 |
394 if (use_new_cache_) { | 395 if (use_new_cache_) { |
395 // Report to the browser that translation finished. The browser will take | 396 // Report to the browser that translation finished. The browser will take |
396 // care of caching. | 397 // care of caching. |
397 plugin_->nacl_interface()->ReportTranslationFinished( | 398 plugin_->nacl_interface()->ReportTranslationFinished( |
398 plugin_->pp_instance()); | 399 plugin_->pp_instance(), PP_TRUE); |
399 NexeReadDidOpen(PP_OK); | 400 NexeReadDidOpen(PP_OK); |
400 return; | 401 return; |
401 } | 402 } |
402 if (pnacl_options_.HasCacheKey() && cached_nexe_file_ != NULL) { | 403 if (pnacl_options_.HasCacheKey() && cached_nexe_file_ != NULL) { |
403 // We are using a cache, but had a cache miss, which is why we did the | 404 // We are using a cache, but had a cache miss, which is why we did the |
404 // translation. Reset cached_nexe_file_ to have a random name, | 405 // translation. Reset cached_nexe_file_ to have a random name, |
405 // for scratch purposes, before renaming to the final cache_identity. | 406 // for scratch purposes, before renaming to the final cache_identity. |
406 cached_nexe_file_.reset(new LocalTempFile(plugin_, file_system_.get(), | 407 cached_nexe_file_.reset(new LocalTempFile(plugin_, file_system_.get(), |
407 nacl::string(kPnaclTempDir))); | 408 nacl::string(kPnaclTempDir))); |
408 pp::CompletionCallback cb = callback_factory_.NewCallback( | 409 pp::CompletionCallback cb = callback_factory_.NewCallback( |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 "PnaclCoordinator: pexe load failed (aborted)."); | 971 "PnaclCoordinator: pexe load failed (aborted)."); |
971 } | 972 } |
972 if (pp_error == PP_ERROR_NOACCESS) { | 973 if (pp_error == PP_ERROR_NOACCESS) { |
973 error_info_.SetReport(ERROR_PNACL_PEXE_FETCH_NOACCESS, | 974 error_info_.SetReport(ERROR_PNACL_PEXE_FETCH_NOACCESS, |
974 "PnaclCoordinator: pexe load failed (no access)."); | 975 "PnaclCoordinator: pexe load failed (no access)."); |
975 } else { | 976 } else { |
976 nacl::stringstream ss; | 977 nacl::stringstream ss; |
977 ss << "PnaclCoordinator: pexe load failed (pp_error=" << pp_error << ")."; | 978 ss << "PnaclCoordinator: pexe load failed (pp_error=" << pp_error << ")."; |
978 error_info_.SetReport(ERROR_PNACL_PEXE_FETCH_OTHER, ss.str()); | 979 error_info_.SetReport(ERROR_PNACL_PEXE_FETCH_OTHER, ss.str()); |
979 } | 980 } |
| 981 if (use_new_cache_) { |
| 982 plugin_->nacl_interface()->ReportTranslationFinished( |
| 983 plugin_->pp_instance(), |
| 984 PP_FALSE); |
| 985 } |
980 translate_thread_->AbortSubprocesses(); | 986 translate_thread_->AbortSubprocesses(); |
981 } else { | 987 } else { |
982 // Compare download completion pct (100% now), to compile completion pct. | 988 // Compare download completion pct (100% now), to compile completion pct. |
983 HistogramRatio("NaCl.Perf.PNaClLoadTime.PctCompiledWhenFullyDownloaded", | 989 HistogramRatio("NaCl.Perf.PNaClLoadTime.PctCompiledWhenFullyDownloaded", |
984 pexe_bytes_compiled_, pexe_size_); | 990 pexe_bytes_compiled_, pexe_size_); |
985 } | 991 } |
986 } | 992 } |
987 | 993 |
988 void PnaclCoordinator::BitcodeStreamGotData(int32_t pp_error, | 994 void PnaclCoordinator::BitcodeStreamGotData(int32_t pp_error, |
989 FileStreamData data) { | 995 FileStreamData data) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 *bytes_total = expected_pexe_size_; | 1050 *bytes_total = expected_pexe_size_; |
1045 } | 1051 } |
1046 | 1052 |
1047 void PnaclCoordinator::ObjectFileDidOpen(int32_t pp_error) { | 1053 void PnaclCoordinator::ObjectFileDidOpen(int32_t pp_error) { |
1048 PLUGIN_PRINTF(("PnaclCoordinator::ObjectFileDidOpen (pp_error=%" | 1054 PLUGIN_PRINTF(("PnaclCoordinator::ObjectFileDidOpen (pp_error=%" |
1049 NACL_PRId32 ")\n", pp_error)); | 1055 NACL_PRId32 ")\n", pp_error)); |
1050 if (pp_error != PP_OK) { | 1056 if (pp_error != PP_OK) { |
1051 ReportPpapiError(ERROR_PNACL_CREATE_TEMP, | 1057 ReportPpapiError(ERROR_PNACL_CREATE_TEMP, |
1052 pp_error, | 1058 pp_error, |
1053 "Failed to open scratch object file."); | 1059 "Failed to open scratch object file."); |
| 1060 if (use_new_cache_) { |
| 1061 plugin_->nacl_interface()->ReportTranslationFinished( |
| 1062 plugin_->pp_instance(), |
| 1063 PP_FALSE); |
| 1064 } |
1054 return; | 1065 return; |
1055 } | 1066 } |
1056 // Open the nexe file for connecting ld and sel_ldr. | 1067 // Open the nexe file for connecting ld and sel_ldr. |
1057 // Start translation when done with this last step of setup! | 1068 // Start translation when done with this last step of setup! |
1058 if (!use_new_cache_) | 1069 if (!use_new_cache_) |
1059 // In the new cache case, the TempFile has already been created. | 1070 // In the new cache case, the TempFile has already been created. |
1060 temp_nexe_file_.reset(new TempFile(plugin_)); | 1071 temp_nexe_file_.reset(new TempFile(plugin_)); |
1061 | 1072 |
1062 pp::CompletionCallback cb = | 1073 pp::CompletionCallback cb = |
1063 callback_factory_.NewCallback(&PnaclCoordinator::RunTranslate); | 1074 callback_factory_.NewCallback(&PnaclCoordinator::RunTranslate); |
(...skipping 14 matching lines...) Expand all Loading... |
1078 obj_file_.get(), | 1089 obj_file_.get(), |
1079 temp_nexe_file_.get(), | 1090 temp_nexe_file_.get(), |
1080 &error_info_, | 1091 &error_info_, |
1081 resources_.get(), | 1092 resources_.get(), |
1082 &pnacl_options_, | 1093 &pnacl_options_, |
1083 this, | 1094 this, |
1084 plugin_); | 1095 plugin_); |
1085 } | 1096 } |
1086 | 1097 |
1087 } // namespace plugin | 1098 } // namespace plugin |
OLD | NEW |