| OLD | NEW |
| 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" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 ack.Run(EventResult::UNHANDLED); | 86 ack.Run(EventResult::UNHANDLED); |
| 87 return; | 87 return; |
| 88 } | 88 } |
| 89 connection->OnWindowInputEvent(std::move(web_event), ack); | 89 connection->OnWindowInputEvent(std::move(web_event), ack); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void CompositorMusConnection::OnWindowInputEventAckOnMainThread( | 92 void CompositorMusConnection::OnWindowInputEventAckOnMainThread( |
| 93 const base::Callback<void(EventResult)>& ack, | 93 const base::Callback<void(EventResult)>& ack, |
| 94 EventResult result) { | 94 EventResult result) { |
| 95 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 95 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 96 compositor_task_runner_->PostTask(FROM_HERE, base::Bind(ack, result)); | 96 if (!ack.is_null()) |
| 97 compositor_task_runner_->PostTask(FROM_HERE, base::Bind(ack, result)); |
| 97 } | 98 } |
| 98 | 99 |
| 99 void CompositorMusConnection::OnWindowTreeClientDestroyed( | 100 void CompositorMusConnection::OnWindowTreeClientDestroyed( |
| 100 mus::WindowTreeClient* client) { | 101 mus::WindowTreeClient* client) { |
| 101 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); | 102 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); |
| 102 main_task_runner_->PostTask( | 103 main_task_runner_->PostTask( |
| 103 FROM_HERE, | 104 FROM_HERE, |
| 104 base::Bind(&CompositorMusConnection::OnConnectionLostOnMainThread, this)); | 105 base::Bind(&CompositorMusConnection::OnConnectionLostOnMainThread, this)); |
| 105 } | 106 } |
| 106 | 107 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 base::Callback<void(EventResult)> ack = | 139 base::Callback<void(EventResult)> ack = |
| 139 base::Bind(&::DoNothingWithEventResult); | 140 base::Bind(&::DoNothingWithEventResult); |
| 140 const bool send_ack = WebInputEventTraits::ShouldBlockEventStream(*web_event); | 141 const bool send_ack = WebInputEventTraits::ShouldBlockEventStream(*web_event); |
| 141 if (send_ack) { | 142 if (send_ack) { |
| 142 // Ultimately, this ACK needs to go back to the Mus client lib which is not | 143 // Ultimately, this ACK needs to go back to the Mus client lib which is not |
| 143 // thread-safe and lives on the compositor thread. For ACKs that are passed | 144 // thread-safe and lives on the compositor thread. For ACKs that are passed |
| 144 // to the main thread we pass them back to the compositor thread via | 145 // to the main thread we pass them back to the compositor thread via |
| 145 // OnWindowInputEventAckOnMainThread. | 146 // OnWindowInputEventAckOnMainThread. |
| 146 ack = | 147 ack = |
| 147 base::Bind(&CompositorMusConnection::OnWindowInputEventAckOnMainThread, | 148 base::Bind(&CompositorMusConnection::OnWindowInputEventAckOnMainThread, |
| 148 this, *ack_callback->get()); | 149 this, |
| 149 ack_callback->reset(); | 150 ack_callback ? *ack_callback->get() |
| 151 : base::Callback<void(EventResult)>()); |
| 152 if (ack_callback) |
| 153 ack_callback->reset(); |
| 150 } | 154 } |
| 151 main_task_runner_->PostTask( | 155 main_task_runner_->PostTask( |
| 152 FROM_HERE, | 156 FROM_HERE, |
| 153 base::Bind(&CompositorMusConnection::OnWindowInputEventOnMainThread, this, | 157 base::Bind(&CompositorMusConnection::OnWindowInputEventOnMainThread, this, |
| 154 base::Passed(std::move(web_event)), ack)); | 158 base::Passed(std::move(web_event)), ack)); |
| 155 } | 159 } |
| 156 | 160 |
| 157 } // namespace content | 161 } // namespace content |
| OLD | NEW |