summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-12 22:03:18 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-12 22:03:18 +0000
commit95549331a831de5e4fea29691340af2025be552c (patch)
tree972c0e44c689963ef54056ed2ef037d52f9b97c4
parentb1f94ee9e16d9905426355a529803f3433d00c6e (diff)
downloadchromium_src-95549331a831de5e4fea29691340af2025be552c.zip
chromium_src-95549331a831de5e4fea29691340af2025be552c.tar.gz
chromium_src-95549331a831de5e4fea29691340af2025be552c.tar.bz2
PPAPI: Add console logging methods to pp::InstancePrivate.
We didn't want to add them to pp::Instance (since they're not available to NaCl plugins?), so add them to InstancePrivate. (We can move them to Instance later, if desired.) BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/10703146 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146456 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ppapi/cpp/private/instance_private.cc30
-rw-r--r--ppapi/cpp/private/instance_private.h17
2 files changed, 41 insertions, 6 deletions
diff --git a/ppapi/cpp/private/instance_private.cc b/ppapi/cpp/private/instance_private.cc
index 4e38114..1dfabbf 100644
--- a/ppapi/cpp/private/instance_private.cc
+++ b/ppapi/cpp/private/instance_private.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -17,6 +17,10 @@ template <> const char* interface_name<PPB_Instance_Private>() {
return PPB_INSTANCE_PRIVATE_INTERFACE;
}
+template <> const char* interface_name<PPB_Console_Dev_0_1>() {
+ return PPB_CONSOLE_DEV_INTERFACE_0_1;
+}
+
PP_Var GetInstanceObject(PP_Instance pp_instance) {
Module* module_singleton = Module::Get();
if (!module_singleton)
@@ -66,10 +70,26 @@ VarPrivate InstancePrivate::ExecuteScript(const Var& script, Var* exception) {
if (!has_interface<PPB_Instance_Private>())
return VarPrivate();
return VarPrivate(PASS_REF,
- get_interface<PPB_Instance_Private>()->ExecuteScript(
- pp_instance(),
- script.pp_var(),
- VarPrivate::OutException(exception).get()));
+ get_interface<PPB_Instance_Private>()->ExecuteScript(
+ pp_instance(),
+ script.pp_var(),
+ VarPrivate::OutException(exception).get()));
+}
+
+void InstancePrivate::LogToConsole(PP_LogLevel_Dev level, const Var& value) {
+ if (!has_interface<PPB_Console_Dev_0_1>())
+ return;
+ get_interface<PPB_Console_Dev_0_1>()->Log(
+ pp_instance(), level, value.pp_var());
+}
+
+void InstancePrivate::LogToConsoleWithSource(PP_LogLevel_Dev level,
+ const Var& source,
+ const Var& value) {
+ if (!has_interface<PPB_Console_Dev_0_1>())
+ return;
+ get_interface<PPB_Console_Dev_0_1>()->LogWithSource(
+ pp_instance(), level, source.pp_var(), value.pp_var());
}
} // namespace pp
diff --git a/ppapi/cpp/private/instance_private.h b/ppapi/cpp/private/instance_private.h
index d658f0b..c6c51b7 100644
--- a/ppapi/cpp/private/instance_private.h
+++ b/ppapi/cpp/private/instance_private.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,11 +13,13 @@
* @{
*/
+#include "ppapi/c/dev/ppb_console_dev.h"
#include "ppapi/cpp/instance.h"
/** The C++ interface to the Pepper API. */
namespace pp {
+class Var;
class VarPrivate;
class InstancePrivate : public Instance {
@@ -46,6 +48,19 @@ class InstancePrivate : public Instance {
VarPrivate ExecuteScript(const Var& script, Var* exception = NULL);
// @}
+
+ // @{
+ /// @name PPB_Console_Dev methods for logging to the console:
+
+ /// See PPB_Console_Dev.Log.
+ void LogToConsole(PP_LogLevel_Dev level, const Var& value);
+
+ /// See PPB_Console_Dev.LogWithSource.
+ void LogToConsoleWithSource(PP_LogLevel_Dev level,
+ const Var& source,
+ const Var& value);
+
+ // @}
};
} // namespace pp