summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-15 18:39:51 +0000
committerteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-15 18:39:51 +0000
commit296258e4605c3f57224061dcebc7d09cad719345 (patch)
treebb0470002fd9f9481a5dbb5a0b267382106a7daa /ppapi
parent05b59c9d55924996b24f13785d2f15276078bb94 (diff)
downloadchromium_src-296258e4605c3f57224061dcebc7d09cad719345.zip
chromium_src-296258e4605c3f57224061dcebc7d09cad719345.tar.gz
chromium_src-296258e4605c3f57224061dcebc7d09cad719345.tar.bz2
Pepper: Fix MODULE_PRINTF behavior.
An earlier change to use VLOG() as the destination for pluging logging messages caused problems with MODULE_PRINTF() statements when NACL_PLUGIN_DEBUG is set. This change alters MODULE_PRINTF() and PLUGIN_PRINTF() to log to stderr when the NaCl interface isn't available, and tightens up where the PPB_NaCl_Private interface is set. BUG= Review URL: https://codereview.chromium.org/236943004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263942 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/native_client/src/trusted/plugin/module_ppapi.cc2
-rw-r--r--ppapi/native_client/src/trusted/plugin/utility.cc21
-rw-r--r--ppapi/native_client/src/trusted/plugin/utility.h1
3 files changed, 16 insertions, 8 deletions
diff --git a/ppapi/native_client/src/trusted/plugin/module_ppapi.cc b/ppapi/native_client/src/trusted/plugin/module_ppapi.cc
index b73a1a3..bc7a2c5 100644
--- a/ppapi/native_client/src/trusted/plugin/module_ppapi.cc
+++ b/ppapi/native_client/src/trusted/plugin/module_ppapi.cc
@@ -12,6 +12,7 @@
#include "ppapi/native_client/src/trusted/plugin/module_ppapi.h"
#include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h"
#include "ppapi/native_client/src/trusted/plugin/plugin.h"
+#include "ppapi/native_client/src/trusted/plugin/utility.h"
namespace plugin {
@@ -41,6 +42,7 @@ bool ModulePpapi::Init() {
"GetBrowserInterface returned NULL\n"));
return false;
}
+ SetNaClInterface(private_interface_);
launch_nacl_process = reinterpret_cast<LaunchNaClProcessFunc>(
private_interface_->LaunchSelLdr);
diff --git a/ppapi/native_client/src/trusted/plugin/utility.cc b/ppapi/native_client/src/trusted/plugin/utility.cc
index b1984ea..ea4a494 100644
--- a/ppapi/native_client/src/trusted/plugin/utility.cc
+++ b/ppapi/native_client/src/trusted/plugin/utility.cc
@@ -27,6 +27,15 @@ int NaClPluginPrintLog(const char *format, ...) {
static const int kStackBufferSize = 512;
char stack_buffer[kStackBufferSize];
+
+ // Just log locally to stderr if we can't use the nacl interface.
+ if (!GetNaClInterface()) {
+ va_start(arg, format);
+ int rc = vfprintf(stderr, format, arg);
+ va_end(arg);
+ return rc;
+ }
+
va_start(arg, format);
out_size = vsnprintf(stack_buffer, kStackBufferSize, format, arg);
va_end(arg);
@@ -101,15 +110,11 @@ bool IsValidIdentifierString(const char* strval, uint32_t* length) {
static const PPB_NaCl_Private* g_nacl_interface = NULL;
const PPB_NaCl_Private* GetNaClInterface() {
- if (g_nacl_interface)
- return g_nacl_interface;
-
- pp::Module *module = pp::Module::Get();
- CHECK(module);
- CHECK(module->core()->IsMainThread());
- g_nacl_interface = static_cast<const PPB_NaCl_Private*>(
- module->GetBrowserInterface(PPB_NACL_PRIVATE_INTERFACE));
return g_nacl_interface;
}
+void SetNaClInterface(const PPB_NaCl_Private* nacl_interface) {
+ g_nacl_interface = nacl_interface;
+}
+
} // namespace plugin
diff --git a/ppapi/native_client/src/trusted/plugin/utility.h b/ppapi/native_client/src/trusted/plugin/utility.h
index 758759c..062d22d 100644
--- a/ppapi/native_client/src/trusted/plugin/utility.h
+++ b/ppapi/native_client/src/trusted/plugin/utility.h
@@ -28,6 +28,7 @@ namespace plugin {
bool IsValidIdentifierString(const char* strval, uint32_t* length);
const PPB_NaCl_Private* GetNaClInterface();
+void SetNaClInterface(const PPB_NaCl_Private* nacl_interface);
// Debugging print utility
extern int gNaClPluginDebugPrintEnabled;