| 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 "chrome/browser/sync_file_system/sync_file_system_test_util.h" | 5 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 MultiThreadTestHelper::MultiThreadTestHelper() | 37 MultiThreadTestHelper::MultiThreadTestHelper() |
| 38 : file_thread_(new base::Thread("File_Thread")), | 38 : file_thread_(new base::Thread("File_Thread")), |
| 39 io_thread_(new base::Thread("IO_Thread")) {} | 39 io_thread_(new base::Thread("IO_Thread")) {} |
| 40 | 40 |
| 41 MultiThreadTestHelper::~MultiThreadTestHelper() {} | 41 MultiThreadTestHelper::~MultiThreadTestHelper() {} |
| 42 | 42 |
| 43 void MultiThreadTestHelper::SetUp() { | 43 void MultiThreadTestHelper::SetUp() { |
| 44 file_thread_->Start(); | 44 file_thread_->Start(); |
| 45 io_thread_->StartWithOptions( | 45 io_thread_->StartWithOptions( |
| 46 base::Thread::Options(MessageLoop::TYPE_IO, 0)); | 46 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 47 | 47 |
| 48 browser_ui_thread_.reset( | 48 browser_ui_thread_.reset( |
| 49 new TestBrowserThread(BrowserThread::UI, | 49 new TestBrowserThread(BrowserThread::UI, base::MessageLoop::current())); |
| 50 MessageLoop::current())); | |
| 51 browser_file_thread_.reset( | 50 browser_file_thread_.reset( |
| 52 new TestBrowserThread(BrowserThread::FILE, | 51 new TestBrowserThread(BrowserThread::FILE, file_thread_->message_loop())); |
| 53 file_thread_->message_loop())); | |
| 54 browser_io_thread_.reset( | 52 browser_io_thread_.reset( |
| 55 new TestBrowserThread(BrowserThread::IO, | 53 new TestBrowserThread(BrowserThread::IO, |
| 56 io_thread_->message_loop())); | 54 io_thread_->message_loop())); |
| 57 | 55 |
| 58 ui_task_runner_ = | 56 ui_task_runner_ = |
| 59 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); | 57 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); |
| 60 file_task_runner_ = | 58 file_task_runner_ = |
| 61 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE); | 59 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE); |
| 62 io_task_runner_ = | 60 io_task_runner_ = |
| 63 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 61 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| 64 } | 62 } |
| 65 | 63 |
| 66 void MultiThreadTestHelper::TearDown() { | 64 void MultiThreadTestHelper::TearDown() { |
| 67 // Make sure we give some more time to finish tasks on the FILE thread | 65 // Make sure we give some more time to finish tasks on the FILE thread |
| 68 // before stopping IO/FILE threads. | 66 // before stopping IO/FILE threads. |
| 69 base::RunLoop run_loop; | 67 base::RunLoop run_loop; |
| 70 file_task_runner_->PostTaskAndReply( | 68 file_task_runner_->PostTaskAndReply( |
| 71 FROM_HERE, base::Bind(&base::DoNothing), run_loop.QuitClosure()); | 69 FROM_HERE, base::Bind(&base::DoNothing), run_loop.QuitClosure()); |
| 72 run_loop.Run(); | 70 run_loop.Run(); |
| 73 | 71 |
| 74 io_thread_->Stop(); | 72 io_thread_->Stop(); |
| 75 file_thread_->Stop(); | 73 file_thread_->Stop(); |
| 76 } | 74 } |
| 77 | 75 |
| 78 } // namespace sync_file_system | 76 } // namespace sync_file_system |
| OLD | NEW |