From 4db78f084fbe3f5ecce8b8a9170c0ae7eb07843f Mon Sep 17 00:00:00 2001 From: "teravest@chromium.org" Date: Thu, 20 Mar 2014 21:43:34 +0000 Subject: Pepper: Move AddToConsole() to PPB_NaCl_Private. BUG=239656 R=dmichael@chromium.org Review URL: https://codereview.chromium.org/203373005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258417 0039d316-1c4b-4281-b951-d872f2087c98 --- components/nacl/renderer/ppb_nacl_private_impl.cc | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'components') diff --git a/components/nacl/renderer/ppb_nacl_private_impl.cc b/components/nacl/renderer/ppb_nacl_private_impl.cc index 9160252..8730878 100644 --- a/components/nacl/renderer/ppb_nacl_private_impl.cc +++ b/components/nacl/renderer/ppb_nacl_private_impl.cc @@ -44,6 +44,9 @@ namespace { +// Forward declare LogToConsole() we can use it in other functions here. +void LogToConsole(PP_Instance instance, const char* message); + base::LazyInstance > g_pnacl_resource_host = LAZY_INSTANCE_INITIALIZER; @@ -512,6 +515,7 @@ void SetReadOnlyProperty(PP_Instance instance, void ReportLoadError(PP_Instance instance, PP_NaClError error, const char* error_message, + const char* console_message, PP_Bool is_installed) { // Check that we are on the main renderer thread. DCHECK(content::RenderThread::Get()); @@ -525,8 +529,6 @@ void ReportLoadError(PP_Instance instance, } // TODO(dmichael): Move the following actions here: // - Set ready state to DONE. - // - Set last error string. - // - Print error message to JavaScript console. // Inform JavaScript that loading encountered an error and is complete. DispatchEvent(instance, PP_NACL_EVENT_ERROR, NULL, PP_FALSE, 0, 0); @@ -546,6 +548,10 @@ void ReportLoadError(PP_Instance instance, plugin_instance->SetEmbedProperty( ppapi::StringVar::StringToPPVar("lastError"), ppapi::StringVar::StringToPPVar(error_string)); + + std::string console_string = std::string("NaCl module load failed: ") + + std::string(console_message); + LogToConsole(instance, console_string.c_str()); } void InstanceDestroyed(PP_Instance instance) { @@ -582,6 +588,14 @@ PP_UrlSchemeType GetUrlScheme(PP_Var url) { return PP_SCHEME_OTHER; } +void LogToConsole(PP_Instance instance, const char* message) { + std::string source("NativeClient"); + ppapi::PpapiGlobals::Get()->LogWithSource(instance, + PP_LOGLEVEL_LOG, + source, + std::string(message)); +} + const PPB_NaCl_Private nacl_interface = { &LaunchSelLdr, &StartPpapiProxy, @@ -601,7 +615,8 @@ const PPB_NaCl_Private nacl_interface = { &InstanceDestroyed, &NaClDebugStubEnabled, &GetSandboxArch, - &GetUrlScheme + &GetUrlScheme, + &LogToConsole }; } // namespace -- cgit v1.1