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

Side by Side Diff: ui/ui_controls/ui_controls_internal_win.cc

Issue 10479018: Add base::RunLoop and update ui_test_utils to use it to reduce flakiness (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more test fixes Created 8 years, 6 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 | Annotate | Revision Log
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 "ui/ui_controls/ui_controls_internal_win.h" 5 #include "ui/ui_controls/ui_controls_internal_win.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 void UninstallHook(InputDispatcher* dispatcher) { 105 void UninstallHook(InputDispatcher* dispatcher) {
106 if (current_dispatcher_ == dispatcher) { 106 if (current_dispatcher_ == dispatcher) {
107 installed_hook_ = false; 107 installed_hook_ = false;
108 current_dispatcher_ = NULL; 108 current_dispatcher_ = NULL;
109 UnhookWindowsHookEx(next_hook_); 109 UnhookWindowsHookEx(next_hook_);
110 } 110 }
111 } 111 }
112 112
113 InputDispatcher::InputDispatcher(const base::Closure& task, 113 InputDispatcher::InputDispatcher(const base::Closure& task,
114 UINT message_waiting_for) 114 UINT message_waiting_for)
115 : task_(task), message_waiting_for_(message_waiting_for) { 115 : task_(task), message_waiting_for_(message_waiting_for) {
jar (doing other things) 2012/06/08 01:05:37 nit: one init per line
116 InstallHook(this, message_waiting_for == WM_KEYUP); 116 InstallHook(this, message_waiting_for == WM_KEYUP);
117 } 117 }
118 118
119 InputDispatcher::~InputDispatcher() { 119 InputDispatcher::~InputDispatcher() {
120 // Make sure the hook isn't installed. 120 // Make sure the hook isn't installed.
121 UninstallHook(this); 121 UninstallHook(this);
122 } 122 }
123 123
124 void InputDispatcher::DispatchedMessage(WPARAM message) { 124 void InputDispatcher::DispatchedMessage(WPARAM message) {
125 if (message == message_waiting_for_) 125 if (message == message_waiting_for_)
126 MatchingMessageFound(); 126 MatchingMessageFound();
127 } 127 }
128 128
129 void InputDispatcher::MatchingMessageFound() { 129 void InputDispatcher::MatchingMessageFound() {
130 UninstallHook(this); 130 UninstallHook(this);
131 // At the time we're invoked the event has not actually been processed. 131 // At the time we're invoked the event has not actually been processed.
132 // Use PostTask to make sure the event has been processed before notifying. 132 // Use PostTask to make sure the event has been processed before notifying.
133 MessageLoop::current()->PostTask( 133 MessageLoop::current()->PostTask(
134 FROM_HERE, base::Bind(&InputDispatcher::NotifyTask, this)); 134 FROM_HERE, base::Bind(&InputDispatcher::NotifyTask, this));
135 } 135 }
136 136
137 void InputDispatcher::NotifyTask() { 137 void InputDispatcher::NotifyTask() {
138 task_.Run(); 138 if (!task_.is_null()) {
139 task_.Run();
140 task_.Reset();
jar (doing other things) 2012/06/08 01:05:37 Why did this change?
jbates 2012/06/13 22:11:20 I'll undo this. I just noticed there's a DCHECK i
141 }
139 Release(); 142 Release();
140 } 143 }
141 144
142 // Private functions ---------------------------------------------------------- 145 // Private functions ----------------------------------------------------------
143 146
144 // Populate the INPUT structure with the appropriate keyboard event 147 // Populate the INPUT structure with the appropriate keyboard event
145 // parameters required by SendInput 148 // parameters required by SendInput
146 bool FillKeyboardInput(ui::KeyboardCode key, INPUT* input, bool key_up) { 149 bool FillKeyboardInput(ui::KeyboardCode key, INPUT* input, bool key_up) {
147 memset(input, 0, sizeof(INPUT)); 150 memset(input, 0, sizeof(INPUT));
148 input->type = INPUT_KEYBOARD; 151 input->type = INPUT_KEYBOARD;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 return false; 341 return false;
339 342
340 if (dispatcher.get()) 343 if (dispatcher.get())
341 dispatcher->AddRef(); 344 dispatcher->AddRef();
342 345
343 return true; 346 return true;
344 } 347 }
345 348
346 } // namespace internal 349 } // namespace internal
347 } // namespace ui_controls 350 } // namespace ui_controls
OLDNEW
« chrome/test/base/ui_test_utils.h ('K') | « content/test/test_navigation_observer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698