diff options
author | halyavin@google.com <halyavin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-22 18:01:30 +0000 |
---|---|---|
committer | halyavin@google.com <halyavin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-22 18:01:30 +0000 |
commit | 05c7cc7cbf45b00d5d3400cb893adb1c196c10ee (patch) | |
tree | df2e7d167527c561f56046535b468491ed127490 /ppapi/native_client/src/trusted | |
parent | 8df07d2a28b8de7a857a9e1ad8df36a6026939a8 (diff) | |
download | chromium_src-05c7cc7cbf45b00d5d3400cb893adb1c196c10ee.zip chromium_src-05c7cc7cbf45b00d5d3400cb893adb1c196c10ee.tar.gz chromium_src-05c7cc7cbf45b00d5d3400cb893adb1c196c10ee.tar.bz2 |
Show more different NaCl loading errors.
Also refactor NaCl launch message to pass output parameters in a single
structure.
I changed nacl::FileDescriptor type on Windows from int to HANDLE to make it
compatible with IPC::PlatformFileForTransit. The only ways nacl::FileDescriptor
is currently used are its initialization, passing in IPC message and in
nacl::ToNativeHandle function. The behaviour of nacl::ToNativeHandle haven't
changed. IPC doesn't have special handling for integers and it only truncates
HANDLEs to 32-bit (so that they can be passed between 32-bit and 64-bit
processes) on Windows. So the change shouldn't affect any existing users of
nacl::FileDescriptor type.
TEST= bots + changing code to produce an error on normal code path
BUG= 259333
Review URL: https://chromiumcodereview.appspot.com/18045007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212913 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/native_client/src/trusted')
6 files changed, 45 insertions, 8 deletions
diff --git a/ppapi/native_client/src/trusted/plugin/nacl_entry_points.h b/ppapi/native_client/src/trusted/plugin/nacl_entry_points.h index 6079820..33e4f77 100644 --- a/ppapi/native_client/src/trusted/plugin/nacl_entry_points.h +++ b/ppapi/native_client/src/trusted/plugin/nacl_entry_points.h @@ -24,7 +24,8 @@ typedef PP_NaClResult (*LaunchNaClProcessFunc)( PP_Bool enable_ppapi_dev, PP_Bool enable_dyncode_syscalls, PP_Bool enable_exception_handling, - NaClHandle* result_socket); + NaClHandle* result_socket, + struct PP_Var* error_message); extern LaunchNaClProcessFunc launch_nacl_process; diff --git a/ppapi/native_client/src/trusted/plugin/plugin.cc b/ppapi/native_client/src/trusted/plugin/plugin.cc index 4aa4c50..09a0724 100644 --- a/ppapi/native_client/src/trusted/plugin/plugin.cc +++ b/ppapi/native_client/src/trusted/plugin/plugin.cc @@ -1415,7 +1415,8 @@ void Plugin::ReportLoadError(const ErrorInfo& error_info) { nacl::string message = nacl::string("NaCl module load failed: ") + error_info.message(); set_last_error_string(message); - AddToConsole(message); + AddToConsole(nacl::string("NaCl module load failed: ") + + error_info.console_message()); // Inform JavaScript that loading encountered an error and is complete. EnqueueProgressEvent(kProgressEventError); EnqueueProgressEvent(kProgressEventLoadEnd); diff --git a/ppapi/native_client/src/trusted/plugin/plugin_error.h b/ppapi/native_client/src/trusted/plugin/plugin_error.h index f02ef83..9da77ca 100644 --- a/ppapi/native_client/src/trusted/plugin/plugin_error.h +++ b/ppapi/native_client/src/trusted/plugin/plugin_error.h @@ -115,6 +115,20 @@ class ErrorInfo { void SetReport(PluginErrorCode error_code, const std::string& message) { error_code_ = error_code; message_ = message; + console_message_ = message; + } + + // console_message is a part of the error that is logged to + // the JavaScript console but is not reported to JavaScript via + // the lastError property. This is used to report internal errors which + // may easily change in new versions of the browser and we don't want apps + // to come to depend on the details of these errors. + void SetReportWithConsoleOnlyError(PluginErrorCode error_code, + const std::string& message, + const std::string& console_message) { + error_code_ = error_code; + message_ = message; + console_message_ = message + "; " + console_message; } PluginErrorCode error_code() const { @@ -123,15 +137,21 @@ class ErrorInfo { void PrependMessage(const std::string& prefix) { message_ = prefix + message_; + console_message_ = prefix + console_message_; } const std::string& message() const { return message_; } + const std::string& console_message() const { + return console_message_; + } + private: PluginErrorCode error_code_; std::string message_; + std::string console_message_; NACL_DISALLOW_COPY_AND_ASSIGN(ErrorInfo); }; diff --git a/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc b/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc index 5e3751b..bd68de5 100644 --- a/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc +++ b/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc @@ -6,6 +6,8 @@ #include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h" #include "ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h" +#include "ppapi/cpp/var.h" + LaunchNaClProcessFunc launch_nacl_process = NULL; namespace plugin { @@ -21,9 +23,12 @@ bool SelLdrLauncherChrome::Start(PP_Instance instance, bool uses_ppapi, bool enable_ppapi_dev, bool enable_dyncode_syscalls, - bool enable_exception_handling) { + bool enable_exception_handling, + nacl::string* error_message) { + *error_message = ""; if (!launch_nacl_process) return false; + PP_Var var_error_message; // send a synchronous message to the browser process if (launch_nacl_process(instance, url, @@ -32,7 +37,12 @@ bool SelLdrLauncherChrome::Start(PP_Instance instance, PP_FromBool(enable_ppapi_dev), PP_FromBool(enable_dyncode_syscalls), PP_FromBool(enable_exception_handling), - &channel_) != PP_NACL_OK) { + &channel_, + &var_error_message) != PP_NACL_OK) { + pp::Var var_error_message_cpp(pp::PASS_REF, var_error_message); + if (var_error_message_cpp.is_string()) { + *error_message = var_error_message_cpp.AsString(); + } return false; } return true; diff --git a/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h b/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h index 6861622..a64c66b 100644 --- a/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h +++ b/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h @@ -19,7 +19,8 @@ class SelLdrLauncherChrome : public nacl::SelLdrLauncherBase { bool uses_ppapi, bool enable_ppapi_dev, bool enable_dyncode_syscalls, - bool enable_exception_handling); + bool enable_exception_handling, + nacl::string* error_message); }; } // namespace plugin diff --git a/ppapi/native_client/src/trusted/plugin/service_runtime.cc b/ppapi/native_client/src/trusted/plugin/service_runtime.cc index 7759fc3..f908f8b 100644 --- a/ppapi/native_client/src/trusted/plugin/service_runtime.cc +++ b/ppapi/native_client/src/trusted/plugin/service_runtime.cc @@ -728,17 +728,21 @@ bool ServiceRuntime::StartSelLdr(const SelLdrStartParams& params) { "ServiceRuntime: failed to create sel_ldr launcher"); return false; } + nacl::string error_message; bool started = tmp_subprocess->Start(plugin_->pp_instance(), params.url.c_str(), params.uses_irt, params.uses_ppapi, params.enable_dev_interfaces, params.enable_dyncode_syscalls, - params.enable_exception_handling); + params.enable_exception_handling, + &error_message); if (!started) { NaClLog(LOG_ERROR, "ServiceRuntime::Start (start failed)\n"); - params.error_info->SetReport(ERROR_SEL_LDR_LAUNCH, - "ServiceRuntime: failed to start"); + params.error_info->SetReportWithConsoleOnlyError( + ERROR_SEL_LDR_LAUNCH, + "ServiceRuntime: failed to start", + error_message); return false; } |