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

Unified Diff: content/renderer/mus/compositor_mus_connection.cc

Issue 2265393002: Refactor compositor event handling path to be callback-based (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tdresser's review Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/mus/compositor_mus_connection.cc
diff --git a/content/renderer/mus/compositor_mus_connection.cc b/content/renderer/mus/compositor_mus_connection.cc
index be3998c185111c2ff4fea9940c9445952485b73d..e4040881ab5327a9408c3d341b6f278b9bf9cd7c 100644
--- a/content/renderer/mus/compositor_mus_connection.cc
+++ b/content/renderer/mus/compositor_mus_connection.cc
@@ -83,7 +83,7 @@ void CompositorMusConnection::OnConnectionLostOnMainThread() {
}
void CompositorMusConnection::OnWindowInputEventOnMainThread(
- std::unique_ptr<blink::WebInputEvent> web_event,
+ ui::ScopedWebInputEvent web_event,
const base::Callback<void(EventResult)>& ack) {
DCHECK(main_task_runner_->BelongsToCurrentThread());
RenderWidgetMusConnection* connection =
@@ -156,15 +156,34 @@ void CompositorMusConnection::OnWindowInputEvent(
const ui::Event& event,
std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) {
DCHECK(compositor_task_runner_->BelongsToCurrentThread());
- std::unique_ptr<blink::WebInputEvent> web_event(Convert(event));
+
+ // Take ownership of the callback, indicating that we will handle it.
+ std::unique_ptr<base::Callback<void(EventResult)>> callback =
+ std::move(*ack_callback);
+ ui::ScopedWebInputEvent web_event(Convert(event).release());
// TODO(sad): We probably need to plumb LatencyInfo through Mus.
ui::LatencyInfo info;
- InputEventAckState ack_state = input_handler_manager_->HandleInputEvent(
- routing_id_, web_event.get(), &info);
+ input_handler_manager_->HandleInputEvent(
+ routing_id_, std::move(web_event), info,
+ base::Bind(
+ &CompositorMusConnection::DidHandleWindowInputEventAndOverscroll,
+ this, base::Passed(std::move(callback))));
+}
+
+void CompositorMusConnection::DidHandleWindowInputEventAndOverscroll(
+ std::unique_ptr<base::Callback<void(EventResult)>> ack_callback,
+ InputEventAckState ack_state,
+ ui::ScopedWebInputEvent web_event,
+ const ui::LatencyInfo& latency_info,
+ std::unique_ptr<ui::DidOverscrollParams>) {
// TODO(jonross): We probably need to ack the event based on the consumed
// state.
- if (ack_state != INPUT_EVENT_ACK_STATE_NOT_CONSUMED)
+ if (ack_state != INPUT_EVENT_ACK_STATE_NOT_CONSUMED) {
+ // We took the ownership of the callback, so we need to send the ack, and
+ // mark the event as not consumed to preserve existing behavior.
+ ack_callback->Run(EventResult::UNHANDLED);
return;
+ }
base::Callback<void(EventResult)> ack =
base::Bind(&::DoNothingWithEventResult);
const bool send_ack =
@@ -176,9 +195,14 @@ void CompositorMusConnection::OnWindowInputEvent(
// OnWindowInputEventAckOnMainThread.
ack =
base::Bind(&CompositorMusConnection::OnWindowInputEventAckOnMainThread,
- this, *ack_callback->get());
- ack_callback->reset();
+ this, *ack_callback);
+ } else {
+ // We took the ownership of the callback, so we need to send the ack, and
+ // mark the event as not consumed to preserve existing behavior.
+ ack_callback->Run(EventResult::UNHANDLED);
}
+ ack_callback.reset();
+
main_task_runner_->PostTask(
FROM_HERE,
base::Bind(&CompositorMusConnection::OnWindowInputEventOnMainThread, this,

Powered by Google App Engine
This is Rietveld 408576698