Fix race on Mojo Input Message based host_ callback object.
The host_ ptr was only populated on the Widget's input handler interface
and if an event was received before that binding wasn't completed before
the first touch start was received and a null host would be accessed.
Add the host interface to the frame input handler interface so that there
is no race. Whenever input is handled there will be a host.
BUG=774340
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_site_isolation
Change-Id: I514d97c13f260f8af7d0224de9aa7c6488c67f80
Reviewed-on: https://chromium-review.googlesource.com/742082
Commit-Queue: Dave Tapuska <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Nick Carter <[email protected]>
Cr-Commit-Position: refs/heads/master@{#516729}
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index 316edef0..5704486f 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -1132,9 +1132,8 @@
void RenderWidget::OnDidOverscroll(const ui::DidOverscrollParams& params) {
if (widget_input_handler_manager_) {
- WidgetInputHandlerManager::WidgetInputHandlerHost host =
- widget_input_handler_manager_->GetWidgetInputHandlerHost();
- (*host)->DidOverscroll(params);
+ widget_input_handler_manager_->GetWidgetInputHandlerHost()->DidOverscroll(
+ params);
} else {
Send(new InputHostMsg_DidOverscroll(routing_id_, params));
}
@@ -1737,9 +1736,8 @@
// process to cancel the input method's ongoing composition session, to make
// sure we are in a consistent state.
if (widget_input_handler_manager_) {
- WidgetInputHandlerManager::WidgetInputHandlerHost host =
- widget_input_handler_manager_->GetWidgetInputHandlerHost();
- (*host)->ImeCancelComposition();
+ widget_input_handler_manager_->GetWidgetInputHandlerHost()
+ ->ImeCancelComposition();
} else {
Send(new InputHostMsg_ImeCancelComposition(routing_id()));
}
@@ -1992,10 +1990,9 @@
composition_character_bounds_ = character_bounds;
composition_range_ = range;
if (widget_input_handler_manager_) {
- WidgetInputHandlerManager::WidgetInputHandlerHost host =
- widget_input_handler_manager_->GetWidgetInputHandlerHost();
- (*host)->ImeCompositionRangeChanged(composition_range_,
- composition_character_bounds_);
+ widget_input_handler_manager_->GetWidgetInputHandlerHost()
+ ->ImeCompositionRangeChanged(composition_range_,
+ composition_character_bounds_);
} else {
Send(new InputHostMsg_ImeCompositionRangeChanged(
routing_id(), composition_range_, composition_character_bounds_));
@@ -2517,8 +2514,8 @@
void RenderWidget::SetupWidgetInputHandler(
mojom::WidgetInputHandlerRequest request,
mojom::WidgetInputHandlerHostPtr host) {
- widget_input_handler_manager_->AddInterface(std::move(request));
- widget_input_handler_manager_->SetWidgetInputHandlerHost(std::move(host));
+ widget_input_handler_manager_->AddInterface(std::move(request),
+ std::move(host));
}
void RenderWidget::SetWidgetBinding(mojom::WidgetRequest request) {