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

Side by Side Diff: content/browser/android/sync_input_event_filter.cc

Issue 15484013: Remove dead WebCompositorInputHandler related code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "base/debug/trace_event.h" 5 #include "base/debug/trace_event.h"
6 #include "content/browser/android/sync_input_event_filter.h" 6 #include "content/browser/android/sync_input_event_filter.h"
7 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositorInputHan dler.h"
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositorInputHan dlerClient.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 7 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
10 8
11 using WebKit::WebInputEvent; 9 using WebKit::WebInputEvent;
12 10
13 namespace content { 11 namespace content {
14 12
15 class SyncInputEventFilter::InputHandlerWrapper
16 : public WebKit::WebCompositorInputHandlerClient {
17 public:
18 InputHandlerWrapper(SyncInputEventFilter* event_filter,
19 WebKit::WebCompositorInputHandler* input_handler)
20 : event_result_(INPUT_EVENT_ACK_STATE_UNKNOWN),
21 event_filter_(event_filter),
22 input_handler_(input_handler) {
23 input_handler_->setClient(this);
24 }
25
26 virtual ~InputHandlerWrapper() {
27 input_handler_->setClient(NULL);
28 }
29
30 InputEventAckState HandleInputEvent(
31 const WebKit::WebInputEvent& input_event) {
32
33 // Clear the result for the (unexpected) case that callbacks to
34 // did/didNotHandleInputEvent are not made synchronously.
35 event_result_ = INPUT_EVENT_ACK_STATE_UNKNOWN;
36
37 // It is expected that input_handler_ makes an appropriate synchronous
38 // callback to did/didNotHandleInputEvent. event_result_ is then assigned in
39 // those callbacks.
40 input_handler_->handleInputEvent(input_event);
41
42 DCHECK(event_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN);
43
44 return event_result_;
45 }
46
47 WebKit::WebCompositorInputHandler* input_handler() const {
48 return input_handler_;
49 }
50
51 // WebCompositorInputHandlerClient methods:
52
53 virtual void willShutdown() {
54 event_filter_->ClearInputHandler();
55 }
56
57 virtual void didHandleInputEvent() {
58 event_result_ = INPUT_EVENT_ACK_STATE_CONSUMED;
59 }
60
61 virtual void didNotHandleInputEvent(bool send_to_widget) {
62 event_result_ = send_to_widget ? INPUT_EVENT_ACK_STATE_NOT_CONSUMED
63 : INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS;
64 }
65
66 private:
67 // This acts as a temporary result, storing the result of the
68 // did/didNotHandleInputEvent callbacks. We use it to avoid creating a
69 // closure or reference to a stack variable.
70 InputEventAckState event_result_;
71
72 SyncInputEventFilter* event_filter_;
73 WebKit::WebCompositorInputHandler* input_handler_;
74
75 DISALLOW_COPY_AND_ASSIGN(InputHandlerWrapper);
76 };
77
78 //------------------------------------------------------------------------------ 13 //------------------------------------------------------------------------------
79 14
80 SyncInputEventFilter::SyncInputEventFilter() { 15 SyncInputEventFilter::SyncInputEventFilter() {
81 } 16 }
82 17
83 SyncInputEventFilter::~SyncInputEventFilter() { 18 SyncInputEventFilter::~SyncInputEventFilter() {
84 DCHECK(thread_checker_.CalledOnValidThread()); 19 DCHECK(thread_checker_.CalledOnValidThread());
85 } 20 }
86 21
87 InputEventAckState SyncInputEventFilter::HandleInputEvent( 22 InputEventAckState SyncInputEventFilter::HandleInputEvent(
88 const WebInputEvent& event) { 23 const WebInputEvent& event) {
89 if (!input_handler_) 24 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
jamesr 2013/05/22 01:15:25 this is just a stub, of course - I'm pretty sure t
Jói 2013/05/22 02:25:59 Do you want to leave a comment to this effect, per
joth 2013/05/22 04:34:24 We'll need to jiggle some bits around to make it w
jamesr 2013/05/22 07:05:09 I'd rather leave this to the folks working on andr
90 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
91
92 return input_handler_->HandleInputEvent(event);
93 }
94
95 void SyncInputEventFilter::SetInputHandler(
96 WebKit::WebCompositorInputHandler* new_input_handler) {
97 DCHECK(thread_checker_.CalledOnValidThread());
98
99 if (!new_input_handler) {
100 return;
101 }
102
103 if (input_handler_) {
104 // It's valid to call SetInputHandler() with the same input_handler many
105 // times, but it's not valid to change the input_handler once it's been set.
106 DCHECK_EQ(input_handler_->input_handler(), new_input_handler);
107 return;
108 }
109
110 TRACE_EVENT0("cc", "SyncInputEventFilter::SetInputHandler");
111 input_handler_.reset(new InputHandlerWrapper(this, new_input_handler));
112 } 25 }
113 26
114 void SyncInputEventFilter::ClearInputHandler() { 27 void SyncInputEventFilter::ClearInputHandler() {
115 DCHECK(thread_checker_.CalledOnValidThread()); 28 DCHECK(thread_checker_.CalledOnValidThread());
116 TRACE_EVENT0("cc", "SyncInputEventFilter::ClearInputHandler");
117 input_handler_.reset();
118 } 29 }
119 30
120 } // namespace content 31 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698