| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test_browser_thread_bundle.h" | 5 #include "content/public/test/test_browser_thread_bundle.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/test/scoped_task_scheduler.h" |
| 9 #include "content/browser/browser_thread_impl.h" | 10 #include "content/browser/browser_thread_impl.h" |
| 10 #include "content/public/test/test_browser_thread.h" | 11 #include "content/public/test/test_browser_thread.h" |
| 11 | 12 |
| 12 namespace content { | 13 namespace content { |
| 13 | 14 |
| 14 TestBrowserThreadBundle::TestBrowserThreadBundle() | 15 TestBrowserThreadBundle::TestBrowserThreadBundle() |
| 15 : TestBrowserThreadBundle(DEFAULT) {} | 16 : TestBrowserThreadBundle(DEFAULT) {} |
| 16 | 17 |
| 17 TestBrowserThreadBundle::TestBrowserThreadBundle(int options) | 18 TestBrowserThreadBundle::TestBrowserThreadBundle(int options) |
| 18 : options_(options), threads_started_(false) { | 19 : options_(options), threads_started_(false) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 CHECK(!(options_ & IO_MAINLOOP) || !(options_ & REAL_IO_THREAD)); | 58 CHECK(!(options_ & IO_MAINLOOP) || !(options_ & REAL_IO_THREAD)); |
| 58 // There must be a thread to start to use DONT_START_THREADS | 59 // There must be a thread to start to use DONT_START_THREADS |
| 59 CHECK((options_ & ~IO_MAINLOOP) != DONT_START_THREADS); | 60 CHECK((options_ & ~IO_MAINLOOP) != DONT_START_THREADS); |
| 60 | 61 |
| 61 if (options_ & IO_MAINLOOP) { | 62 if (options_ & IO_MAINLOOP) { |
| 62 message_loop_.reset(new base::MessageLoopForIO()); | 63 message_loop_.reset(new base::MessageLoopForIO()); |
| 63 } else { | 64 } else { |
| 64 message_loop_.reset(new base::MessageLoopForUI()); | 65 message_loop_.reset(new base::MessageLoopForUI()); |
| 65 } | 66 } |
| 66 | 67 |
| 68 task_scheduler_.reset( |
| 69 new base::test::ScopedTaskScheduler(message_loop_.get())); |
| 70 |
| 67 ui_thread_.reset( | 71 ui_thread_.reset( |
| 68 new TestBrowserThread(BrowserThread::UI, message_loop_.get())); | 72 new TestBrowserThread(BrowserThread::UI, message_loop_.get())); |
| 69 | 73 |
| 70 if (options_ & REAL_DB_THREAD) { | 74 if (options_ & REAL_DB_THREAD) { |
| 71 db_thread_.reset(new TestBrowserThread(BrowserThread::DB)); | 75 db_thread_.reset(new TestBrowserThread(BrowserThread::DB)); |
| 72 } else { | 76 } else { |
| 73 db_thread_.reset( | 77 db_thread_.reset( |
| 74 new TestBrowserThread(BrowserThread::DB, message_loop_.get())); | 78 new TestBrowserThread(BrowserThread::DB, message_loop_.get())); |
| 75 } | 79 } |
| 76 | 80 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 if (options_ & REAL_FILE_THREAD) | 112 if (options_ & REAL_FILE_THREAD) |
| 109 file_thread_->Start(); | 113 file_thread_->Start(); |
| 110 | 114 |
| 111 if (options_ & REAL_IO_THREAD) | 115 if (options_ & REAL_IO_THREAD) |
| 112 io_thread_->StartIOThread(); | 116 io_thread_->StartIOThread(); |
| 113 | 117 |
| 114 threads_started_ = true; | 118 threads_started_ = true; |
| 115 } | 119 } |
| 116 | 120 |
| 117 } // namespace content | 121 } // namespace content |
| OLD | NEW |