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

Side by Side Diff: content/public/test/browser_test_utils.cc

Issue 2387353004: Delay Input.dispatchKeyEvent response until after key event ack. (Closed)
Patch Set: add test, address review comments about docs Created 4 years, 2 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 (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 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after
1522 InputHostMsg_HandleInputEvent_ACK::Read(&message, &params); 1522 InputHostMsg_HandleInputEvent_ACK::Read(&message, &params);
1523 blink::WebInputEvent::Type ack_type = std::get<0>(params).type; 1523 blink::WebInputEvent::Type ack_type = std::get<0>(params).type;
1524 InputEventAckState ack_state = std::get<0>(params).state; 1524 InputEventAckState ack_state = std::get<0>(params).state;
1525 BrowserThread::PostTask( 1525 BrowserThread::PostTask(
1526 BrowserThread::UI, FROM_HERE, 1526 BrowserThread::UI, FROM_HERE,
1527 base::Bind(&InputMsgWatcher::ReceivedAck, this, ack_type, ack_state)); 1527 base::Bind(&InputMsgWatcher::ReceivedAck, this, ack_type, ack_state));
1528 } 1528 }
1529 return false; 1529 return false;
1530 } 1530 }
1531 1531
1532 bool InputMsgWatcher::HasReceivedAck() {
1533 return ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN;
1534 }
1535
1532 uint32_t InputMsgWatcher::WaitForAck() { 1536 uint32_t InputMsgWatcher::WaitForAck() {
1533 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1537 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1534 if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN) 1538 if (HasReceivedAck())
1535 return ack_result_; 1539 return ack_result_;
1536 base::RunLoop run_loop; 1540 base::RunLoop run_loop;
1537 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); 1541 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure());
1538 run_loop.Run(); 1542 run_loop.Run();
1539 return ack_result_; 1543 return ack_result_;
1540 } 1544 }
1541 1545
1542 #if defined(OS_WIN) 1546 #if defined(OS_WIN)
1543 static void RunTaskAndSignalCompletion(const base::Closure& task, 1547 static void RunTaskAndSignalCompletion(const base::Closure& task,
1544 base::WaitableEvent* completion) { 1548 base::WaitableEvent* completion) {
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 1781
1778 std::string ascii_message = base::UTF16ToASCII(message); 1782 std::string ascii_message = base::UTF16ToASCII(message);
1779 if (base::MatchPattern(ascii_message, filter_)) { 1783 if (base::MatchPattern(ascii_message, filter_)) {
1780 message_ = ascii_message; 1784 message_ = ascii_message;
1781 message_loop_runner_->Quit(); 1785 message_loop_runner_->Quit();
1782 } 1786 }
1783 return false; 1787 return false;
1784 } 1788 }
1785 1789
1786 } // namespace content 1790 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698