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

Side by Side Diff: chrome/test/base/ui_test_utils.cc

Issue 8873032: Removing MessageLoop::QuitTask() from chrome/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert 3 more problematic files Created 9 years 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
« no previous file with comments | « chrome/test/base/browser_with_test_window_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/test/base/ui_test_utils.h" 5 #include "chrome/test/base/ui_test_utils.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #endif 9 #endif
10 10
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 Value* result_val; 237 Value* result_val;
238 if (!list || !list->GetSize() || 238 if (!list || !list->GetSize() ||
239 !list->Remove(0, &result_val)) // Remove gives us ownership of the value. 239 !list->Remove(0, &result_val)) // Remove gives us ownership of the value.
240 return false; 240 return false;
241 241
242 result->reset(result_val); 242 result->reset(result_val);
243 return true; 243 return true;
244 } 244 }
245 245
246 void RunAllPendingMessageAndSendQuit(content::BrowserThread::ID thread_id) { 246 void RunAllPendingMessageAndSendQuit(content::BrowserThread::ID thread_id) {
247 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 247 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
248 RunMessageLoop(); 248 RunMessageLoop();
249 content::BrowserThread::PostTask(thread_id, FROM_HERE, 249 content::BrowserThread::PostTask(thread_id, FROM_HERE,
250 new MessageLoop::QuitTask()); 250 MessageLoop::QuitClosure());
251 } 251 }
252 252
253 } // namespace 253 } // namespace
254 254
255 void RunMessageLoop() { 255 void RunMessageLoop() {
256 MessageLoop* loop = MessageLoop::current(); 256 MessageLoop* loop = MessageLoop::current();
257 MessageLoopForUI* ui_loop = 257 MessageLoopForUI* ui_loop =
258 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI) ? 258 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI) ?
259 MessageLoopForUI::current() : NULL; 259 MessageLoopForUI::current() : NULL;
260 bool did_allow_task_nesting = loop->NestableTasksAllowed(); 260 bool did_allow_task_nesting = loop->NestableTasksAllowed();
261 loop->SetNestableTasksAllowed(true); 261 loop->SetNestableTasksAllowed(true);
262 if (ui_loop) { 262 if (ui_loop) {
263 #if defined(USE_AURA) 263 #if defined(USE_AURA)
264 aura::RootWindow::GetInstance()->Run(); 264 aura::RootWindow::GetInstance()->Run();
265 #elif defined(TOOLKIT_VIEWS) 265 #elif defined(TOOLKIT_VIEWS)
266 views::AcceleratorHandler handler; 266 views::AcceleratorHandler handler;
267 ui_loop->RunWithDispatcher(&handler); 267 ui_loop->RunWithDispatcher(&handler);
268 #elif defined(OS_POSIX) && !defined(OS_MACOSX) 268 #elif defined(OS_POSIX) && !defined(OS_MACOSX)
269 ui_loop->RunWithDispatcher(NULL); 269 ui_loop->RunWithDispatcher(NULL);
270 #else 270 #else
271 ui_loop->Run(); 271 ui_loop->Run();
272 #endif 272 #endif
273 } else { 273 } else {
274 loop->Run(); 274 loop->Run();
275 } 275 }
276 loop->SetNestableTasksAllowed(did_allow_task_nesting); 276 loop->SetNestableTasksAllowed(did_allow_task_nesting);
277 } 277 }
278 278
279 void RunAllPendingInMessageLoop() { 279 void RunAllPendingInMessageLoop() {
280 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 280 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
281 ui_test_utils::RunMessageLoop(); 281 ui_test_utils::RunMessageLoop();
282 } 282 }
283 283
284 void RunAllPendingInMessageLoop(content::BrowserThread::ID thread_id) { 284 void RunAllPendingInMessageLoop(content::BrowserThread::ID thread_id) {
285 if (content::BrowserThread::CurrentlyOn(thread_id)) { 285 if (content::BrowserThread::CurrentlyOn(thread_id)) {
286 RunAllPendingInMessageLoop(); 286 RunAllPendingInMessageLoop();
287 return; 287 return;
288 } 288 }
289 content::BrowserThread::ID current_thread_id; 289 content::BrowserThread::ID current_thread_id;
290 if (!content::BrowserThread::GetCurrentThreadIdentifier(&current_thread_id)) { 290 if (!content::BrowserThread::GetCurrentThreadIdentifier(&current_thread_id)) {
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 } 684 }
685 685
686 void TimedMessageLoopRunner::RunFor(int ms) { 686 void TimedMessageLoopRunner::RunFor(int ms) {
687 QuitAfter(ms); 687 QuitAfter(ms);
688 quit_loop_invoked_ = false; 688 quit_loop_invoked_ = false;
689 loop_->Run(); 689 loop_->Run();
690 } 690 }
691 691
692 void TimedMessageLoopRunner::Quit() { 692 void TimedMessageLoopRunner::Quit() {
693 quit_loop_invoked_ = true; 693 quit_loop_invoked_ = true;
694 loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask); 694 loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
695 } 695 }
696 696
697 void TimedMessageLoopRunner::QuitAfter(int ms) { 697 void TimedMessageLoopRunner::QuitAfter(int ms) {
698 quit_loop_invoked_ = true; 698 quit_loop_invoked_ = true;
699 loop_->PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask, ms); 699 loop_->PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), ms);
700 } 700 }
701 701
702 namespace { 702 namespace {
703 703
704 void AppendToPythonPath(const FilePath& dir) { 704 void AppendToPythonPath(const FilePath& dir) {
705 #if defined(OS_WIN) 705 #if defined(OS_WIN)
706 const wchar_t kPythonPath[] = L"PYTHONPATH"; 706 const wchar_t kPythonPath[] = L"PYTHONPATH";
707 // TODO(ukai): handle longer PYTHONPATH variables. 707 // TODO(ukai): handle longer PYTHONPATH variables.
708 wchar_t oldpath[4096]; 708 wchar_t oldpath[4096];
709 if (::GetEnvironmentVariable(kPythonPath, oldpath, arraysize(oldpath)) == 0) { 709 if (::GetEnvironmentVariable(kPythonPath, oldpath, arraysize(oldpath)) == 0) {
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); 1061 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap);
1062 } 1062 }
1063 1063
1064 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { 1064 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) {
1065 DCHECK(bitmap); 1065 DCHECK(bitmap);
1066 SnapshotTaker taker; 1066 SnapshotTaker taker;
1067 return taker.TakeEntirePageSnapshot(rvh, bitmap); 1067 return taker.TakeEntirePageSnapshot(rvh, bitmap);
1068 } 1068 }
1069 1069
1070 } // namespace ui_test_utils 1070 } // namespace ui_test_utils
OLDNEW
« no previous file with comments | « chrome/test/base/browser_with_test_window_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698