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
104
105
|
// Copyright (c) 2010 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_testing_proxy.h"
#include "base/message_loop.h"
#include "ppapi/c/dev/ppb_testing_dev.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/ppapi_messages.h"
namespace pp {
namespace proxy {
namespace {
PP_Bool ReadImageData(PP_Resource device_context_2d,
PP_Resource image,
const PP_Point* top_left) {
PP_Bool result = PP_FALSE;
PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBTesting_ReadImageData(
INTERFACE_ID_PPB_TESTING, device_context_2d, image, *top_left, &result));
return result;
}
void RunMessageLoop() {
bool old_state = MessageLoop::current()->NestableTasksAllowed();
MessageLoop::current()->SetNestableTasksAllowed(true);
MessageLoop::current()->Run();
MessageLoop::current()->SetNestableTasksAllowed(old_state);
}
void QuitMessageLoop() {
MessageLoop::current()->QuitNow();
}
uint32_t GetLiveObjectCount(PP_Module module_id) {
uint32_t result = 0;
PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBTesting_GetLiveObjectCount(
INTERFACE_ID_PPB_TESTING, module_id, &result));
return result;
}
const PPB_Testing_Dev testing_interface = {
&ReadImageData,
&RunMessageLoop,
&QuitMessageLoop,
&GetLiveObjectCount
};
} // namespace
PPB_Testing_Proxy::PPB_Testing_Proxy(Dispatcher* dispatcher,
const void* target_interface)
: InterfaceProxy(dispatcher, target_interface) {
}
PPB_Testing_Proxy::~PPB_Testing_Proxy() {
}
const void* PPB_Testing_Proxy::GetSourceInterface() const {
return &testing_interface;
}
InterfaceID PPB_Testing_Proxy::GetInterfaceId() const {
return INTERFACE_ID_PPB_TESTING;
}
void PPB_Testing_Proxy::OnMessageReceived(const IPC::Message& msg) {
IPC_BEGIN_MESSAGE_MAP(PPB_Testing_Proxy, msg)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_ReadImageData,
OnMsgReadImageData)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_RunMessageLoop,
OnMsgRunMessageLoop)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_QuitMessageLoop,
OnMsgQuitMessageLoop)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_GetLiveObjectCount,
OnMsgGetLiveObjectCount)
IPC_END_MESSAGE_MAP()
}
void PPB_Testing_Proxy::OnMsgReadImageData(PP_Resource device_context_2d,
PP_Resource image,
const PP_Point& top_left,
PP_Bool* result) {
*result = ppb_testing_target()->ReadImageData(
device_context_2d, image, &top_left);
}
void PPB_Testing_Proxy::OnMsgRunMessageLoop(bool* dummy) {
ppb_testing_target()->RunMessageLoop();
*dummy = false;
}
void PPB_Testing_Proxy::OnMsgQuitMessageLoop() {
ppb_testing_target()->QuitMessageLoop();
}
void PPB_Testing_Proxy::OnMsgGetLiveObjectCount(PP_Module module_id,
uint32_t* result) {
*result = ppb_testing_target()->GetLiveObjectCount(module_id);
}
} // namespace proxy
} // namespace pp
|