Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(727)

Side by Side Diff: ppapi/cpp/private/instance_private.cc

Issue 10703146: PPAPI: Add console logging methods to pp::InstancePrivate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: asdf Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/cpp/private/instance_private.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/cpp/private/instance_private.h" 5 #include "ppapi/cpp/private/instance_private.h"
6 6
7 #include "ppapi/c/private/ppb_instance_private.h" 7 #include "ppapi/c/private/ppb_instance_private.h"
8 #include "ppapi/c/private/ppp_instance_private.h" 8 #include "ppapi/c/private/ppp_instance_private.h"
9 #include "ppapi/cpp/module_impl.h" 9 #include "ppapi/cpp/module_impl.h"
10 #include "ppapi/cpp/private/var_private.h" 10 #include "ppapi/cpp/private/var_private.h"
11 11
12 namespace pp { 12 namespace pp {
13 13
14 namespace { 14 namespace {
15 15
16 template <> const char* interface_name<PPB_Instance_Private>() { 16 template <> const char* interface_name<PPB_Instance_Private>() {
17 return PPB_INSTANCE_PRIVATE_INTERFACE; 17 return PPB_INSTANCE_PRIVATE_INTERFACE;
18 } 18 }
19 19
20 template <> const char* interface_name<PPB_Console_Dev_0_1>() {
21 return PPB_CONSOLE_DEV_INTERFACE_0_1;
22 }
23
20 PP_Var GetInstanceObject(PP_Instance pp_instance) { 24 PP_Var GetInstanceObject(PP_Instance pp_instance) {
21 Module* module_singleton = Module::Get(); 25 Module* module_singleton = Module::Get();
22 if (!module_singleton) 26 if (!module_singleton)
23 return Var().Detach(); 27 return Var().Detach();
24 InstancePrivate* instance_private = static_cast<InstancePrivate*>( 28 InstancePrivate* instance_private = static_cast<InstancePrivate*>(
25 module_singleton->InstanceForPPInstance(pp_instance)); 29 module_singleton->InstanceForPPInstance(pp_instance));
26 if (!instance_private) 30 if (!instance_private)
27 return Var().Detach(); 31 return Var().Detach();
28 return instance_private->GetInstanceObject().Detach(); 32 return instance_private->GetInstanceObject().Detach();
29 } 33 }
(...skipping 29 matching lines...) Expand all
59 return VarPrivate(); 63 return VarPrivate();
60 return VarPrivate(PASS_REF, 64 return VarPrivate(PASS_REF,
61 get_interface<PPB_Instance_Private>()->GetOwnerElementObject( 65 get_interface<PPB_Instance_Private>()->GetOwnerElementObject(
62 pp_instance())); 66 pp_instance()));
63 } 67 }
64 68
65 VarPrivate InstancePrivate::ExecuteScript(const Var& script, Var* exception) { 69 VarPrivate InstancePrivate::ExecuteScript(const Var& script, Var* exception) {
66 if (!has_interface<PPB_Instance_Private>()) 70 if (!has_interface<PPB_Instance_Private>())
67 return VarPrivate(); 71 return VarPrivate();
68 return VarPrivate(PASS_REF, 72 return VarPrivate(PASS_REF,
69 get_interface<PPB_Instance_Private>()->ExecuteScript( 73 get_interface<PPB_Instance_Private>()->ExecuteScript(
70 pp_instance(), 74 pp_instance(),
71 script.pp_var(), 75 script.pp_var(),
72 VarPrivate::OutException(exception).get())); 76 VarPrivate::OutException(exception).get()));
77 }
78
79 void InstancePrivate::LogToConsole(PP_LogLevel_Dev level, const Var& value) {
80 if (!has_interface<PPB_Console_Dev_0_1>())
81 return;
82 get_interface<PPB_Console_Dev_0_1>()->Log(
83 pp_instance(), level, value.pp_var());
84 }
85
86 void InstancePrivate::LogToConsoleWithSource(PP_LogLevel_Dev level,
87 const Var& source,
88 const Var& value) {
89 if (!has_interface<PPB_Console_Dev_0_1>())
90 return;
91 get_interface<PPB_Console_Dev_0_1>()->LogWithSource(
92 pp_instance(), level, source.pp_var(), value.pp_var());
73 } 93 }
74 94
75 } // namespace pp 95 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/private/instance_private.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698