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

Side by Side Diff: content/renderer/mus/compositor_mus_connection.cc

Issue 1891413002: mash: Convert OnWindowInputEventAck to use an enum for handled status (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missed a file Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/renderer/mus/compositor_mus_connection.h" 5 #include "content/renderer/mus/compositor_mus_connection.h"
6 6
7 #include "base/single_thread_task_runner.h" 7 #include "base/single_thread_task_runner.h"
8 #include "content/common/input/web_input_event_traits.h" 8 #include "content/common/input/web_input_event_traits.h"
9 #include "content/renderer/input/input_handler_manager.h" 9 #include "content/renderer/input/input_handler_manager.h"
10 #include "content/renderer/mus/render_widget_mus_connection.h" 10 #include "content/renderer/mus/render_widget_mus_connection.h"
11 #include "mojo/converters/blink/blink_input_events_type_converters.h" 11 #include "mojo/converters/blink/blink_input_events_type_converters.h"
12 #include "mojo/converters/input_events/input_events_type_converters.h" 12 #include "mojo/converters/input_events/input_events_type_converters.h"
13 #include "ui/latency_info/latency_info.h" 13 #include "ui/latency_info/latency_info.h"
14 14
15 using mus::mojom::EventResult;
16
15 namespace { 17 namespace {
16 18
17 void DoNothingBool(bool result) {} 19 void DoNothingWithEventResult(EventResult result) {}
18 20
19 } // namespace 21 } // namespace
20 22
21 namespace content { 23 namespace content {
22 24
23 CompositorMusConnection::CompositorMusConnection( 25 CompositorMusConnection::CompositorMusConnection(
24 int routing_id, 26 int routing_id,
25 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, 27 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner,
26 const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner, 28 const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner,
27 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request, 29 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 DCHECK(main_task_runner_->BelongsToCurrentThread()); 73 DCHECK(main_task_runner_->BelongsToCurrentThread());
72 RenderWidgetMusConnection* connection = 74 RenderWidgetMusConnection* connection =
73 RenderWidgetMusConnection::Get(routing_id_); 75 RenderWidgetMusConnection::Get(routing_id_);
74 if (!connection) 76 if (!connection)
75 return; 77 return;
76 connection->OnConnectionLost(); 78 connection->OnConnectionLost();
77 } 79 }
78 80
79 void CompositorMusConnection::OnWindowInputEventOnMainThread( 81 void CompositorMusConnection::OnWindowInputEventOnMainThread(
80 std::unique_ptr<blink::WebInputEvent> web_event, 82 std::unique_ptr<blink::WebInputEvent> web_event,
81 const base::Callback<void(bool)>& ack) { 83 const base::Callback<void(EventResult)>& ack) {
82 DCHECK(main_task_runner_->BelongsToCurrentThread()); 84 DCHECK(main_task_runner_->BelongsToCurrentThread());
83 RenderWidgetMusConnection* connection = 85 RenderWidgetMusConnection* connection =
84 RenderWidgetMusConnection::Get(routing_id_); 86 RenderWidgetMusConnection::Get(routing_id_);
85 if (!connection) { 87 if (!connection) {
86 ack.Run(false); 88 ack.Run(EventResult::UNHANDLED);
87 return; 89 return;
88 } 90 }
89 connection->OnWindowInputEvent(std::move(web_event), ack); 91 connection->OnWindowInputEvent(std::move(web_event), ack);
90 } 92 }
91 93
92 void CompositorMusConnection::OnWindowInputEventAckOnMainThread( 94 void CompositorMusConnection::OnWindowInputEventAckOnMainThread(
93 const base::Callback<void(bool)>& ack, 95 const base::Callback<void(EventResult)>& ack,
94 bool handled) { 96 EventResult result) {
95 DCHECK(main_task_runner_->BelongsToCurrentThread()); 97 DCHECK(main_task_runner_->BelongsToCurrentThread());
96 compositor_task_runner_->PostTask(FROM_HERE, base::Bind(ack, handled)); 98 compositor_task_runner_->PostTask(FROM_HERE, base::Bind(ack, result));
97 } 99 }
98 100
99 void CompositorMusConnection::OnConnectionLost( 101 void CompositorMusConnection::OnConnectionLost(
100 mus::WindowTreeConnection* connection) { 102 mus::WindowTreeConnection* connection) {
101 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); 103 DCHECK(compositor_task_runner_->BelongsToCurrentThread());
102 main_task_runner_->PostTask( 104 main_task_runner_->PostTask(
103 FROM_HERE, 105 FROM_HERE,
104 base::Bind(&CompositorMusConnection::OnConnectionLostOnMainThread, this)); 106 base::Bind(&CompositorMusConnection::OnConnectionLostOnMainThread, this));
105 } 107 }
106 108
107 void CompositorMusConnection::OnEmbed(mus::Window* root) { 109 void CompositorMusConnection::OnEmbed(mus::Window* root) {
108 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); 110 DCHECK(compositor_task_runner_->BelongsToCurrentThread());
109 root_ = root; 111 root_ = root;
110 root_->set_input_event_handler(this); 112 root_->set_input_event_handler(this);
111 if (window_surface_binding_) { 113 if (window_surface_binding_) {
112 root->AttachSurface(mus::mojom::SurfaceType::DEFAULT, 114 root->AttachSurface(mus::mojom::SurfaceType::DEFAULT,
113 std::move(window_surface_binding_)); 115 std::move(window_surface_binding_));
114 } 116 }
115 } 117 }
116 118
117 void CompositorMusConnection::OnWindowInputEvent( 119 void CompositorMusConnection::OnWindowInputEvent(
118 mus::Window* window, 120 mus::Window* window,
119 const ui::Event& event, 121 const ui::Event& event,
120 std::unique_ptr<base::Callback<void(bool)>>* ack_callback) { 122 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) {
121 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); 123 DCHECK(compositor_task_runner_->BelongsToCurrentThread());
122 // TODO(moshayedi): Convert ui::Event directly to blink::WebInputEvent. 124 // TODO(moshayedi): Convert ui::Event directly to blink::WebInputEvent.
123 std::unique_ptr<blink::WebInputEvent> web_event( 125 std::unique_ptr<blink::WebInputEvent> web_event(
124 mus::mojom::Event::From(event) 126 mus::mojom::Event::From(event)
125 .To<std::unique_ptr<blink::WebInputEvent>>()); 127 .To<std::unique_ptr<blink::WebInputEvent>>());
126 // TODO(sad): We probably need to plumb LatencyInfo through Mus. 128 // TODO(sad): We probably need to plumb LatencyInfo through Mus.
127 ui::LatencyInfo info; 129 ui::LatencyInfo info;
128 InputEventAckState ack_state = input_handler_manager_->HandleInputEvent( 130 InputEventAckState ack_state = input_handler_manager_->HandleInputEvent(
129 routing_id_, web_event.get(), &info); 131 routing_id_, web_event.get(), &info);
130 // TODO(jonross): We probably need to ack the event based on the consumed 132 // TODO(jonross): We probably need to ack the event based on the consumed
131 // state. 133 // state.
132 if (ack_state != INPUT_EVENT_ACK_STATE_NOT_CONSUMED) 134 if (ack_state != INPUT_EVENT_ACK_STATE_NOT_CONSUMED)
133 return; 135 return;
134 base::Callback<void(bool)> ack = base::Bind(&::DoNothingBool); 136 base::Callback<void(EventResult)> ack =
137 base::Bind(&::DoNothingWithEventResult);
135 const bool send_ack = WebInputEventTraits::ShouldBlockEventStream(*web_event); 138 const bool send_ack = WebInputEventTraits::ShouldBlockEventStream(*web_event);
136 if (send_ack) { 139 if (send_ack) {
137 // Ultimately, this ACK needs to go back to the Mus client lib which is not 140 // Ultimately, this ACK needs to go back to the Mus client lib which is not
138 // thread-safe and lives on the compositor thread. For ACKs that are passed 141 // thread-safe and lives on the compositor thread. For ACKs that are passed
139 // to the main thread we pass them back to the compositor thread via 142 // to the main thread we pass them back to the compositor thread via
140 // OnWindowInputEventAckOnMainThread. 143 // OnWindowInputEventAckOnMainThread.
141 ack = 144 ack =
142 base::Bind(&CompositorMusConnection::OnWindowInputEventAckOnMainThread, 145 base::Bind(&CompositorMusConnection::OnWindowInputEventAckOnMainThread,
143 this, *ack_callback->get()); 146 this, *ack_callback->get());
144 ack_callback->reset(); 147 ack_callback->reset();
145 } 148 }
146 main_task_runner_->PostTask( 149 main_task_runner_->PostTask(
147 FROM_HERE, 150 FROM_HERE,
148 base::Bind(&CompositorMusConnection::OnWindowInputEventOnMainThread, this, 151 base::Bind(&CompositorMusConnection::OnWindowInputEventOnMainThread, this,
149 base::Passed(std::move(web_event)), ack)); 152 base::Passed(std::move(web_event)), ack));
150 } 153 }
151 154
152 } // namespace content 155 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/mus/compositor_mus_connection.h ('k') | content/renderer/mus/compositor_mus_connection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698