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

Side by Side Diff: ppapi/proxy/ppb_testing_proxy.cc

Issue 8413021: Add functions to generate input events to PPB_Testing_Dev. These make (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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/proxy/ppb_testing_proxy.h ('k') | ppapi/tests/test_input_event.h » ('j') | 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) 2011 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/proxy/ppb_testing_proxy.h" 5 #include "ppapi/proxy/ppb_testing_proxy.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "ppapi/c/dev/ppb_testing_dev.h" 8 #include "ppapi/c/dev/ppb_testing_dev.h"
9 #include "ppapi/proxy/enter_proxy.h"
9 #include "ppapi/proxy/plugin_dispatcher.h" 10 #include "ppapi/proxy/plugin_dispatcher.h"
10 #include "ppapi/proxy/ppapi_messages.h" 11 #include "ppapi/proxy/ppapi_messages.h"
11 #include "ppapi/shared_impl/ppapi_globals.h" 12 #include "ppapi/shared_impl/ppapi_globals.h"
12 #include "ppapi/shared_impl/resource.h" 13 #include "ppapi/shared_impl/resource.h"
13 #include "ppapi/shared_impl/resource_tracker.h" 14 #include "ppapi/shared_impl/resource_tracker.h"
15 #include "ppapi/thunk/enter.h"
16 #include "ppapi/thunk/ppb_input_event_api.h"
17
18 using ppapi::thunk::EnterResource;
19 using ppapi::thunk::PPB_InputEvent_API;
14 20
15 namespace ppapi { 21 namespace ppapi {
16 namespace proxy { 22 namespace proxy {
17 23
18 namespace { 24 namespace {
19 25
20 PP_Bool ReadImageData(PP_Resource graphics_2d, 26 PP_Bool ReadImageData(PP_Resource graphics_2d,
21 PP_Resource image, 27 PP_Resource image,
22 const PP_Point* top_left) { 28 const PP_Point* top_left) {
23 Resource* image_object = 29 Resource* image_object =
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 uint32_t result = 0; 67 uint32_t result = 0;
62 dispatcher->Send(new PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance( 68 dispatcher->Send(new PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance(
63 API_ID_PPB_TESTING, instance_id, &result)); 69 API_ID_PPB_TESTING, instance_id, &result));
64 return result; 70 return result;
65 } 71 }
66 72
67 PP_Bool IsOutOfProcess() { 73 PP_Bool IsOutOfProcess() {
68 return PP_TRUE; 74 return PP_TRUE;
69 } 75 }
70 76
77 void SimulateInputEvent(PP_Instance instance_id, PP_Resource input_event) {
78 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id);
79 if (!dispatcher)
80 return;
81 EnterResource<PPB_InputEvent_API> enter(input_event, false);
82 if (enter.failed())
83 return;
84
85 const InputEventData& input_event_data = enter.object()->GetInputEventData();
86 dispatcher->Send(new PpapiHostMsg_PPBTesting_SimulateInputEvent(
87 API_ID_PPB_TESTING, instance_id, input_event_data));
88 }
89
71 const PPB_Testing_Dev testing_interface = { 90 const PPB_Testing_Dev testing_interface = {
72 &ReadImageData, 91 &ReadImageData,
73 &RunMessageLoop, 92 &RunMessageLoop,
74 &QuitMessageLoop, 93 &QuitMessageLoop,
75 &GetLiveObjectsForInstance, 94 &GetLiveObjectsForInstance,
76 &IsOutOfProcess 95 &IsOutOfProcess,
96 &SimulateInputEvent
77 }; 97 };
78 98
79 InterfaceProxy* CreateTestingProxy(Dispatcher* dispatcher) { 99 InterfaceProxy* CreateTestingProxy(Dispatcher* dispatcher) {
80 return new PPB_Testing_Proxy(dispatcher); 100 return new PPB_Testing_Proxy(dispatcher);
81 } 101 }
82 102
83 } // namespace 103 } // namespace
84 104
85 PPB_Testing_Proxy::PPB_Testing_Proxy(Dispatcher* dispatcher) 105 PPB_Testing_Proxy::PPB_Testing_Proxy(Dispatcher* dispatcher)
86 : InterfaceProxy(dispatcher), 106 : InterfaceProxy(dispatcher),
(...skipping 19 matching lines...) Expand all
106 return &info; 126 return &info;
107 } 127 }
108 128
109 bool PPB_Testing_Proxy::OnMessageReceived(const IPC::Message& msg) { 129 bool PPB_Testing_Proxy::OnMessageReceived(const IPC::Message& msg) {
110 bool handled = true; 130 bool handled = true;
111 IPC_BEGIN_MESSAGE_MAP(PPB_Testing_Proxy, msg) 131 IPC_BEGIN_MESSAGE_MAP(PPB_Testing_Proxy, msg)
112 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_ReadImageData, 132 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_ReadImageData,
113 OnMsgReadImageData) 133 OnMsgReadImageData)
114 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance, 134 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance,
115 OnMsgGetLiveObjectsForInstance) 135 OnMsgGetLiveObjectsForInstance)
136 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_SimulateInputEvent,
137 OnMsgSimulateInputEvent)
116 IPC_MESSAGE_UNHANDLED(handled = false) 138 IPC_MESSAGE_UNHANDLED(handled = false)
117 IPC_END_MESSAGE_MAP() 139 IPC_END_MESSAGE_MAP()
118 return handled; 140 return handled;
119 } 141 }
120 142
121 void PPB_Testing_Proxy::OnMsgReadImageData( 143 void PPB_Testing_Proxy::OnMsgReadImageData(
122 const HostResource& device_context_2d, 144 const HostResource& device_context_2d,
123 const HostResource& image, 145 const HostResource& image,
124 const PP_Point& top_left, 146 const PP_Point& top_left,
125 PP_Bool* result) { 147 PP_Bool* result) {
126 *result = ppb_testing_impl_->ReadImageData( 148 *result = ppb_testing_impl_->ReadImageData(
127 device_context_2d.host_resource(), image.host_resource(), &top_left); 149 device_context_2d.host_resource(), image.host_resource(), &top_left);
128 } 150 }
129 151
130 void PPB_Testing_Proxy::OnMsgRunMessageLoop(PP_Instance instance) { 152 void PPB_Testing_Proxy::OnMsgRunMessageLoop(PP_Instance instance) {
131 ppb_testing_impl_->RunMessageLoop(instance); 153 ppb_testing_impl_->RunMessageLoop(instance);
132 } 154 }
133 155
134 void PPB_Testing_Proxy::OnMsgQuitMessageLoop(PP_Instance instance) { 156 void PPB_Testing_Proxy::OnMsgQuitMessageLoop(PP_Instance instance) {
135 ppb_testing_impl_->QuitMessageLoop(instance); 157 ppb_testing_impl_->QuitMessageLoop(instance);
136 } 158 }
137 159
138 void PPB_Testing_Proxy::OnMsgGetLiveObjectsForInstance(PP_Instance instance, 160 void PPB_Testing_Proxy::OnMsgGetLiveObjectsForInstance(PP_Instance instance,
139 uint32_t* result) { 161 uint32_t* result) {
140 *result = ppb_testing_impl_->GetLiveObjectsForInstance(instance); 162 *result = ppb_testing_impl_->GetLiveObjectsForInstance(instance);
141 } 163 }
142 164
165 void PPB_Testing_Proxy::OnMsgSimulateInputEvent(
166 PP_Instance instance,
167 const InputEventData& input_event) {
168 scoped_refptr<InputEventImpl> input_event_impl(
169 new InputEventImpl(InputEventImpl::InitAsProxy(),
170 instance,
171 input_event));
172 ppb_testing_impl_->SimulateInputEvent(instance,
173 input_event_impl->pp_resource());
174 }
175
143 } // namespace proxy 176 } // namespace proxy
144 } // namespace ppapi 177 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_testing_proxy.h ('k') | ppapi/tests/test_input_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698