1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
// Copyright (c) 2011 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.
#include "ppapi/proxy/ppb_console_proxy.h"
#include "ppapi/c/dev/ppb_console_dev.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/ppapi_messages.h"
namespace ppapi {
namespace proxy {
namespace {
void Log(PP_Instance instance, PP_LogLevel_Dev level, PP_Var value) {
PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
if (!dispatcher)
return;
dispatcher->Send(new PpapiHostMsg_PPBConsole_Log(
INTERFACE_ID_PPB_CONSOLE, instance, static_cast<int>(level),
SerializedVarSendInput(dispatcher, value)));
}
void LogWithSource(PP_Instance instance,
PP_LogLevel_Dev level,
const PP_Var source,
const PP_Var value) {
PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
if (!dispatcher)
return;
dispatcher->Send(new PpapiHostMsg_PPBConsole_LogWithSource(
INTERFACE_ID_PPB_CONSOLE, instance, static_cast<int>(level),
SerializedVarSendInput(dispatcher, source),
SerializedVarSendInput(dispatcher, value)));
}
const PPB_Console_Dev console_interface = {
&Log,
&LogWithSource
};
InterfaceProxy* CreateConsoleProxy(Dispatcher* dispatcher,
const void* target_interface) {
return new PPB_Console_Proxy(dispatcher, target_interface);
}
} // namespace
PPB_Console_Proxy::PPB_Console_Proxy(Dispatcher* dispatcher,
const void* target_interface)
: InterfaceProxy(dispatcher, target_interface) {
}
PPB_Console_Proxy::~PPB_Console_Proxy() {
}
// static
const InterfaceProxy::Info* PPB_Console_Proxy::GetInfo() {
static const Info info = {
&console_interface,
PPB_CONSOLE_DEV_INTERFACE,
INTERFACE_ID_PPB_CONSOLE,
false,
&CreateConsoleProxy,
};
return &info;
}
bool PPB_Console_Proxy::OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PPB_Console_Proxy, msg)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBConsole_Log,
OnMsgLog)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBConsole_LogWithSource,
OnMsgLogWithSource)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void PPB_Console_Proxy::OnMsgLog(PP_Instance instance,
int log_level,
SerializedVarReceiveInput value) {
ppb_console_target()->Log(instance,
static_cast<PP_LogLevel_Dev>(log_level),
value.Get(dispatcher()));
}
void PPB_Console_Proxy::OnMsgLogWithSource(PP_Instance instance,
int log_level,
SerializedVarReceiveInput source,
SerializedVarReceiveInput value) {
ppb_console_target()->LogWithSource(
instance,
static_cast<PP_LogLevel_Dev>(log_level),
source.Get(dispatcher()),
value.Get(dispatcher()));
}
} // namespace proxy
} // namespace ppapi
|