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

Side by Side Diff: content/renderer/gpu/input_event_filter.h

Issue 14487003: Add a new pair of IPC categories for messages that need handling as input events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addresses feedback Created 7 years, 8 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
« no previous file with comments | « content/public/test/render_view_test.cc ('k') | content/renderer/gpu/input_event_filter.cc » ('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 #ifndef CONTENT_RENDERER_GPU_INPUT_EVENT_FILTER_H_ 5 #ifndef CONTENT_RENDERER_GPU_INPUT_EVENT_FILTER_H_
6 #define CONTENT_RENDERER_GPU_INPUT_EVENT_FILTER_H_ 6 #define CONTENT_RENDERER_GPU_INPUT_EVENT_FILTER_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <set> 9 #include <set>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 #include "content/port/common/input_event_ack_state.h" 14 #include "content/port/common/input_event_ack_state.h"
15 #include "ipc/ipc_channel_proxy.h" 15 #include "ipc/ipc_channel_proxy.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
17 17
18 // This class can be used to intercept ViewMsg_HandleInputEvent messages 18 // This class can be used to intercept InputMsg_HandleInputEvent messages
19 // and have them be delivered to a target thread. Input events are filtered 19 // and have them be delivered to a target thread. Input events are filtered
20 // based on routing_id (see AddRoute and RemoveRoute). 20 // based on routing_id (see AddRoute and RemoveRoute).
21 // 21 //
22 // The user of this class provides an instance of InputEventFilter::Handler, 22 // The user of this class provides an instance of InputEventFilter::Handler,
23 // which will be passed WebInputEvents on the target thread. 23 // which will be passed WebInputEvents on the target thread.
24 // 24 //
25 25
26 namespace content { 26 namespace content {
27 27
28 class CONTENT_EXPORT InputEventFilter 28 class CONTENT_EXPORT InputEventFilter
29 : public IPC::ChannelProxy::MessageFilter { 29 : public IPC::ChannelProxy::MessageFilter {
30 public: 30 public:
31 typedef base::Callback<void(int /*routing_id*/, 31 typedef base::Callback<void(int /*routing_id*/,
32 const WebKit::WebInputEvent*)> Handler; 32 const WebKit::WebInputEvent*)> Handler;
33 33
34 // The |handler| is invoked on the thread associated with |target_loop| to 34 // The |handler| is invoked on the thread associated with |target_loop| to
35 // handle input events matching the filtered routes. In response, the 35 // handle input events matching the filtered routes. In response, the
36 // handler should call either DidHandleInputEvent or DidNotHandleInputEvent. 36 // handler should call either DidHandleInputEvent or DidNotHandleInputEvent.
37 // These may be called asynchronously to the handler invocation, but they 37 // These may be called asynchronously to the handler invocation, but they
38 // must be called on the target thread. 38 // must be called on the target thread.
39 // 39 //
40 // If DidNotHandleInputEvent is called with send_to_widget set to true, then 40 // If DidNotHandleInputEvent is called with send_to_widget set to true, then
41 // the original ViewMsg_HandleInputEvent message will be delivered to 41 // the original InputMsg_HandleInputEvent message will be delivered to
42 // |main_listener| on the main thread. (The "main thread" in this context is 42 // |main_listener| on the main thread. (The "main thread" in this context is
43 // the thread where the InputEventFilter was constructed.) If send_to_widget 43 // the thread where the InputEventFilter was constructed.) If send_to_widget
44 // is true, then a ViewHostMsg_HandleInputEvent_ACK will not be generated, 44 // is true, then a InputHostMsg_HandleInputEvent_ACK will not be
45 // leaving that responsibility up to the eventual handler on the main thread. 45 // generated, leaving that responsibility up to the eventual handler on the
46 // main thread.
46 // 47 //
47 InputEventFilter(IPC::Listener* main_listener, 48 InputEventFilter(IPC::Listener* main_listener,
48 const scoped_refptr<base::MessageLoopProxy>& target_loop, 49 const scoped_refptr<base::MessageLoopProxy>& target_loop,
49 const Handler& handler); 50 const Handler& handler);
50 51
51 // Define the message routes to be filtered. 52 // Define the message routes to be filtered.
52 void AddRoute(int routing_id); 53 void AddRoute(int routing_id);
53 void RemoveRoute(int routing_id); 54 void RemoveRoute(int routing_id);
54 55
55 // Called on the target thread by the Handler. 56 // Called on the target thread by the Handler.
56 void DidHandleInputEvent(); 57 void DidHandleInputEvent();
57 void DidNotHandleInputEvent(bool send_to_widget); 58 void DidNotHandleInputEvent(bool send_to_widget);
58 59
59 // IPC::ChannelProxy::MessageFilter methods: 60 // IPC::ChannelProxy::MessageFilter methods:
60 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; 61 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE;
61 virtual void OnFilterRemoved() OVERRIDE; 62 virtual void OnFilterRemoved() OVERRIDE;
62 virtual void OnChannelClosing() OVERRIDE; 63 virtual void OnChannelClosing() OVERRIDE;
63 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 64 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
64 65
65 // Expects a ViewMsg_HandleInputEvent message. 66 // Expects a InputMsg_HandleInputEvent message.
66 static const WebKit::WebInputEvent* CrackMessage(const IPC::Message& message); 67 static const WebKit::WebInputEvent* CrackMessage(const IPC::Message& message);
67 68
68 private: 69 private:
69 friend class IPC::ChannelProxy::MessageFilter; 70 friend class IPC::ChannelProxy::MessageFilter;
70 virtual ~InputEventFilter(); 71 virtual ~InputEventFilter();
71 72
72 void ForwardToMainListener(const IPC::Message& message); 73 void ForwardToMainListener(const IPC::Message& message);
73 void ForwardToHandler(const IPC::Message& message); 74 void ForwardToHandler(const IPC::Message& message);
74 void SendACK(const IPC::Message& message, InputEventAckState ack_result); 75 void SendACK(const IPC::Message& message, InputEventAckState ack_result);
75 void SendACKOnIOThread(int routing_id, WebKit::WebInputEvent::Type event_type, 76 void SendACKOnIOThread(int routing_id, WebKit::WebInputEvent::Type event_type,
(...skipping 14 matching lines...) Expand all
90 // Protects access to routes_. 91 // Protects access to routes_.
91 base::Lock routes_lock_; 92 base::Lock routes_lock_;
92 93
93 // Indicates the routing_ids for which input events should be filtered. 94 // Indicates the routing_ids for which input events should be filtered.
94 std::set<int> routes_; 95 std::set<int> routes_;
95 }; 96 };
96 97
97 } // namespace content 98 } // namespace content
98 99
99 #endif // CONTENT_RENDERER_GPU_INPUT_EVENT_FILTER_H_ 100 #endif // CONTENT_RENDERER_GPU_INPUT_EVENT_FILTER_H_
OLDNEW
« no previous file with comments | « content/public/test/render_view_test.cc ('k') | content/renderer/gpu/input_event_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698