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

Unified Diff: components/nacl/renderer/plugin/pnacl_coordinator.cc

Issue 1608313002: PNaCl cleanup: Simplify error checking when opening temp files (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Review: remove arg & move check Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: components/nacl/renderer/plugin/pnacl_coordinator.cc
diff --git a/components/nacl/renderer/plugin/pnacl_coordinator.cc b/components/nacl/renderer/plugin/pnacl_coordinator.cc
index ffd87594fb1e594543f6b07e955550ee7bd2664f..692fe67bc583feb0bf262f8ca0c155f0e1228a08 100644
--- a/components/nacl/renderer/plugin/pnacl_coordinator.cc
+++ b/components/nacl/renderer/plugin/pnacl_coordinator.cc
@@ -147,17 +147,6 @@ void PnaclCoordinator::ReportNonPpapiError(PP_NaClError err_code,
ExitWithError();
}
-void PnaclCoordinator::ReportPpapiError(PP_NaClError err_code,
- int32_t pp_error,
- const std::string& message) {
- std::stringstream ss;
- ss << "PnaclCoordinator: " << message << " (pp_error=" << pp_error << ").";
- ErrorInfo error_info;
- error_info.SetReport(err_code, ss.str());
- plugin_->ReportLoadError(error_info);
- ExitWithError();
-}
-
void PnaclCoordinator::ExitWithError() {
PLUGIN_PRINTF(("PnaclCoordinator::ExitWithError\n"));
// Free all the intermediate callbacks we ever created.
@@ -213,28 +202,13 @@ void PnaclCoordinator::TranslateFinished(int32_t pp_error) {
pnacl_options_.use_subzero, nexe_size, pexe_size_,
translate_thread_->GetCompileTime());
- NexeReadDidOpen(PP_OK);
+ NexeReadDidOpen();
}
-void PnaclCoordinator::NexeReadDidOpen(int32_t pp_error) {
- PLUGIN_PRINTF(("PnaclCoordinator::NexeReadDidOpen (pp_error=%"
- NACL_PRId32 ")\n", pp_error));
- if (pp_error != PP_OK) {
- if (pp_error == PP_ERROR_FILENOTFOUND) {
- ReportPpapiError(PP_NACL_ERROR_PNACL_CACHE_FETCH_NOTFOUND,
- pp_error,
- "Failed to open translated nexe (not found).");
- return;
- }
- if (pp_error == PP_ERROR_NOACCESS) {
- ReportPpapiError(PP_NACL_ERROR_PNACL_CACHE_FETCH_NOACCESS,
- pp_error,
- "Failed to open translated nexe (no access).");
- return;
- }
- ReportPpapiError(PP_NACL_ERROR_PNACL_CACHE_FETCH_OTHER,
- pp_error,
- "Failed to open translated nexe.");
+void PnaclCoordinator::NexeReadDidOpen() {
+ if (!temp_nexe_file_->IsValid()) {
+ ReportNonPpapiError(PP_NACL_ERROR_PNACL_CACHE_FETCH_OTHER,
+ "Failed to open translated nexe.");
return;
}
@@ -270,7 +244,7 @@ void PnaclCoordinator::BitcodeStreamCacheHit(PP_FileHandle handle) {
}
temp_nexe_file_.reset(new TempFile(plugin_, handle));
// Open it for reading as the cached nexe file.
- NexeReadDidOpen(temp_nexe_file_->CheckValidity());
+ NexeReadDidOpen();
}
void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size,
@@ -308,11 +282,9 @@ void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size,
PP_FileHandle obj_handle =
plugin_->nacl_interface()->CreateTemporaryFile(plugin_->pp_instance());
scoped_ptr<TempFile> temp_file(new TempFile(plugin_, obj_handle));
- int32_t pp_error = temp_file->CheckValidity();
- if (pp_error != PP_OK) {
- ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP,
- pp_error,
- "Failed to open scratch object file.");
+ if (!temp_file->IsValid()) {
+ ReportNonPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP,
+ "Failed to open scratch object file.");
return;
} else {
obj_files_.push_back(temp_file.release());
@@ -322,8 +294,7 @@ void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size,
temp_nexe_file_.reset(new TempFile(plugin_, nexe_handle));
// Open the nexe file for connecting ld and sel_ldr.
// Start translation when done with this last step of setup!
- int32_t pp_error = temp_nexe_file_->CheckValidity();
- if (pp_error != PP_OK) {
+ if (!temp_nexe_file_->IsValid()) {
ReportNonPpapiError(
PP_NACL_ERROR_PNACL_CREATE_TEMP,
std::string(
« no previous file with comments | « components/nacl/renderer/plugin/pnacl_coordinator.h ('k') | components/nacl/renderer/plugin/temporary_file.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698