diff options
author | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-20 21:43:34 +0000 |
---|---|---|
committer | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-20 21:43:34 +0000 |
commit | 4db78f084fbe3f5ecce8b8a9170c0ae7eb07843f (patch) | |
tree | 95c22925282df2383eb405f497005882ff247e30 /ppapi | |
parent | 3e627c39c71510b325fb00861aa23db912afb776 (diff) | |
download | chromium_src-4db78f084fbe3f5ecce8b8a9170c0ae7eb07843f.zip chromium_src-4db78f084fbe3f5ecce8b8a9170c0ae7eb07843f.tar.gz chromium_src-4db78f084fbe3f5ecce8b8a9170c0ae7eb07843f.tar.bz2 |
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
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/api/private/ppb_nacl_private.idl | 5 | ||||
-rw-r--r-- | ppapi/c/private/ppb_nacl_private.h | 5 | ||||
-rw-r--r-- | ppapi/native_client/src/trusted/plugin/plugin.cc | 30 | ||||
-rw-r--r-- | ppapi/native_client/src/trusted/plugin/plugin.h | 3 | ||||
-rw-r--r-- | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c | 14 |
5 files changed, 24 insertions, 33 deletions
diff --git a/ppapi/api/private/ppb_nacl_private.idl b/ppapi/api/private/ppb_nacl_private.idl index aa731ae..c17ab8b 100644 --- a/ppapi/api/private/ppb_nacl_private.idl +++ b/ppapi/api/private/ppb_nacl_private.idl @@ -275,6 +275,7 @@ interface PPB_NaCl_Private { void ReportLoadError([in] PP_Instance instance, [in] PP_NaClError error, [in] str_t error_message, + [in] str_t console_message, [in] PP_Bool is_installed); /* Performs internal cleanup when an instance is destroyed. */ @@ -292,4 +293,8 @@ interface PPB_NaCl_Private { /* Returns the scheme type for a given url. */ PP_UrlSchemeType GetUrlScheme([in] PP_Var url); + + /* Logs the message to the console. */ + void LogToConsole([in] PP_Instance instance, + [in] str_t message); }; diff --git a/ppapi/c/private/ppb_nacl_private.h b/ppapi/c/private/ppb_nacl_private.h index e2ccb2b..e5032fc 100644 --- a/ppapi/c/private/ppb_nacl_private.h +++ b/ppapi/c/private/ppb_nacl_private.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From private/ppb_nacl_private.idl modified Tue Mar 18 11:15:05 2014. */ +/* From private/ppb_nacl_private.idl modified Thu Mar 20 14:02:02 2014. */ #ifndef PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ @@ -282,6 +282,7 @@ struct PPB_NaCl_Private_1_0 { void (*ReportLoadError)(PP_Instance instance, PP_NaClError error, const char* error_message, + const char* console_message, PP_Bool is_installed); /* Performs internal cleanup when an instance is destroyed. */ void (*InstanceDestroyed)(PP_Instance instance); @@ -295,6 +296,8 @@ struct PPB_NaCl_Private_1_0 { const char* (*GetSandboxArch)(void); /* Returns the scheme type for a given url. */ PP_UrlSchemeType (*GetUrlScheme)(struct PP_Var url); + /* Logs the message to the console. */ + void (*LogToConsole)(PP_Instance instance, const char* message); }; typedef struct PPB_NaCl_Private_1_0 PPB_NaCl_Private; diff --git a/ppapi/native_client/src/trusted/plugin/plugin.cc b/ppapi/native_client/src/trusted/plugin/plugin.cc index 189895e..931bfe2 100644 --- a/ppapi/native_client/src/trusted/plugin/plugin.cc +++ b/ppapi/native_client/src/trusted/plugin/plugin.cc @@ -802,7 +802,8 @@ void Plugin::NexeFileDidOpenContinuation(int32_t pp_error) { static void LogLineToConsole(Plugin* plugin, const nacl::string& one_line) { PLUGIN_PRINTF(("LogLineToConsole: %s\n", one_line.c_str())); - plugin->AddToConsole(one_line); + plugin->nacl_interface()->LogToConsole(plugin->pp_instance(), + one_line.c_str()); } void Plugin::CopyCrashLogToJsConsole() { @@ -918,7 +919,7 @@ void Plugin::ReportDeadNexe() { nacl::string message = nacl::string("NaCl module crashed"); set_last_error_string(message); - AddToConsole(message); + nacl_interface()->LogToConsole(pp_instance(), message.c_str()); EnqueueProgressEvent(PP_NACL_EVENT_CRASH); set_nexe_error_reported(true); @@ -1262,14 +1263,12 @@ void Plugin::ReportLoadError(const ErrorInfo& error_info) { nacl_interface_->ReportLoadError(pp_instance(), error_info.error_code(), error_info.message().c_str(), + error_info.console_message().c_str(), PP_FromBool(is_installed_)); // Set the readyState attribute to indicate we need to start over. set_nacl_ready_state(DONE); set_nexe_error_reported(true); - // Report an error on the JavaScript console. - AddToConsole(nacl::string("NaCl module load failed: ") + - error_info.console_message()); } @@ -1281,7 +1280,7 @@ void Plugin::ReportLoadAbort() { // Report an error in lastError and on the JavaScript console. nacl::string error_string("NaCl module load failed: user aborted"); set_last_error_string(error_string); - AddToConsole(error_string); + nacl_interface()->LogToConsole(pp_instance(), error_string.c_str()); // Inform JavaScript that loading was aborted and is complete. EnqueueProgressEvent(PP_NACL_EVENT_ABORT); EnqueueProgressEvent(PP_NACL_EVENT_LOADEND); @@ -1414,25 +1413,6 @@ bool Plugin::DocumentCanRequest(const std::string& url) { return url_util_->DocumentCanRequest(this, pp::Var(url)); } -void Plugin::AddToConsole(const nacl::string& text) { - pp::Module* module = pp::Module::Get(); - const PPB_Var* var_interface = - static_cast<const PPB_Var*>( - module->GetBrowserInterface(PPB_VAR_INTERFACE)); - nacl::string prefix_string("NativeClient"); - PP_Var prefix = - var_interface->VarFromUtf8(prefix_string.c_str(), - static_cast<uint32_t>(prefix_string.size())); - PP_Var str = var_interface->VarFromUtf8(text.c_str(), - static_cast<uint32_t>(text.size())); - const PPB_Console* console_interface = - static_cast<const PPB_Console*>( - module->GetBrowserInterface(PPB_CONSOLE_INTERFACE)); - console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str); - var_interface->Release(prefix); - var_interface->Release(str); -} - void Plugin::set_last_error_string(const nacl::string& error) { DCHECK(nacl_interface_); nacl_interface_->SetReadOnlyProperty(pp_instance(), diff --git a/ppapi/native_client/src/trusted/plugin/plugin.h b/ppapi/native_client/src/trusted/plugin/plugin.h index 6d472d9..0fe9762 100644 --- a/ppapi/native_client/src/trusted/plugin/plugin.h +++ b/ppapi/native_client/src/trusted/plugin/plugin.h @@ -130,9 +130,6 @@ class Plugin : public pp::Instance { // Report loading a module was aborted, typically due to user action. void ReportLoadAbort(); - // Write a text string on the JavaScript console. - void AddToConsole(const nacl::string& text); - // Dispatch a JavaScript event to indicate a key step in loading. // |event_type| is a character string indicating which type of progress // event (loadstart, progress, error, abort, load, loadend). Events are diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c index 9cee893..1a6fbb7 100644 --- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c +++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c @@ -3163,9 +3163,9 @@ static void Pnacl_M25_PPB_NaCl_Private_SetReadOnlyProperty(PP_Instance instance, iface->SetReadOnlyProperty(instance, *key, *value); } -static void Pnacl_M25_PPB_NaCl_Private_ReportLoadError(PP_Instance instance, PP_NaClError error, const char* error_message, PP_Bool is_installed) { +static void Pnacl_M25_PPB_NaCl_Private_ReportLoadError(PP_Instance instance, PP_NaClError error, const char* error_message, const char* console_message, PP_Bool is_installed) { const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->ReportLoadError(instance, error, error_message, is_installed); + iface->ReportLoadError(instance, error, error_message, console_message, is_installed); } static void Pnacl_M25_PPB_NaCl_Private_InstanceDestroyed(PP_Instance instance) { @@ -3188,6 +3188,11 @@ static PP_UrlSchemeType Pnacl_M25_PPB_NaCl_Private_GetUrlScheme(struct PP_Var* u return iface->GetUrlScheme(*url); } +static void Pnacl_M25_PPB_NaCl_Private_LogToConsole(PP_Instance instance, const char* message) { + const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; + iface->LogToConsole(instance, message); +} + /* End wrapper methods for PPB_NaCl_Private_1_0 */ /* Begin wrapper methods for PPB_NetAddress_Private_0_1 */ @@ -5075,11 +5080,12 @@ static const struct PPB_NaCl_Private_1_0 Pnacl_Wrappers_PPB_NaCl_Private_1_0 = { .OpenNaClExecutable = (PP_FileHandle (*)(PP_Instance instance, const char* file_url, uint64_t* file_token_lo, uint64_t* file_token_hi))&Pnacl_M25_PPB_NaCl_Private_OpenNaClExecutable, .DispatchEvent = (void (*)(PP_Instance instance, PP_NaClEventType event_type, const char* resource_url, PP_Bool length_is_computable, uint64_t loaded_bytes, uint64_t total_bytes))&Pnacl_M25_PPB_NaCl_Private_DispatchEvent, .SetReadOnlyProperty = (void (*)(PP_Instance instance, struct PP_Var key, struct PP_Var value))&Pnacl_M25_PPB_NaCl_Private_SetReadOnlyProperty, - .ReportLoadError = (void (*)(PP_Instance instance, PP_NaClError error, const char* error_message, PP_Bool is_installed))&Pnacl_M25_PPB_NaCl_Private_ReportLoadError, + .ReportLoadError = (void (*)(PP_Instance instance, PP_NaClError error, const char* error_message, const char* console_message, PP_Bool is_installed))&Pnacl_M25_PPB_NaCl_Private_ReportLoadError, .InstanceDestroyed = (void (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_InstanceDestroyed, .NaClDebugStubEnabled = (PP_Bool (*)(void))&Pnacl_M25_PPB_NaCl_Private_NaClDebugStubEnabled, .GetSandboxArch = (const char* (*)(void))&Pnacl_M25_PPB_NaCl_Private_GetSandboxArch, - .GetUrlScheme = (PP_UrlSchemeType (*)(struct PP_Var url))&Pnacl_M25_PPB_NaCl_Private_GetUrlScheme + .GetUrlScheme = (PP_UrlSchemeType (*)(struct PP_Var url))&Pnacl_M25_PPB_NaCl_Private_GetUrlScheme, + .LogToConsole = (void (*)(PP_Instance instance, const char* message))&Pnacl_M25_PPB_NaCl_Private_LogToConsole }; static const struct PPB_NetAddress_Private_0_1 Pnacl_Wrappers_PPB_NetAddress_Private_0_1 = { |