| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/public/test/browser_test_utils.h" | 5 #include "content/public/test/browser_test_utils.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <tuple> | 8 #include <tuple> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1472 BrowserThread::UI, FROM_HERE, | 1472 BrowserThread::UI, FROM_HERE, |
| 1473 base::Bind(&MainThreadFrameObserver::Quit, base::Unretained(this))); | 1473 base::Bind(&MainThreadFrameObserver::Quit, base::Unretained(this))); |
| 1474 } | 1474 } |
| 1475 return true; | 1475 return true; |
| 1476 } | 1476 } |
| 1477 | 1477 |
| 1478 InputMsgWatcher::InputMsgWatcher(RenderWidgetHost* render_widget_host, | 1478 InputMsgWatcher::InputMsgWatcher(RenderWidgetHost* render_widget_host, |
| 1479 blink::WebInputEvent::Type type) | 1479 blink::WebInputEvent::Type type) |
| 1480 : BrowserMessageFilter(InputMsgStart), | 1480 : BrowserMessageFilter(InputMsgStart), |
| 1481 wait_for_type_(type), | 1481 wait_for_type_(type), |
| 1482 ack_result_(INPUT_EVENT_ACK_STATE_UNKNOWN) { | 1482 ack_result_(INPUT_EVENT_ACK_STATE_UNKNOWN), |
| 1483 ack_source_(static_cast<uint32_t>(InputEventAckSource::UNKNOWN)) { |
| 1483 render_widget_host->GetProcess()->AddFilter(this); | 1484 render_widget_host->GetProcess()->AddFilter(this); |
| 1484 } | 1485 } |
| 1485 | 1486 |
| 1486 InputMsgWatcher::~InputMsgWatcher() {} | 1487 InputMsgWatcher::~InputMsgWatcher() {} |
| 1487 | 1488 |
| 1488 void InputMsgWatcher::ReceivedAck(blink::WebInputEvent::Type ack_type, | 1489 void InputMsgWatcher::ReceivedAck(blink::WebInputEvent::Type ack_type, |
| 1489 uint32_t ack_state) { | 1490 uint32_t ack_state, |
| 1491 uint32_t ack_source) { |
| 1490 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1492 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1491 if (wait_for_type_ == ack_type) { | 1493 if (wait_for_type_ == ack_type) { |
| 1492 ack_result_ = ack_state; | 1494 ack_result_ = ack_state; |
| 1495 ack_source_ = ack_source; |
| 1493 if (!quit_.is_null()) | 1496 if (!quit_.is_null()) |
| 1494 quit_.Run(); | 1497 quit_.Run(); |
| 1495 } | 1498 } |
| 1496 } | 1499 } |
| 1497 | 1500 |
| 1498 bool InputMsgWatcher::OnMessageReceived(const IPC::Message& message) { | 1501 bool InputMsgWatcher::OnMessageReceived(const IPC::Message& message) { |
| 1499 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1502 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 1500 if (message.type() == InputHostMsg_HandleInputEvent_ACK::ID) { | 1503 if (message.type() == InputHostMsg_HandleInputEvent_ACK::ID) { |
| 1501 InputHostMsg_HandleInputEvent_ACK::Param params; | 1504 InputHostMsg_HandleInputEvent_ACK::Param params; |
| 1502 InputHostMsg_HandleInputEvent_ACK::Read(&message, ¶ms); | 1505 InputHostMsg_HandleInputEvent_ACK::Read(&message, ¶ms); |
| 1503 blink::WebInputEvent::Type ack_type = std::get<0>(params).type; | 1506 blink::WebInputEvent::Type ack_type = std::get<0>(params).type; |
| 1504 InputEventAckState ack_state = std::get<0>(params).state; | 1507 InputEventAckState ack_state = std::get<0>(params).state; |
| 1508 InputEventAckSource ack_source = std::get<0>(params).source; |
| 1505 BrowserThread::PostTask( | 1509 BrowserThread::PostTask( |
| 1506 BrowserThread::UI, FROM_HERE, | 1510 BrowserThread::UI, FROM_HERE, |
| 1507 base::Bind(&InputMsgWatcher::ReceivedAck, this, ack_type, ack_state)); | 1511 base::Bind(&InputMsgWatcher::ReceivedAck, this, ack_type, ack_state, |
| 1512 static_cast<uint32_t>(ack_source))); |
| 1508 } | 1513 } |
| 1509 return false; | 1514 return false; |
| 1510 } | 1515 } |
| 1511 | 1516 |
| 1512 uint32_t InputMsgWatcher::WaitForAck() { | 1517 uint32_t InputMsgWatcher::WaitForAck() { |
| 1513 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1518 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1514 if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN) | 1519 if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN) |
| 1515 return ack_result_; | 1520 return ack_result_; |
| 1516 base::RunLoop run_loop; | 1521 base::RunLoop run_loop; |
| 1517 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); | 1522 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1757 | 1762 |
| 1758 std::string ascii_message = base::UTF16ToASCII(message); | 1763 std::string ascii_message = base::UTF16ToASCII(message); |
| 1759 if (base::MatchPattern(ascii_message, filter_)) { | 1764 if (base::MatchPattern(ascii_message, filter_)) { |
| 1760 message_ = ascii_message; | 1765 message_ = ascii_message; |
| 1761 message_loop_runner_->Quit(); | 1766 message_loop_runner_->Quit(); |
| 1762 } | 1767 } |
| 1763 return false; | 1768 return false; |
| 1764 } | 1769 } |
| 1765 | 1770 |
| 1766 } // namespace content | 1771 } // namespace content |
| OLD | NEW |