summaryrefslogtreecommitdiffstats
path: root/ppapi/thunk
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-31 05:00:26 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-31 05:00:26 +0000
commita9b16dd01eea5070cab620a1177a05a6b43677ee (patch)
tree69efee3fc88d36da9d9462e96bc7609b1f74b1b2 /ppapi/thunk
parente0001c50836c2de0f95549fb901f4f23b4ab0a0b (diff)
downloadchromium_src-a9b16dd01eea5070cab620a1177a05a6b43677ee.zip
chromium_src-a9b16dd01eea5070cab620a1177a05a6b43677ee.tar.gz
chromium_src-a9b16dd01eea5070cab620a1177a05a6b43677ee.tar.bz2
The tricky part about logging to the console is that many of the errors are generated by invalid resources, from which we have no context. This means we don't know the instance to send the error message of.
Plumbing this through in a way that works proved much harder than I expected. I added log functions to the PpapiGlobals so that we can call it easily from all places. It can either go off an instance (like PPB_Console does) or a module, or nothing. In the module case, all consoles associated with all instances in the module get the log message, in the no context case, all consoles associated with any pepper plugin get the message. In the IPC proxy, we know the module from whence the error came since there's a unique process for it. So proxied errors with no context when run out of process get translated into errors with PP_Module context. In the common case, there's only one instance for a module, so this works out nicely. I added some logging ability to resources and added some errors to Graphics2D and URLLoader. We can add messages to more classes as the need arises. I added some advice on writing them to the chromium pepper page. Review URL: https://chromiumcodereview.appspot.com/9160017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119853 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/thunk')
-rw-r--r--ppapi/thunk/enter.cc27
-rw-r--r--ppapi/thunk/ppb_instance_api.h5
2 files changed, 26 insertions, 6 deletions
diff --git a/ppapi/thunk/enter.cc b/ppapi/thunk/enter.cc
index 42f4a0e..43e80fe 100644
--- a/ppapi/thunk/enter.cc
+++ b/ppapi/thunk/enter.cc
@@ -7,7 +7,9 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop.h"
+#include "base/stringprintf.h"
#include "ppapi/c/pp_errors.h"
+#include "ppapi/shared_impl/ppapi_globals.h"
#include "ppapi/thunk/ppb_instance_api.h"
#include "ppapi/thunk/resource_creation_api.h"
@@ -74,15 +76,32 @@ Resource* EnterBase::GetResource(PP_Resource resource) const {
return PpapiGlobals::Get()->GetResourceTracker()->GetResource(resource);
}
-void EnterBase::SetStateForResourceError(PP_Resource /* pp_resource */,
- Resource* /* resource_base */,
+void EnterBase::SetStateForResourceError(PP_Resource pp_resource,
+ Resource* resource_base,
void* object,
- bool /* report_error */) {
+ bool report_error) {
if (object)
return; // Everything worked.
retval_ = PP_ERROR_BADRESOURCE;
- // TODO(brettw) log the error.
+
+ // We choose to silently ignore the error when the pp_resource is null
+ // because this is a pretty common case and we don't want to have lots
+ // of errors in the log. This should be an obvious case to debug.
+ if (report_error && pp_resource) {
+ std::string message;
+ if (resource_base) {
+ message = base::StringPrintf(
+ "0x%X is not the correct type for this function.",
+ pp_resource);
+ } else {
+ message = base::StringPrintf(
+ "0x%X is not a valid resource ID.",
+ pp_resource);
+ }
+ PpapiGlobals::Get()->BroadcastLogWithSource(0, PP_LOGLEVEL_ERROR,
+ std::string(), message);
+ }
}
} // namespace subtle
diff --git a/ppapi/thunk/ppb_instance_api.h b/ppapi/thunk/ppb_instance_api.h
index 013f61b..6d0339a 100644
--- a/ppapi/thunk/ppb_instance_api.h
+++ b/ppapi/thunk/ppb_instance_api.h
@@ -5,6 +5,7 @@
#ifndef PPAPI_THUNK_INSTANCE_API_H_
#define PPAPI_THUNK_INSTANCE_API_H_
+#include "ppapi/c/dev/ppb_console_dev.h"
#include "ppapi/c/dev/ppb_gamepad_dev.h"
#include "ppapi/c/dev/ppb_url_util_dev.h"
#include "ppapi/c/pp_completion_callback.h"
@@ -47,10 +48,10 @@ class PPB_Instance_FunctionAPI {
// Console.
virtual void Log(PP_Instance instance,
- int log_level,
+ PP_LogLevel_Dev log_level,
PP_Var value) = 0;
virtual void LogWithSource(PP_Instance instance,
- int log_level,
+ PP_LogLevel_Dev log_level,
PP_Var source,
PP_Var value) = 0;