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

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

Issue 7285010: Implement an input event resource. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ppapi/proxy/ppp_input_event_proxy.h"
6
7 #include <algorithm>
8
9 #include "ppapi/c/ppp_input_event.h"
10 #include "ppapi/proxy/host_dispatcher.h"
11 #include "ppapi/proxy/plugin_dispatcher.h"
12 #include "ppapi/proxy/plugin_resource_tracker.h"
13 #include "ppapi/proxy/ppapi_messages.h"
14 #include "ppapi/proxy/ppb_input_event_proxy.h"
15 #include "ppapi/thunk/enter.h"
16 #include "ppapi/thunk/ppb_input_event_api.h"
17
18 using ppapi::InputEventData;
19 using ppapi::thunk::EnterResourceNoLock;
20 using ppapi::thunk::PPB_InputEvent_API;
21
22 namespace pp {
23 namespace proxy {
24
25 namespace {
26
27 PP_Bool HandleInputEvent(PP_Instance instance, PP_Resource input_event) {
28 EnterResourceNoLock<PPB_InputEvent_API> enter(input_event, false);
29 if (enter.failed()) {
30 NOTREACHED();
31 return PP_FALSE;
32 }
33 const InputEventData& data = enter.object()->GetInputEventData();
34 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
35 if (!dispatcher) {
36 NOTREACHED();
37 return PP_FALSE;
38 }
39
40 // Need to send different messages depending on whether filtering is needed.
41 PP_Bool result = PP_FALSE;
42 if (data.is_filtered) {
43 dispatcher->Send(new PpapiMsg_PPPInputEvent_HandleFilteredInputEvent(
44 INTERFACE_ID_PPP_INPUT_EVENT, instance, data, &result));
45 } else {
46 dispatcher->Send(new PpapiMsg_PPPInputEvent_HandleInputEvent(
47 INTERFACE_ID_PPP_INPUT_EVENT, instance, data));
48 }
49 return result;
50 }
51
52 static const PPP_InputEvent input_event_interface = {
53 &HandleInputEvent
54 };
55
56 InterfaceProxy* CreateInputEventProxy(Dispatcher* dispatcher,
57 const void* target_interface) {
58 return new PPP_InputEvent_Proxy(dispatcher, target_interface);
59 }
60
61 } // namespace
62
63 PPP_InputEvent_Proxy::PPP_InputEvent_Proxy(Dispatcher* dispatcher,
64 const void* target_interface)
65 : InterfaceProxy(dispatcher, target_interface) {
66 }
67
68 PPP_InputEvent_Proxy::~PPP_InputEvent_Proxy() {
69 }
70
71 // static
72 const InterfaceProxy::Info* PPP_InputEvent_Proxy::GetInfo() {
73 static const Info info = {
74 &input_event_interface,
75 PPP_INPUT_EVENT_INTERFACE,
76 INTERFACE_ID_PPP_INPUT_EVENT,
77 false,
78 &CreateInputEventProxy,
79 };
80 return &info;
81 }
82
83 bool PPP_InputEvent_Proxy::OnMessageReceived(const IPC::Message& msg) {
84 bool handled = true;
85 IPC_BEGIN_MESSAGE_MAP(PPP_InputEvent_Proxy, msg)
86 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInputEvent_HandleInputEvent,
87 OnMsgHandleInputEvent)
88 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInputEvent_HandleFilteredInputEvent,
89 OnMsgHandleFilteredInputEvent)
90 IPC_MESSAGE_UNHANDLED(handled = false)
91 IPC_END_MESSAGE_MAP()
92 return handled;
93 }
94
95 void PPP_InputEvent_Proxy::OnMsgHandleInputEvent(PP_Instance instance,
96 const InputEventData& data) {
97 PP_Resource event_resource = PPB_InputEvent_Proxy::CreateProxyResource(
98 instance, data);
99 ppp_input_event_target()->HandleInputEvent(instance, event_resource);
100 PluginResourceTracker::GetInstance()->ReleaseResource(event_resource);
101 }
102
103 void PPP_InputEvent_Proxy::OnMsgHandleFilteredInputEvent(
104 PP_Instance instance,
105 const InputEventData& data,
106 PP_Bool* result) {
107 PP_Resource event_resource = PPB_InputEvent_Proxy::CreateProxyResource(
108 instance, data);
109 *result = ppp_input_event_target()->HandleInputEvent(instance,
110 event_resource);
111 PluginResourceTracker::GetInstance()->ReleaseResource(event_resource);
dmichael (off chromium) 2011/07/01 20:04:19 Okay, scratch my earlier comment about reminder to
112 }
113
114 } // namespace proxy
115 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698