OLD | NEW |
1 // Copyright (c) 2012 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 | |
24 PP_Var GetInstanceObject(PP_Instance pp_instance) { | 20 PP_Var GetInstanceObject(PP_Instance pp_instance) { |
25 Module* module_singleton = Module::Get(); | 21 Module* module_singleton = Module::Get(); |
26 if (!module_singleton) | 22 if (!module_singleton) |
27 return Var().Detach(); | 23 return Var().Detach(); |
28 InstancePrivate* instance_private = static_cast<InstancePrivate*>( | 24 InstancePrivate* instance_private = static_cast<InstancePrivate*>( |
29 module_singleton->InstanceForPPInstance(pp_instance)); | 25 module_singleton->InstanceForPPInstance(pp_instance)); |
30 if (!instance_private) | 26 if (!instance_private) |
31 return Var().Detach(); | 27 return Var().Detach(); |
32 return instance_private->GetInstanceObject().Detach(); | 28 return instance_private->GetInstanceObject().Detach(); |
33 } | 29 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 VarPrivate InstancePrivate::ExecuteScript(const Var& script, Var* exception) { | 65 VarPrivate InstancePrivate::ExecuteScript(const Var& script, Var* exception) { |
70 if (!has_interface<PPB_Instance_Private>()) | 66 if (!has_interface<PPB_Instance_Private>()) |
71 return VarPrivate(); | 67 return VarPrivate(); |
72 return VarPrivate(PASS_REF, | 68 return VarPrivate(PASS_REF, |
73 get_interface<PPB_Instance_Private>()->ExecuteScript( | 69 get_interface<PPB_Instance_Private>()->ExecuteScript( |
74 pp_instance(), | 70 pp_instance(), |
75 script.pp_var(), | 71 script.pp_var(), |
76 VarPrivate::OutException(exception).get())); | 72 VarPrivate::OutException(exception).get())); |
77 } | 73 } |
78 | 74 |
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()); | |
93 } | |
94 | |
95 } // namespace pp | 75 } // namespace pp |
OLD | NEW |